Optimizing install and uninstall script

This commit is contained in:
Alex Epstein 2017-07-07 00:18:07 -04:00
parent 8bf97b8382
commit 79272a58e7
2 changed files with 36 additions and 127 deletions

View File

@ -1,6 +1,7 @@
#!/bin/bash
# Author: Alexander Epstein https://github.com/alexanderepstein
currentVersion="1.10.1"
declare -a tools=(currency stocks weather crypt movies taste short geo cheat ytview cloudup qrify)
askInstall()
{
@ -8,6 +9,7 @@ askInstall()
read -r answer
if [[ "$answer" == "Y" || "$answer" == "y" ]] ;then
cd $1 || return 1
chmod a+x install.sh || return 1
./install.sh || return 1
cd .. || return 1
fi
@ -16,129 +18,42 @@ askInstall()
updateTool()
{
if [[ -f /usr/local/bin/$1 ]];then
cd $1 || exit 1
./install.sh || exit 1
cd .. || exit 1
cd $1 || return 1
chmod a+x install.sh || return 1
./install.sh || return 1
cd .. || return 1
fi
}
singleInstall()
{
cd $1 || exit 1
chmod a+x install.sh || return 1
./install.sh || exit 1
cd .. || exit 1
}
if [[ $# == 0 ]]; then
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
if [[ $1 == "currency" ]];then
cd currency || exit 1
./install.sh || exit 1
cd .. || exit 1
elif [[ $1 == "stocks" ]]; then
cd stocks || exit 1
./install.sh || exit 1
cd .. || exit 1
elif [[ $1 == "weather" ]]; then
cd weather || exit 1
./install.sh || exit 1
cd .. || exit 1
elif [[ $1 == "crypt" ]]; then
cd crypt || exit 1
./install.sh || exit 1
cd .. || exit 1
elif [[ $1 == "movies" ]]; then
cd movies || exit 1
./install.sh || exit 1
cd .. || exit 1
elif [[ $1 == "taste" ]]; then
cd taste || exit 1
./install.sh || exit 1
cd .. || exit 1
elif [[ $1 == "short" ]]; then
cd short || exit 1
./install.sh || exit 1
cd .. || exit 1
elif [[ $1 == "geo" ]]; then
cd geo || exit 1
./install.sh || exit 1
cd .. || exit 1
elif [[ $1 == "cheat" ]]; then
cd cheat || exit 1
./install.sh || exit 1
cd .. || exit 1
elif [[ $1 == "ytview" ]]; then
cd ytview || exit 1
./install.sh || exit 1
cd .. || exit 1
elif [[ $1 == "cloudup" ]]; then
cd cloudup || exit 1
./install.sh || exit 1
cd .. || exit 1
elif [[ $1 == "qrify" ]]; then
cd qrify || exit 1
./install.sh || exit 1
cd .. || exit 1
elif [[ $1 == "all" ]];then
cd currency || exit 1
./install.sh || exit 1
cd .. || exit 1
cd stocks || exit 1
./install.sh || exit 1
cd .. || exit 1
cd weather || exit 1
./install.sh || exit 1
cd .. || exit 1
cd crypt || exit 1
./install.sh || exit 1
cd .. || exit 1
cd movies || exit 1
./install.sh || exit 1
cd .. || exit 1
cd taste || exit 1
./install.sh || exit 1
cd .. || exit 1
cd short || exit 1
./install.sh || exit 1
cd .. || exit 1
cd geo || exit 1
./install.sh || exit 1
cd .. || exit 1
cd cheat || exit 1
./install.sh || exit 1
cd .. || exit 1
cd ytview || exit 1
./install.sh || exit 1
cd .. || exit 1
cd cloudup || exit 1
./install.sh || exit 1
cd .. || exit 1
cd qrify || exit 1
./install.sh || exit 1
cd .. || exit 1
for tool in "${tools[@]}"
do
askInstall $tool || exit 1
done
elif [[ $1 == "update" ]]; then
echo "Updating scripts..."
updateTool currency
updateTool stocks
updateTool weather
updateTool crypt
updateTool movies
updateTool taste
updateTool short
updateTool geo
updateTool cheat
updateTool ytview
updateTool cloudup
updateTool qrify
for tool in "${tools[@]}"
do
updateTool $tool || exit 1
done
elif [[ $1 == "all" ]];then
for tool in "${tools[@]}"
do
singleInstall $tool || exit 1
done
else
singleInstall $1 || exit 1
fi
echo -n "( •_•)"
sleep .75
echo -n -e "\r( •_•)>⌐■-■"

View File

@ -1,5 +1,6 @@
#!/bin/bash
# Author: Alexander Epstein https://github.com/alexanderepstein
declare -a tools=(currency stocks weather crypt movies taste short geo cheat ytview cloudup qrify)
askUninstall()
{
@ -8,6 +9,7 @@ askUninstall()
read -r answer
if [[ "$answer" == "Y" || "$answer" == "y" ]] ;then
cd $1 || return 1
chmod a+x uninstall.sh || return 1
./uninstall.sh || return 1
cd .. || return 1
fi
@ -16,15 +18,7 @@ askUninstall()
}
askUninstall currency || exit 1
askUninstall stocks || exit 1
askUninstall weather || exit 1
askUninstall crypt || exit 1
askUninstall movies || exit 1
askUninstall taste || exit 1
askUninstall short || exit 1
askUninstall geo || exit 1
askUninstall cheat || exit 1
askUninstall ytview || exit 1
askUninstall cloudup || exit 1
askUninstall qrify || exit 1
for tool in "${tools[@]}"
do
askUninstall $tool || exit 1
done