forked from alexanderepstein/Bash-Snippets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
uninstall.sh
executable file
·49 lines (44 loc) · 1.54 KB
/
uninstall.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env bash
# Author: Alexander Epstein https://github.com/alexanderepstein
declare -a tools=(bash-snippets cheat cloudup crypt cryptocurrency currency geo lyrics meme movies newton pwned 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