Line 1... |
Line 1... |
1 |
|
1 |
|
2 |
#!/bin/bash
|
2 |
#!/bin/bash
|
3 |
# $Id: alcasar-uninstall.sh 2192 2017-05-01 19:52:53Z richard $
|
3 |
# $Id: alcasar-uninstall.sh 2206 2017-05-06 17:58:56Z richard $
|
4 |
|
4 |
|
5 |
# alcasar-uninstall.sh
|
5 |
# alcasar-uninstall.sh
|
6 |
# by Franck BOUIJOUX, Pascal LEVANT and Richard REY
|
6 |
# by Franck BOUIJOUX, Pascal LEVANT and Richard REY
|
7 |
# This script is distributed under the Gnu General Public License (GPL)
|
7 |
# This script is distributed under the Gnu General Public License (GPL)
|
8 |
|
8 |
|
9 |
# Désisntallation d'ALCASAR
|
9 |
# Désisntallation ou mise à jour d'ALCASAR
|
10 |
# Uninstall ALCASAR
|
10 |
# Uninstall or update ALCASAR
|
11 |
|
11 |
|
- |
|
12 |
usage="Usage: alcasar-uninstall.sh {-update or --update} | {-full or --full}"
|
12 |
SED="/bin/sed -i"
|
13 |
SED="/bin/sed -i"
|
- |
|
14 |
|
- |
|
15 |
nb_args=$#
|
- |
|
16 |
args=$1
|
- |
|
17 |
if [ $nb_args -eq 0 ]
|
- |
|
18 |
then
|
- |
|
19 |
nb_args=1
|
- |
|
20 |
args="-h"
|
- |
|
21 |
fi
|
- |
|
22 |
case $args in
|
- |
|
23 |
-\? | -h* | --h*)
|
- |
|
24 |
echo "$usage"
|
- |
|
25 |
exit 0
|
- |
|
26 |
;;
|
- |
|
27 |
--update | -update)
|
- |
|
28 |
mode="update"
|
- |
|
29 |
;;
|
- |
|
30 |
--full | -full)
|
- |
|
31 |
mode="full"
|
- |
|
32 |
;;
|
- |
|
33 |
*)
|
- |
|
34 |
echo "Argument inconnu :$1";
|
- |
|
35 |
echo "$usage"
|
- |
|
36 |
exit 1
|
- |
|
37 |
;;
|
- |
|
38 |
esac
|
- |
|
39 |
|
13 |
clear
|
40 |
clear
|
- |
|
41 |
if [ $mode == "full" ]
|
- |
|
42 |
then
|
14 |
echo "-----------------------------------------------------------------------------"
|
43 |
echo "----------------------------------------------------------------------------"
|
15 |
echo "** Uninstall/Update ALCASAR **"
|
44 |
echo "** Uninstall/Désinstallation d'ALCASAR **"
|
16 |
echo "-----------------------------------------------------------------------------"
|
45 |
echo "----------------------------------------------------------------------------"
|
- |
|
46 |
services="alcasar-load_balancing vnstat havp freshclam ntpd httpd radiusd mysqld dnsmasq-blacklist dnsmasq-whitelist dnsmasq-blackhole tinyproxy nfsen fail2ban iptables ulogd-ext-access ulogd-ssh ulogd-traceability dansguardian dnsmasq sshd chilli"
|
- |
|
47 |
/usr/local/bin/alcasar-logout.sh all # logout everybody
|
17 |
echo
|
48 |
else
|
- |
|
49 |
echo "----------------------------------------------------------------------------"
|
- |
|
50 |
echo "** update/mise à jour d'ALCASAR **"
|
- |
|
51 |
echo "----------------------------------------------------------------------------"
|
- |
|
52 |
# dnsmasq & sshd should stay on to allow remote update
|
- |
|
53 |
services="alcasar-load_balancing vnstat havp freshclam ntpd httpd radiusd mysqld dnsmasq-blacklist dnsmasq-whitelist dnsmasq-blackhole tinyproxy nfsen fail2ban iptables ulogd-ext-access ulogd-ssh ulogd-traceability dansguardian chilli"
|
18 |
/usr/local/bin/alcasar-logout.sh all
|
54 |
/usr/local/bin/alcasar-bypass.sh -on # to allow remote update
|
19 |
# services_stop
|
55 |
fi
|
20 |
echo "Stopping service : "
|
56 |
echo "Stopping service : "
|
21 |
/usr/local/bin/alcasar-sms.sh --stop
|
57 |
/usr/local/bin/alcasar-sms.sh --stop
|
22 |
for i in alcasar-load_balancing vnstat havp freshclam ntpd httpd radiusd mysqld dnsmasq-blacklist dnsmasq-whitelist dnsmasq-blackhole tinyproxy nfsen fail2ban iptables ulogd-ext-access ulogd-ssh ulogd-traceability dansguardian dnsmasq sshd chilli
|
- |
|
- |
|
58 |
for i in $services
|
23 |
do
|
59 |
do
|
24 |
if [ -e /lib/systemd/system/$i.service ]
|
60 |
if [ -e /lib/systemd/system/$i.service ]
|
25 |
then
|
61 |
then
|
26 |
/usr/bin/systemctl disable $i.service
|
62 |
/usr/bin/systemctl disable $i.service
|
27 |
/usr/bin/systemctl stop $i.service 1>/dev/null
|
63 |
/usr/bin/systemctl stop $i.service 1>/dev/null
|
Line 29... |
Line 65... |
29 |
else
|
65 |
else
|
30 |
echo "The service $i.service doesn't exist !"
|
66 |
echo "The service $i.service doesn't exist !"
|
31 |
fi
|
67 |
fi
|
32 |
done
|
68 |
done
|
33 |
echo "Check the service clearing"
|
69 |
echo "Check the service clearing"
|
34 |
for i in alcasar-load_balancing vnstat havp freshclam ntpd httpd radiusd mysqld dnsmasq-blacklist dnsmasq-whitelist dnsmasq-blackhole tinyproxy nfsen fail2ban iptables ulogd-ext-access ulogd-ssh ulogd-traceability dansguardian dnsmasq sshd chilli
|
- |
|
- |
|
70 |
for i in $services
|
35 |
do
|
71 |
do
|
36 |
if [ `systemctl is-active $i.service` == "active" ]
|
72 |
if [ `systemctl is-active $i.service` == "active" ]
|
37 |
then
|
73 |
then
|
38 |
echo "The service '$i' need to be killed"
|
74 |
echo "The service '$i' need to be killed"
|
39 |
/usr/bin/systemctl stop $i.service
|
75 |
/usr/bin/systemctl stop $i.service
|
40 |
killall $i
|
76 |
killall $i
|
41 |
fi
|
77 |
fi
|
42 |
done
|
78 |
done
|
43 |
echo "Reset ALCASAR main functions : "
|
79 |
echo "Reset ALCASAR main functions : "
|
44 |
echo -en "\n- init(1) : "
|
80 |
echo -en "\n- init(1) : "
|
45 |
# les fichiers situés dans /usr/local/ seront supprimés à la fin car encore utiles ici
|
81 |
# The files in /usr/local/ will be removed at the end (usefull here)
|
46 |
rm -f /root/ALCASAR* && echo -n "1"
|
82 |
rm -f /root/ALCASAR* && echo -n "1"
|
47 |
sleep 1
|
83 |
sleep 1
|
48 |
|
84 |
|
49 |
echo -en "\n- ACC(11) : "
|
85 |
echo -en "\n- ACC(11) : "
|
50 |
[ -d /var/www/html ] && rm -rf /var/www/html && echo -n "1, "
|
86 |
[ -d /var/www/html ] && rm -rf /var/www/html && echo -n "1, "
|
Line 109... |
Line 145... |
109 |
[ -e /etc/dansguardian/lists/bannedsitelist.default ] && mv /etc/dansguardian/lists/bannedsitelist.default /etc/dansguardian/lists/bannedsitelist && echo -n "8"
|
145 |
[ -e /etc/dansguardian/lists/bannedsitelist.default ] && mv /etc/dansguardian/lists/bannedsitelist.default /etc/dansguardian/lists/bannedsitelist && echo -n "8"
|
110 |
sleep 1
|
146 |
sleep 1
|
111 |
|
147 |
|
112 |
echo -en "\n- antivirus(5) : "
|
148 |
echo -en "\n- antivirus(5) : "
|
113 |
if [ -e /etc/init.d/havp ]
|
149 |
if [ -e /etc/init.d/havp ]
|
114 |
then
|
150 |
then
|
115 |
[ -e /etc/havp/havp.config.default ] && mv /etc/havp/havp.config.default /etc/havp/havp.config && echo -n "1, "
|
151 |
[ -e /etc/havp/havp.config.default ] && mv /etc/havp/havp.config.default /etc/havp/havp.config && echo -n "1, "
|
116 |
userdel -r havp 2>/dev/null && echo -n "2, "
|
152 |
userdel -r havp 2>/dev/null && echo -n "2, "
|
117 |
[ `grep havp /etc/fstab|wc -l` -ne "0" ] && $SED "/havp/d" /etc/fstab # anciennes versions (mémoire tampon sur disque)
|
- |
|
118 |
[ -e /etc/init.d/havp.default ] && mv /etc/init.d/havp.default /etc/init.d/havp && echo -n "3, "
|
153 |
[ -e /etc/init.d/havp.default ] && mv /etc/init.d/havp.default /etc/init.d/havp && echo -n "3, "
|
119 |
[ -e /lib/systemd/system/havp.service.default ] && mv /lib/systemd/system/havp.service.default /lib/systemd/system/havp.service && echo -n "4, "
|
154 |
[ -e /lib/systemd/system/havp.service.default ] && mv /lib/systemd/system/havp.service.default /lib/systemd/system/havp.service && echo -n "4, "
|
120 |
[ -e /etc/freshclam.conf.default ] && mv /etc/freshclam.conf.default /etc/freshclam.conf && echo -n "5"
|
155 |
[ -e /etc/freshclam.conf.default ] && mv /etc/freshclam.conf.default /etc/freshclam.conf && echo -n "5"
|
121 |
else echo -n "uninstalled"
|
156 |
else echo -n "uninstalled"
|
122 |
fi
|
157 |
fi
|
123 |
sleep 1
|
158 |
sleep 1
|
124 |
|
159 |
|
125 |
echo -en "\n- tinyproxy(2) : "
|
160 |
echo -en "\n- tinyproxy(2) : "
|
126 |
if [ -e /etc/init.d/tinyproxy ]
|
161 |
if [ -e /etc/init.d/tinyproxy ]
|
127 |
then
|
162 |
then
|
128 |
[ -e /etc/tinyproxy/tinyproxy.conf.default ] && mv /etc/tinyproxy/tinyproxy.conf.default /etc/tinyproxy/tinyproxy.conf && echo -n "1, "
|
163 |
[ -e /etc/tinyproxy/tinyproxy.conf.default ] && mv /etc/tinyproxy/tinyproxy.conf.default /etc/tinyproxy/tinyproxy.conf && echo -n "1, "
|
129 |
userdel -r tinyproxy 2>/dev/null && echo -n "2"
|
164 |
userdel -r tinyproxy 2>/dev/null && echo -n "2"
|
130 |
else echo -n "uninstalled"
|
165 |
else echo -n "uninstalled"
|
131 |
fi
|
166 |
fi
|
132 |
sleep 1
|
167 |
sleep 1
|
133 |
|
168 |
|
134 |
echo -en "\n- ulogd(6) : "
|
169 |
echo -en "\n- ulogd(6) : "
|
135 |
i=0
|
170 |
i=0
|
136 |
for log_type in traceability ssh ext-access
|
171 |
for log_type in traceability ssh ext-access
|
137 |
do
|
172 |
do
|
138 |
i=`expr $i + 1`
|
173 |
i=`expr $i + 1`
|
139 |
[ -e /etc/ulogd-$log_type.conf ] && rm -f /etc/ulogd-$log_type.conf && echo -n "$i, "
|
174 |
[ -e /etc/ulogd-$log_type.conf ] && rm -f /etc/ulogd-$log_type.conf && echo -n "$i, "
|
140 |
i=`expr $i + 1`
|
175 |
i=`expr $i + 1`
|
141 |
[ -e /lib/systemd/system/ulogd-$log_type.service ] && rm -f /lib/systemd/system/ulogd-$log_type.service && echo -n "$i, "
|
176 |
[ -e /lib/systemd/system/ulogd-$log_type.service ] && rm -f /lib/systemd/system/ulogd-$log_type.service && echo -n "$i, "
|
142 |
done
|
177 |
done
|
143 |
sleep 1
|
178 |
sleep 1
|
144 |
|
179 |
|
145 |
echo -en "\n- nfsen(1) : "
|
180 |
echo -en "\n- nfsen(1) : "
|
146 |
[ -e /lib/systemd/system/nfsen.service ] && rm -f /lib/systemd/system/nfsen.service && echo -n "1"
|
181 |
[ -e /lib/systemd/system/nfsen.service ] && rm -f /lib/systemd/system/nfsen.service && echo -n "1"
|
147 |
sleep 1
|
182 |
sleep 1
|
Line 169... |
Line 204... |
169 |
sleep 1
|
204 |
sleep 1
|
170 |
|
205 |
|
171 |
echo -en "\n- BL(0) : "
|
206 |
echo -en "\n- BL(0) : "
|
172 |
sleep 1
|
207 |
sleep 1
|
173 |
|
208 |
|
174 |
echo -en "\n- dhcp-server(1) : "
|
- |
|
175 |
if [ -e /etc/init.d/dhcpd ]
|
- |
|
176 |
then
|
- |
|
177 |
/usr/sbin/urpme --auto dhcp-server --auto-orphans && echo -n "1"
|
- |
|
178 |
else echo -n "uninstalled"
|
- |
|
179 |
fi
|
- |
|
180 |
sleep 1
|
- |
|
181 |
|
- |
|
182 |
echo -en "\n- fail2ban(8) : "
|
209 |
echo -en "\n- fail2ban(8) : "
|
183 |
[ -e /etc/fail2ban/fail2ban.conf.default ] && mv /etc/fail2ban/fail2ban.conf.default /etc/fail2ban/fail2ban.conf && echo -n "1, "
|
210 |
[ -e /etc/fail2ban/fail2ban.conf.default ] && mv /etc/fail2ban/fail2ban.conf.default /etc/fail2ban/fail2ban.conf && echo -n "1, "
|
184 |
[ -e /etc/fail2ban/jail.conf.default ] && mv /etc/fail2ban/jail.conf.default /etc/fail2ban/jail.conf && echo -n "2, "
|
211 |
[ -e /etc/fail2ban/jail.conf.default ] && mv /etc/fail2ban/jail.conf.default /etc/fail2ban/jail.conf && echo -n "2, "
|
185 |
[ -e /etc/fail2ban/action.d/iptables-allports.conf.default ] && mv /etc/fail2ban/action.d/iptables-allports.conf.default /etc/fail2ban/action.d/iptables-allports.conf && echo -n "3, "
|
212 |
[ -e /etc/fail2ban/action.d/iptables-allports.conf.default ] && mv /etc/fail2ban/action.d/iptables-allports.conf.default /etc/fail2ban/action.d/iptables-allports.conf && echo -n "3, "
|
186 |
[ -e /etc/fail2ban/filter.d/alcasar_mod-evasive.conf ] && rm /etc/fail2ban/filter.d/alcasar_mod-evasive.conf && echo -n "4, "
|
213 |
[ -e /etc/fail2ban/filter.d/alcasar_mod-evasive.conf ] && rm /etc/fail2ban/filter.d/alcasar_mod-evasive.conf && echo -n "4, "
|
Line 208... |
Line 235... |
208 |
[ -e /etc/gammu_smsd_conf ] && rm -f /etc/gammu_smsd_conf && echo -n "1, "
|
235 |
[ -e /etc/gammu_smsd_conf ] && rm -f /etc/gammu_smsd_conf && echo -n "1, "
|
209 |
[ -e /etc/udev/rules.d/66-huawei.rules ] && rm -f /etc/udev/rules.d/66-huawei.rules && echo -n "2, "
|
236 |
[ -e /etc/udev/rules.d/66-huawei.rules ] && rm -f /etc/udev/rules.d/66-huawei.rules && echo -n "2, "
|
210 |
[ -e /var/log/gammu-smsd ] && rm -rf /var/log/gammu-smsd && echo -n "3"
|
237 |
[ -e /var/log/gammu-smsd ] && rm -rf /var/log/gammu-smsd && echo -n "3"
|
211 |
sleep 1
|
238 |
sleep 1
|
212 |
|
239 |
|
- |
|
240 |
if [ mode == "full " ]
|
- |
|
241 |
then
|
213 |
echo -en "\n- network(9) : "
|
242 |
echo -en "\n- network(9) : "
|
214 |
hostname localhost
|
243 |
hostname localhost
|
215 |
CONF_FILE="/usr/local/etc/alcasar.conf"
|
244 |
CONF_FILE="/usr/local/etc/alcasar.conf"
|
216 |
EXTIF=`grep ^EXTIF= $CONF_FILE|cut -d"=" -f2` # EXTernal InterFace
|
245 |
EXTIF=`grep ^EXTIF= $CONF_FILE|cut -d"=" -f2` # EXTernal InterFace
|
217 |
INTIF=`grep ^INTIF= $CONF_FILE|cut -d"=" -f2` # INTernal InterFace
|
246 |
INTIF=`grep ^INTIF= $CONF_FILE|cut -d"=" -f2` # INTernal InterFace
|
218 |
i=0
|
247 |
i=0
|
219 |
for nic in $EXTIF $INTIF
|
248 |
for nic in $EXTIF $INTIF
|
220 |
do
|
249 |
do
|
221 |
i=`expr $i + 1`
|
250 |
i=`expr $i + 1`
|
222 |
/sbin/ifdown $nic
|
251 |
/sbin/ifdown $nic
|
223 |
[ -e /etc/sysconfig/network-scripts/default-ifcfg-$nic ] && mv -f /etc/sysconfig/network-scripts/default-ifcfg-$nic /etc/sysconfig/network-scripts/ifcfg-$nic && echo -n "$i, "
|
252 |
[ -e /etc/sysconfig/network-scripts/default-ifcfg-$nic ] && mv -f /etc/sysconfig/network-scripts/default-ifcfg-$nic /etc/sysconfig/network-scripts/ifcfg-$nic && echo -n "$i, "
|
224 |
done
|
253 |
done
|
225 |
[ -e /etc/sysconfig/network.default ] && mv /etc/sysconfig/network.default /etc/sysconfig/network && echo -n "3, "
|
254 |
[ -e /etc/sysconfig/network.default ] && mv /etc/sysconfig/network.default /etc/sysconfig/network && echo -n "3, "
|
226 |
[ -e /etc/hosts.default ] && mv /etc/hosts.default /etc/hosts && echo -n "4, "
|
255 |
[ -e /etc/hosts.default ] && mv /etc/hosts.default /etc/hosts && echo -n "4, "
|
227 |
[ -e /etc/hosts.allow.default ] && mv /etc/hosts.allow.default /etc/hosts.allow && echo -n "5, "
|
256 |
[ -e /etc/hosts.allow.default ] && mv /etc/hosts.allow.default /etc/hosts.allow && echo -n "5, "
|
228 |
[ -e /etc/hosts.deny.default ] && mv /etc/hosts.deny.default /etc/hosts.deny && echo -n "6, "
|
257 |
[ -e /etc/hosts.deny.default ] && mv /etc/hosts.deny.default /etc/hosts.deny && echo -n "6, "
|
229 |
[ -e /etc/modprobe.preload.default ] && mv /etc/modprobe.preload.default /etc/modprobe.preload && echo -n "7, "
|
258 |
[ -e /etc/modprobe.preload.default ] && mv /etc/modprobe.preload.default /etc/modprobe.preload && echo -n "7, "
|
230 |
[ -e /lib/systemd/system/iptables.service.default ] && mv /lib/systemd/system/iptables.service.default /lib/systemd/system/iptables.service && echo -n "8, "
|
259 |
[ -e /lib/systemd/system/iptables.service.default ] && mv /lib/systemd/system/iptables.service.default /lib/systemd/system/iptables.service && echo -n "8, "
|
231 |
[ -e /usr/libexec/iptables.init.default ] && mv /usr/libexec/iptables.init.default /usr/libexec/iptables.init && echo -n "9"
|
260 |
[ -e /usr/libexec/iptables.init.default ] && mv /usr/libexec/iptables.init.default /usr/libexec/iptables.init && echo -n "9"
|
232 |
|
- |
|
233 |
/sbin/ifup $EXTIF
|
261 |
/sbin/ifup $EXTIF
|
234 |
sleep 1
|
262 |
sleep 1
|
- |
|
263 |
fi
|
235 |
|
264 |
|
236 |
#post_install
|
265 |
#post_install
|
237 |
echo -en "\n- post_install(6) : "
|
266 |
echo -en "\n- post_install(6) : "
|
238 |
[ -e /etc/mageia-release.default ] && mv /etc/mageia-release.default /etc/mageia-release && echo -n "1, "
|
267 |
[ -e /etc/mageia-release.default ] && mv /etc/mageia-release.default /etc/mageia-release && echo -n "1, "
|
239 |
[ -e /etc/ssh/alcasar-banner-ssh ] && rm -f /etc/ssh/alcasar-banner-ssh && echo -n "2, "
|
268 |
[ -e /etc/ssh/alcasar-banner-ssh ] && rm -f /etc/ssh/alcasar-banner-ssh && echo -n "2, "
|
Line 244... |
Line 273... |
244 |
sleep 1
|
273 |
sleep 1
|
245 |
|
274 |
|
246 |
# nettoyage (on retire les services supprimés ou remplacés dans la nouvelle version)
|
275 |
# nettoyage (on retire les services supprimés ou remplacés dans la nouvelle version)
|
247 |
echo -en "\n- cleaning() : "
|
276 |
echo -en "\n- cleaning() : "
|
248 |
for rm_fic in /usr/local/bin /usr/local/etc /usr/local/sbin
|
277 |
for rm_fic in /usr/local/bin /usr/local/etc /usr/local/sbin
|
249 |
do
|
278 |
do
|
250 |
rm -rf $rm_fic/alcasar*
|
279 |
rm -rf $rm_fic/alcasar*
|
251 |
done
|
280 |
done
|
252 |
echo
|
281 |
echo
|
253 |
|
282 |
|