2
0
Fork 0
mirror of https://github.com/alexanderepstein/Bash-Snippets synced 2018-11-08 02:59:35 +01:00
Bash-Snippets/uninstall.sh
2017-08-03 09:40:43 -04:00

49 lines
1.5 KiB
Bash
Executable file

#!/usr/bin/env bash
# Author: Alexander Epstein https://github.com/alexanderepstein
declare -a tools=(cheat cloudup crypt cryptocurrency currency geo movies newton qrify short siteciphers stocks taste todo transfer weather ytview)
all="1"
askUninstall()
{
if [[ -f /usr/local/bin/$1 ]]; then
echo -n "Do you wish to uninstall $1 [Y/n]: "
read -r answer
if [[ "$answer" == [Yy] ]]; then
echo -n "Removing $1: "
rm -f /usr/local/bin/$1 > /dev/null 2>&1 || { echo "Failed" ; echo "Error removing file, try running uninstall script as sudo"; exit 1; }
echo "Success"
else
all="0"
fi
unset answer
fi
}
removeTool()
{
if [[ -f /usr/local/bin/$1 ]]; then
echo -n "Removing $1: "
rm -f /usr/local/bin/$1 > /dev/null 2>&1 || { echo "Failed" ; echo "Error removing file, try running uninstall script as sudo"; exit 1; }
echo "Success"
fi
}
removeManpage()
{
if [ -f "/usr/local/man/man1/bash-snippets.1" ]; then rm -f "usr/local/man/man1/bash-snippets.1" || { echo "Error removing manpage, try running uninstall script as sudo"; exit 1; } ; fi
if [ -f "/usr/local/share/man/man1/bash-snippets.1" ]; then rm -f "/usr/local/share/man/man1/bash-snippets.1" || { echo "Error removing manpage, try running uninstall script as sudo"; exit 1; } ; fi
}
if [[ $1 != "all" ]];then
for tool in "${tools[@]}"; do
askUninstall $tool || exit 1
done
else
for tool in "${tools[@]}"; do
removeTool $tool || exit 1
done
fi
if [[ $all == "1" ]]; then
removeManpage || exit 1
fi