-
Notifications
You must be signed in to change notification settings - Fork 0
/
uninstall.sh
executable file
·92 lines (80 loc) · 2.53 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
#!/bin/bash
if [[ $(id -u) != 0 ]]
then
echo "Please, run this script as root (using sudo for example)"
exit 1
fi
# for `rm` exclude !(xy)
shopt -s extglob
systemctl stop power_supply_mode_switcher
if [[ $? != 0 ]]
then
echo "power_supply_mode_switcher.service cannot be stopped correctly..."
exit 1
fi
systemctl disable power_supply_mode_switcher
if [[ $? != 0 ]]
then
echo "power_supply_mode_switcher.service cannot be disabled correctly..."
exit 1
fi
rm -f /lib/systemd/system/power_supply_mode_switcher.service
if [[ $? != 0 ]]
then
echo "/lib/systemd/system/power_supply_mode_switcher.service cannot be removed correctly..."
exit 1
fi
AC_MODE_FILE="/usr/share/power_supply_mode_switcher-driver/conf/ac_mode.sh"
BAT_MODE_FILE="/usr/share/power_supply_mode_switcher-driver/conf/bat_mode.sh"
AC_MODE_CONFIG_DIFF=""
if test -f "$AC_MODE_FILE"; then
AC_MODE_CONFIG_DIFF=$(diff <(grep -v '^#' conf/ac_mode.sh) <(grep -v '^#' $AC_MODE_FILE))
fi
BAT_MODE_CONFIG_DIFF=""
if test -f "$BAT_MODE_FILE"; then
BAT_MODE_CONFIG_DIFF=$(diff <(grep -v '^#' conf/bat_mode.sh) <(grep -v '^#' $BAT_MODE_FILE))
fi
if [ "$AC_MODE_CONFIG_DIFF" != "" ] || [ "$BAT_MODE_CONFIG_DIFF" != "" ]
then
read -r -p "Installed config scripts contain modifications compared to the default ones. Do you want remove them for each mode [y/N]" response
case "$response" in [yY][eE][sS]|[yY])
rm -rf /usr/share/power_supply_mode_switcher-driver/
if [[ $? != 0 ]]
then
echo "/usr/share/power_supply_mode_switcher-driver/ cannot be removed correctly..."
exit 1
fi
;;
*)
rm -rf "/usr/share/power_supply_mode_switcher-driver/"!(conf)
if [[ $? != 0 ]]
then
echo "/usr/share/power_supply_mode_switcher-driver/ cannot be removed correctly..."
exit 1
fi
echo "Config scripts in /usr/share/power_supply_mode_switcher-driver/conf/* have not been removed and remain in system:"
ls /usr/share/power_supply_mode_switcher-driver/conf
;;
esac
else
rm -rf /usr/share/power_supply_mode_switcher-driver/
if [[ $? != 0 ]]
then
echo "/usr/share/power_supply_mode_switcher-driver/ cannot be removed correctly..."
exit 1
fi
fi
rm -rf /var/log/power_supply_mode_switcher-driver
if [[ $? != 0 ]]
then
echo "/var/log/power_supply_mode_switcher-driver cannot be removed correctly..."
exit 1
fi
rm -f /usr/lib/udev/rules.d/80-power-supply-mode-switcher.rules
if [[ $? != 0 ]]
then
echo "/usr/lib/udev/rules.d/80-power-supply-mode-switcher.rules cannot be removed correctly..."
exit 1
fi
echo "Power supply mode switcher driver uninstalled"
exit 0