-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathremove
executable file
·110 lines (91 loc) · 2.91 KB
/
remove
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
#!/bin/bash
# shellcheck source=dynamic-wall/dynamicwall.config
if [[ $EUID = 0 ]]; then
echo "This script must be run without root"
exit 1
fi
usrnm=$(logname)
skiprm=false
if which dynamicwall; then
install_dir="$(dirname "$(readlink -f "$(which dynamicwall)")")"
else
echo "Error, can't locate dynamicwall installation. Cleaning up everything else."
skiprm=true
fi
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
cd "$DIR" || { echo "Error, exiting..."; exit 1; }
$skiprm || eval "$(grep "theme_dir" 2>/dev/null < "$install_dir/dynamicwall.config")"
if [[ -f /bin/systemctl ]]; then
echo -e "\n\033[0;33mDisabling dynamicwall systemd daemons...\033[0m"
systemctl --user stop dynamicwall.timer
systemctl --user disable dynamicwall.service dynamicwall.timer
fi
$skiprm || if crontab -u "$usrnm" -l | grep "$install_dir/dynamicwall"; then
echo -e "\033[0;33mRemoving cronjob...\033[0m"
crontab -u "$usrnm" -l | grep -v "$install_dir/dynamicwall" | crontab -u "$usrnm" -
fi
echo -e "\033[0;33mRemoving software links...\033[0m"
if sudo rm /usr/local/bin/dynamicwall 2> /dev/null
then
echo "Removed symlink /usr/local/bin/dynamicwall."
fi
sudo -k
echo
echo -e "\033[0;33mRemoving software files and directories...\033[0m"
function remove_file(){
if [[ -f $1 ]]; then
if rm -v -f $1
then
echo "removed file: $1"
fi
fi
}
function remove_dir(){
if [[ -d $1 ]]; then
if [[ "$2" = "ifempty" ]]; then
if rm -v -d $1 2> /dev/null
then
echo "removed empty directory: $1"
else
echo -e "\e[00;31m$1 contains files not included in default installation, skipping...\e[00m"
fi
else
if rm -v -rf $1
then
echo "removed directory: $1"
fi
fi
fi
}
remove_file "/lib/systemd/system-sleep/dynamicwall.sh"
remove_file "/usr/lib/systemd/system-sleep/dynamicwall.sh"
remove_file "/home/$usrnm/.config/systemd/user/dynamicwall.timer"
remove_file "/home/$usrnm/.config/systemd/user/dynamicwall.service"
remove_file "/home/$usrnm/.config/systemd/user/dynamicwall.timer.d/2-timer.conf"
remove_dir "/home/$usrnm/.config/systemd/user/dynamicwall.timer.d"
remove_dir "/home/$usrnm/.config/systemd/user" "ifempty"
remove_dir "/home/$usrnm/.config/systemd" "ifempty"
$skiprm || {
remove_file "$install_dir/README.md"
remove_file "$install_dir/remove"
remove_dir "$theme_dir/EarthView"
remove_dir "$theme_dir/mojave_dynamic"
remove_dir "$theme_dir/NewOrleans"
remove_dir "$theme_dir" "ifempty"
if [[ "$1" = "-s" ]]; then
remove_file "$install_dir/default.config"
remove_file "$install_dir/dynamicwall.config"
remove_file "$install_dir/dynamicwall"
remove_dir "$install_dir/.oldvar"
remove_dir "$install_dir" "ifempty"
else
remove_dir "$install_dir"
fi
remove_dir "$(dirname "$install_dir")" "ifempty"
}
echo ""
if [[ "$1" != "-s" ]]; then
echo -e "\e[00;32mDynamic-Wall has been removed.\e[00m"
else
echo -e "\e[00;32mBeginning installation...\e[00m"
fi