-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuninstaller.sh
48 lines (39 loc) · 1.36 KB
/
uninstaller.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
#####
### REFERENCE: https://askubuntu.com/questions/1103860/script-to-check-if-some-program-is-already-installed
#####
#!/bin/bash
# set up file name
input="requirements.txt"
# for each requirement in the file
while IFS= read -r line; do
# trim trailing whitespace
requirements="${line}"
# check if package exists and store in variable
dpkg -s $requirements &> /dev/null
# read from variable
if [ $? -ne 0 ]
then
# do nothing
echo "The package '$requirements' is not installed."
else
# uninstall flow
echo "The package '$requirements' is installed. Attempting to uninstall..."
# npm-specific packages
if [ $requirements == "fullcalendar" ] || [ $requirements == "jquery" ] || [ $requirements == "eslint" ]
then
npm uninstall $requirements
# pip-specific packages
elif [ $requirements == "pylint" ]
then
pip uninstall $requirements -y
# nginx-specific flow
elif [ $requirements == "nginx" ]
then
sudo apt remove $requirements nginx-common -y
# normal uninstall flow
else
sudo apt remove $requirements -y
fi
sudo apt autoremove -y
fi
done < "$input"