I'm writing an application in Python so I'm writing an installation file for Bash. I'm having an issue where the exit() function is repeating itself rather than calling the install function from within an if statement. Here's the code...
#! /bin/bash
function install {
if [ $proceed == "y" ];
then
echo " "
echo "Thank you for installing the ACS Troubleshooter!"
echo " "
echo "The next line is going to ask for your password to initialize a download"
echo "sequence from the standard Ubuntu repositories"
echo " "
#sudo apt-get install testing
mkdir ~/Desktop/ACSapplicationFolder
sudo cp -r test ~/Desktop/ACSapplicationFolder
sudo chown -R ~/Desktop/ACSapplicationFolder
echo " "
echo " "
echo "The ACS Troubleshooter has been successfully installed."
read -p "Press [ENTER] key to open the ACS Troubleshooter > "
python gui.py &
elif [ $proceed == "n" ];
then
exit
fi
}
function bad_input {
echo "Please enter 'y' to continue the installation or 'n' to abort..."
read -p "> " proceed
if [ $proceed == "y" ];
then
install
elif [ $proceed == "n" ];
then
exit
else
bad_input
fi
}
function exit {
echo "The installation will exit."
echo " Please press [ENTER] to exit the installation or"
echo " press 'y' to reattempt installation."
read -p "> " yes
if [ "$yes" == "y" ];
then
clear
install
#else
#exit 1
fi
}
clear
echo " "
echo " *************************"
echo " "
echo " INSTALLATION: ACS TROUBLESHOOTER"
echo " "
echo " The installer is going to install Python, the language this application"
echo " is written in. Most computers don't have this installed by default so "
echo " we need to do this before running the Troubleshooter. It's going to ask "
echo " you to input your password one time to allow permission to install files "
echo " to sensitive directories."
echo " *************************"
echo " "
echo " "
echo "Should we continue with the installation? (type 'y' or 'n' then press enter) "
#echo "> "
read -p "> " proceed
if [ $proceed == "y" ];
then
install
elif [ $proceed == "n" ];
then
exit
else
bad_input
fi
The only function giving me trouble is exit() - the other two are working exactly as intended...
When testing the script, giving 'n' at the initial prompt runs exit(), but giving 'y' at the exit() prompt should rerun install() but it reissues the exit() prompt...getting frustrated...Can anyone answer why this is doing this?
*Note: I am just starting this so I know there are errors in install() and a few other quirks but I'm just trying to test the functions before filling in their extended instructions...