Getting rid of redundant code in install and unisntall

This commit is contained in:
Alex Epstein 2017-07-06 20:45:32 -04:00
parent e952b32fdc
commit 7656e970de
2 changed files with 63 additions and 288 deletions

View File

@ -2,118 +2,40 @@
# Author: Alexander Epstein https://github.com/alexanderepstein # Author: Alexander Epstein https://github.com/alexanderepstein
currentVersion="1.10.1" currentVersion="1.10.1"
if [[ $# == 0 ]]; then askInstall()
{
echo -n "Do you wish to install currency [Y/n]: " echo -n "Do you wish to install $1 [Y/n]: "
read -r answer read -r answer
if [[ "$answer" == "Y" || "$answer" == "y" ]] ;then if [[ "$answer" == "Y" || "$answer" == "y" ]] ;then
cd currency || exit 1 cd $1 || return 1
./install.sh || return 1
cd .. || return 1
fi
}
updateTool()
{
if [[ -f /usr/local/bin/$1 ]];then
cd $1 || exit 1
./install.sh || exit 1 ./install.sh || exit 1
cd .. || exit 1 cd .. || exit 1
fi fi
}
unset answer if [[ $# == 0 ]]; then
echo -n "Do you wish to install stocks [Y/n]: "
read -r answer
if [[ "$answer" == "Y" || "$answer" == "y" ]] ;then
cd stocks || exit 1
./install.sh
cd .. || exit 1
fi
unset answer
echo -n "Do you wish to install weather [Y/n]: "
read -r answer
if [[ "$answer" == "Y" || "$answer" == "y" ]] ;then
cd weather || exit 1
./install.sh
cd .. || exit 1
fi
unset answer
echo -n "Do you wish to install crypt [Y/n]: "
read -r answer
if [[ "$answer" == "Y" || "$answer" == "y" ]] ;then
cd crypt || exit 1
./install.sh
cd .. || exit 1
fi
unset answer
echo -n "Do you wish to install movies [Y/n]: "
read -r answer
if [[ "$answer" == "Y" || "$answer" == "y" ]] ;then
cd movies || exit 1
./install.sh
cd .. || exit 1
fi
unset answer
echo -n "Do you wish to install taste [Y/n]: "
read -r answer
if [[ "$answer" == "Y" || "$answer" == "y" ]] ;then
cd taste || exit 1
./install.sh
cd .. || exit 1
fi
unset answer
echo -n "Do you wish to install short [Y/n]: "
read -r answer
if [[ "$answer" == "Y" || "$answer" == "y" ]] ;then
cd short || exit 1
./install.sh
cd .. || exit 1
fi
unset answer
echo -n "Do you wish to install geo [Y/n]: "
read -r answer
if [[ "$answer" == "Y" || "$answer" == "y" ]] ;then
cd geo || exit 1
./install.sh
cd .. || exit 1
fi
unset answer
echo -n "Do you wish to install cheat [Y/n]: "
read -r answer
if [[ "$answer" == "Y" || "$answer" == "y" ]] ;then
cd cheat || exit 1
./install.sh
cd .. || exit 1
fi
unset answer
echo -n "Do you wish to install ytview [Y/n]: "
read -r answer
if [[ "$answer" == "Y" || "$answer" == "y" ]] ;then
cd ytview || exit 1
./install.sh
cd .. || exit 1
fi
unset answer
echo -n "Do you wish to install cloudup [Y/n]: "
read -r answer
if [[ "$answer" == "Y" || "$answer" == "y" ]] ;then
cd cloudup || exit 1
./install.sh
cd .. || exit 1
fi
unset answer
echo -n "Do you wish to install qrify [Y/n]: "
read -r answer
if [[ "$answer" == "Y" || "$answer" == "y" ]] ;then
cd qrify || exit 1
./install.sh
cd .. || exit 1
fi
askInstall currency || exit 1
askInstall stocks || exit 1
askInstall weather || exit 1
askInstall crypt || exit 1
askInstall movies || exit 1
askInstall taste || exit 1
askInstall short || exit 1
askInstall geo || exit 1
askInstall cheat || exit 1
askInstall ytview || exit 1
askInstall cloudup || exit 1
askInstall qrify || exit 1
fi fi
if [[ $1 == "currency" ]];then if [[ $1 == "currency" ]];then
@ -203,66 +125,18 @@ elif [[ $1 == "all" ]];then
cd .. || exit 1 cd .. || exit 1
elif [[ $1 == "update" ]]; then elif [[ $1 == "update" ]]; then
echo "Updating scripts..." echo "Updating scripts..."
if [[ -f /usr/local/bin/currency ]];then updateTool currency
cd currency || exit 1 updateTool stocks
./install.sh || exit 1 updateTool weather
cd .. || exit 1 updateTool crypt
fi updateTool movies
if [[ -f /usr/local/bin/stocks ]];then updateTool taste
cd stocks || exit 1 updateTool short
./install.sh || exit 1 updateTool geo
cd .. || exit 1 updateTool cheat
fi updateTool ytview
if [[ -f /usr/local/bin/weather ]];then updateTool cloudup
cd weather || exit 1 updateTool qrify
./install.sh || exit 1
cd .. || exit 1
fi
if [[ -f /usr/local/bin/crypt ]];then
cd crypt || exit 1
./install.sh || exit 1
cd .. || exit 1
fi
if [[ -f /usr/local/bin/movies ]];then
cd movies || exit 1
./install.sh || exit 1
cd .. || exit 1
fi
if [[ -f /usr/local/bin/taste ]];then
cd taste || exit 1
./install.sh || exit 1
cd .. || exit 1
fi
if [[ -f /usr/local/bin/short ]];then
cd short || exit 1
./install.sh || exit 1
cd .. || exit 1
fi
if [[ -f /usr/local/bin/geo ]];then
cd geo || exit 1
./install.sh || exit 1
cd .. || exit 1
fi
if [[ -f /usr/local/bin/cheat ]];then
cd cheat || exit 1
./install.sh || exit 1
cd .. || exit 1
fi
if [[ -f /usr/local/bin/ytview ]];then
cd ytview || exit 1
./install.sh || exit 1
cd .. || exit 1
fi
if [[ -f /usr/local/bin/cloudup ]];then
cd cloudup || exit 1
./install.sh || exit 1
cd .. || exit 1
fi
if [[ -f /usr/local/bin/qrify ]];then
cd qrify || exit 1
./install.sh || exit 1
cd .. || exit 1
fi
fi fi
echo -n "( •_•)" echo -n "( •_•)"

View File

@ -1,129 +1,30 @@
#!/bin/bash #!/bin/bash
# Author: Alexander Epstein https://github.com/alexanderepstein # Author: Alexander Epstein https://github.com/alexanderepstein
if [[ -f /usr/local/bin/currency ]];then askUninstall()
echo -n "Do you wish to uninstall currency [Y/n]: " {
read -r answer if [[ -f /usr/local/bin/$1 ]];then
if [[ "$answer" == "Y" || "$answer" == "y" ]] ;then echo -n "Do you wish to uninstall $1 [Y/n]: "
cd currency || exit 1 read -r answer
./uninstall.sh || exit 1 if [[ "$answer" == "Y" || "$answer" == "y" ]] ;then
cd .. || exit 1 cd $1 || return 1
./uninstall.sh || return 1
cd .. || return 1
fi
unset answer
fi fi
unset answer }
fi
if [[ -f /usr/local/bin/stocks ]];then
echo -n "Do you wish to uninstall stocks [Y/n]: "
read -r answer
if [[ "$answer" == "Y" || "$answer" == "y" ]] ;then
cd stocks || exit 1
./uninstall.sh
cd .. || exit 1
fi askUninstall currency || exit 1
unset answer askUninstall stocks || exit 1
fi askUninstall weather || exit 1
askUninstall crypt || exit 1
if [[ -f /usr/local/bin/weather ]];then askUninstall movies || exit 1
echo -n "Do you wish to uninstall weather [Y/n]: " askUninstall taste || exit 1
read -r answer askUninstall short || exit 1
if [[ "$answer" == "Y" || "$answer" == "y" ]] ;then askUninstall geo || exit 1
cd weather || exit 1 askUninstall cheat || exit 1
./uninstall.sh askUninstall ytview || exit 1
cd .. || exit 1 askUninstall cloudup || exit 1
askUninstall qrify || exit 1
fi
unset answer
fi
if [[ -f /usr/local/bin/crypt ]];then
echo -n "Do you wish to uninstall crypt [Y/n]: "
read -r answer
if [[ "$answer" == "Y" || "$answer" == "y" ]] ;then
cd crypt || exit 1
./uninstall.sh
cd .. || exit 1
fi
unset answer
fi
if [[ -f /usr/local/bin/movies ]];then
echo -n "Do you wish to uninstall movies [Y/n]: "
read -r answer
if [[ "$answer" == "Y" || "$answer" == "y" ]] ;then
cd movies || exit 1
./uninstall.sh
cd .. || exit 1
fi
fi
if [[ -f /usr/local/bin/taste ]];then
echo -n "Do you wish to uninstall taste [Y/n]: "
read -r answer
if [[ "$answer" == "Y" || "$answer" == "y" ]] ;then
cd taste || exit 1
./uninstall.sh
cd .. || exit 1
fi
fi
if [[ -f /usr/local/bin/short ]];then
echo -n "Do you wish to uninstall short [Y/n]: "
read -r answer
if [[ "$answer" == "Y" || "$answer" == "y" ]] ;then
cd short || exit 1
./uninstall.sh
cd .. || exit 1
fi
fi
if [[ -f /usr/local/bin/geo ]];then
echo -n "Do you wish to uninstall geo [Y/n]: "
read -r answer
if [[ "$answer" == "Y" || "$answer" == "y" ]] ;then
cd geo || exit 1
./uninstall.sh
cd .. || exit 1
fi
fi
if [[ -f /usr/local/bin/cheat ]];then
echo -n "Do you wish to uninstall cheat [Y/n]: "
read -r answer
if [[ "$answer" == "Y" || "$answer" == "y" ]] ;then
cd cheat || exit 1
./uninstall.sh
cd .. || exit 1
fi
fi
if [[ -f /usr/local/bin/ytview ]];then
echo -n "Do you wish to uninstall ytview [Y/n]: "
read -r answer
if [[ "$answer" == "Y" || "$answer" == "y" ]] ;then
cd ytview || exit 1
./uninstall.sh
cd .. || exit 1
fi
fi
if [[ -f /usr/local/bin/cloudup ]];then
echo -n "Do you wish to uninstall cloudup [Y/n]: "
read -r answer
if [[ "$answer" == "Y" || "$answer" == "y" ]] ;then
cd cloudup || exit 1
./uninstall.sh
cd .. || exit 1
fi
fi
if [[ -f /usr/local/bin/qrify ]];then
echo -n "Do you wish to uninstall qrify [Y/n]: "
read -r answer
if [[ "$answer" == "Y" || "$answer" == "y" ]] ;then
cd qrify || exit 1
./uninstall.sh
cd .. || exit 1
fi
fi