forked from arno-iptables-firewall/aif
-
Notifications
You must be signed in to change notification settings - Fork 1
/
uninstall.sh
executable file
·146 lines (112 loc) · 3.92 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
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
#!/bin/bash
MY_VERSION="1.0f"
# ------------------------------------------------------------------------------------------
# -= Arno's Iptables Firewall(AIF) =-
# Single- & multi-homed firewall script with DSL/ADSL support
#
# ~ In memory of my dear parents ~
#
# (C) Copyright 2001-2020 by Arno van Amersfoort
# Web : https://github.com/arno-iptables-firewall/aif
# Email : a r n o DOT v a n DOT a m e r s f o o r t AT g m a i l DOT c o m
# (note: you must remove all spaces and substitute the @ and the .
# at the proper locations!)
# ------------------------------------------------------------------------------------------
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# ------------------------------------------------------------------------------------------
check_command()
{
local path IFS
IFS=' '
for cmd in $*; do
if [ -n "$(which "$cmd" 2>/dev/null)" ]; then
return 0
fi
done
return 1
}
sanity_check()
{
# root check
if [ "$(id -u)" != "0" ]; then
printf "\033[40m\033[1;31mERROR: Root check FAILED (you MUST be root to use this script)! Quitting...\033[0m\n" >&2
exit 1
fi
}
get_user_yn()
{
if [ "$2" = "y" ]; then
printf "$1 (Y/n)? "
else
printf "$1 (y/N)? "
fi
read answer_with_case
ANSWER=`echo "$answer_with_case" |tr A-Z a-z`
if [ "$ANSWER" = "y" -o "$ANSWER" = "yes" ]; then
return 0
fi
if [ "$ANSWER" = "n" -o "$ANSWER" = "no" ]; then
return 1
fi
# Fallback to default
if [ "$2" = "y" ]; then
return 0
else
return 1
fi
}
# main line:
AIF_VERSION="$(grep "MY_VERSION=" ./bin/arno-iptables-firewall |sed -e "s/^MY_VERSION=\"//" -e "s/\"$//")"
printf "\033[40m\033[1;32mArno's Iptables Firewall(AIF) v$AIF_VERSION\033[0m\n"
printf "Uninstall Script v$MY_VERSION\n"
echo "-------------------------------------------------------------------------------"
sanity_check
if ! get_user_yn "Continue uninstall" "n"; then
echo "*Uninstall aborted!"
exit 1
fi
rm -fv /usr/local/sbin/arno-iptables-firewall
rm -fv /usr/local/sbin/arno-fwfilter
rm -fv /usr/local/sbin/traffic-accounting-show
rm -fv /usr/local/bin/arno-fwfilter
rm -rfv /usr/local/share/arno-iptables-firewall
rm -fv /usr/local/share/man/man8/arno-iptables-firewall.8.gz
rm -fv /usr/local/share/man/man8/arno-fwfilter.1.gz
rm -fv /usr/local/share/doc/arno-iptables-firewall/README
rm -fv /etc/logrotate.d/arno-iptables-firewall
# Disable systemd
if check_command systemctl; then
systemctl disable arno-iptables-firewall
fi
# Disable via update-rc.d/chkconfig
if check_command update-rc.d; then
update-rc.d -f arno-iptables-firewall remove
elif check_command chkconfig; then
chkconfig --del arno-iptables-firewall
fi
# Remove init.d script
rm -fv /etc/init.d/arno-iptables-firewall
rm -fv /etc/rc.d/rc*.d/*arno-iptables-firewall
rm -fv /etc/rc*.d/*arno-iptables-firewall
# Remove systemd files
rm -fv /usr/lib/systemd/system/arno-iptables-firewall.service
rm -fv /lib/systemd/system/arno-iptables-firewall.service
rm -fv /etc/systemd/arno-iptables-firewall.service
if get_user_yn "Also remove ALL configuration files from /etc/arno-iptables-firewall/" "n"; then
rm -rfv /etc/arno-iptables-firewall
else
echo "* Skipped"
fi
echo ""
echo "** Uninstall done **"
echo ""
exit 0