-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Uninstall
executable file
·152 lines (145 loc) · 3.99 KB
/
Uninstall
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#!/bin/bash
#
# shellcheck disable=SC2001,SC2181
PKGS="neomutt cmatrix figlet lolcat mplayer neomutt newsboat ranger tmux w3m asciinema speedtest-cli neofetch imagemagick gnupg"
PYMS="asciimatics ddgr durdraw socli future xtermcolor ffmpeg-python pyaudio term-image"
ALL=
[ "$1" == "all" ] && ALL=1
export PATH=${PATH}:/usr/local/bin:/snap/bin
plat=$(uname -s)
if [ "$plat" == "Darwin" ]; then
sudo pkg/Uninstall-bin.sh "$1"
else
debian=
have_apt=$(type -p apt)
have_dpkg=$(type -p dpkg)
have_rpm=$(type -p rpm)
have_dnf=$(type -p dnf)
have_pac=$(type -p pacman)
[ -f /etc/os-release ] && . /etc/os-release
[ "${ID}" == "debian" ] || [ "${ID_LIKE}" == "debian" ] && debian=1
[ "${ID}" == "arch" ] || [ "${ID_LIKE}" == "arch" ] && arch=1
[ "${debian}" ] || [ -f /etc/debian_version ] && debian=1
[ "${arch}" ] || [ "${debian}" ] || {
echo "${ID_LIKE}" | grep debian >/dev/null && debian=1
}
ASCPKG=asciiville
[ "${debian}" ] || [ "${arch}" ] || ASCPKG=Asciiville
if [ "${debian}" ]; then
if [ "${have_apt}" ]; then
sudo apt remove "${ASCPKG}" -y
else
if [ "${have_dpkg}" ]; then
sudo dpkg -r "${ASCPKG}"
else
echo "Cannot locate apt or dpkg to remove. Skipping."
fi
fi
else
if [ "${arch}" ]; then
if [ "${have_pac}" ]; then
sudo pacman -Rs "${ASCPKG}"
else
echo "Cannot locate pacman to remove. Skipping."
fi
else
if [ "${have_dnf}" ]; then
sudo dnf remove "${ASCPKG}"
else
if [ "${have_rpm}" ]; then
sudo rpm -e "${ASCPKG}"
else
echo "Cannot locate either dnf or rpm to remove. Skipping."
fi
fi
fi
fi
sudo pkg/Uninstall-bin.sh "$1"
fi
[ "${ALL}" ] && {
echo "The 'all' argument indicates uninstall all Asciiville components."
echo "This will attempt to uninstall the following packages:"
echo ""
echo "${PKGS}"
echo ""
echo "And the following Python modules:"
echo ""
echo "${PYMS}"
echo ""
echo "Note that this may remove packages installed prior to Asciiville."
echo "You may have to re-install those packages."
echo ""
echo "Do you wish to proceed with removal of these modules and packages?"
while true; do
read -r -p "Uninstall Asciiville components ? (y/n) " yn
case $yn in
[Yy]*)
break
;;
[Nn]*)
exit 0
;;
*)
echo "Please answer yes or no."
;;
esac
done
if [ "$plat" == "Darwin" ]; then
have_brew=$(type -p brew)
if [ "${have_brew}" ]; then
PKGS="btop ${PKGS}"
for pkg in ${PKGS}; do
brew list -q "${pkg}" >/dev/null 2>&1
[ $? -eq 0 ] && brew uninstall -q "${pkg}"
done
else
echo "Brew not found. Asciiville components not removed."
fi
else
if [ "${debian}" ]; then
if [ "${have_apt}" ]; then
sudo apt remove "${PKGS}" -y
else
if [ "${have_dpkg}" ]; then
sudo dpkg -r "${PKGS}"
else
echo "Cannot locate apt or dpkg to remove. Skipping."
fi
fi
else
if [ "${arch}" ]; then
if [ "${have_pac}" ]; then
sudo pacman -Rs "${PKGS}"
else
echo "Cannot locate pacman to remove. Skipping."
fi
else
if [ "${have_dnf}" ]; then
sudo dnf remove "${PKGS}"
else
if [ "${have_rpm}" ]; then
sudo rpm -e "${PKGS}"
else
echo "Cannot locate either dnf or rpm to remove. Skipping."
fi
fi
fi
fi
fi
VENV_DIR="${HOME}/.venv"
[ -f ${VENV_DIR}/bin/activate ] && source ${VENV_DIR}/bin/activate
python3_inst=$(type -p python3)
if [ "${python3_inst}" ]; then
PYTHON="python3"
else
PYTHON="python"
fi
for mod in ${PYMS}; do
${PYTHON} -m pip list 2>/dev/null | grep "${mod}" >/dev/null && {
${PYTHON} -m pip uninstall "${mod}" -y 2>/dev/null
}
done
rm -rf ~/.local/share/durdraw
rm -f ~/.local/bin/durdraw
rm -f ~/.local/share/man/man1/durdraw.1
}