-
Notifications
You must be signed in to change notification settings - Fork 7
/
uninstall.sh
executable file
·108 lines (95 loc) · 2.91 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
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
#!/bin/bash
install_location=/usr/local/bin
config_location=~/.config
autostart_location=~/.config/autostart
# detect distro
if [ -f /etc/os-release ]; then
. /etc/os-release
OS=$NAME
VER=$VERSION_ID
elif type lsb_release >/dev/null 2>&1; then
OS=$(lsb_release -si)
VER=$(lsb_release -sr)
elif [ -f /etc/lsb-release ]; then
. /etc/lsb-release
OS=$DISTRIB_ID
VER=$DISTRIB_RELEASE
elif [ -f /etc/debian_version ]; then
OS=Debian
VER=$(cat /etc/debian_version)
else
...
fi
# uninstall requirements
case $OS in
openSUSE*)
pkgM=zypper;;
Debain*)
pkgM=apt-get;;
Ubuntu*)
pkgM=apt-get;;
Fedora*)
pkgM=dnf;;
CentOS*)
pkgM=yum;;
*)
pkgM=$( command -v pamac || command -v pacman ) || echo "package manager not found"
esac
case ${pkgM} in
*pacman)
uninstall=-R
auto=--noconfirm
;;
*pamac)
uninstall=remove
auto=--no-confirm
;;
*)
uninstall=remove
auto=-y
;;
esac
# filter package list by distro
# ATTENTION: needs further work, currently only openSUSE and non-openSUSE.
case $OS in
openSUSE*)
cat ./pkg_requirements | grep openSUSE | awk '{ print $1 }' > PKG_REQ_LIST;;
*)
cat ./pkg_requirements | grep ALL | awk '{ print $1 }' > PKG_REQ_LIST;;
esac
## subprocess, shlex, threading, queue, time, os, sys, math are builtin
## uninstalls on global python
echo "Uninstalling $(sed -n -e 'H;${x;s/\n/, /g;s/^,[ ]//;p;}' py_requirements)."
xargs -d"\n" -n 1 -I{} -ra <( cat py_requirements ) sh -c "echo; echo Uninstalling {} through pip; sudo pip3 uninstall {};"
## cat, stdbuf are builtin, may need to install daemonize by hand
echo "Uninstalling $(sed -n -e 'H;${x;s/\n/, /g;s/^,[ ]//;p;}' PKG_REQ_LIST)."
xargs -d"\n" -n 1 -I{} -ra <( cat PKG_REQ_LIST ) sh -c "echo; echo Uninstalling {}; sudo ${pkgM} ${uninstall} {}"
# remove user from input group
while true; do
echo "Remove input group? Other tools may depend on it."
read -p "(y/n):" choice
case "$choice" in
y|Y ) sudo gpasswd -d $USER input; break;;
n|N ) break;;
* ) echo "Please answer y or n.";;
esac
done
# remove placed files
echo "Removing placed files gestures, getConfig.py, $(ls -m utilities) from ${install_location}."
sudo rm -i ${install_location}/gestures
sudo rm -i ${install_location}/getConfig.py
xargs -I {} -d"\n" -n 1 -ra <( ls utilities ) sudo rm -i ${install_location}/{}
## remove config file
while true; do
echo "Remove configuration file (~/.config/gesture.conf)? Warning: will need to rewrite to get back."
read -p "(y/n):" choice
case "$choice" in
y|Y ) echo "Removing config file."; rm -i ${config_location}/gestures.conf; break;;
n|N ) echo "Skipping Removal of config file."; break;;
* ) echo "Please answer y or n.";;
esac
done
echo "Removing from auto start."
rm -i ${autostart_location}/gestures.desktop
# clearup
rm ./PKG_REQ_LIST