Subversion Repositories ALCASAR

Rev

Rev 3103 | Rev 3179 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 3103 Rev 3104
Line 1... Line 1...
1
#!/bin/bash
1
#!/bin/bash
2
# $Id: alcasar-uninstall.sh 3103 2022-12-30 23:45:23Z rexy $
2
# $Id: alcasar-uninstall.sh 3104 2022-12-31 09:56:17Z rexy $
3
 
3
 
4
# alcasar-uninstall.sh
4
# alcasar-uninstall.sh
5
# by Franck BOUIJOUX, Pascal LEVANT and Richard REY
5
# by Franck BOUIJOUX, Pascal LEVANT and Richard REY
6
# This script is distributed under the Gnu General Public License (GPL)
6
# This script is distributed under the Gnu General Public License (GPL)
7
 
7
 
8
# Désinstallation ou mise à jour d'ALCASAR (avec traitement des .rpmnew)
8
# Désinstallation ou mise à jour d'ALCASAR
9
# Uninstall or update ALCASAR (with .rpmnew handling)
9
# Uninstall or update ALCASAR
10
 
10
 
11
SED="/bin/sed -i"
11
SED="/bin/sed -i"
12
 
12
 
13
[ -z $DEBUG_ALCASAR ] && DEBUG_ALCASAR='off'
13
[ -z $DEBUG_ALCASAR ] && DEBUG_ALCASAR='off'
14
 
14
 
Line 16... Line 16...
16
{
16
{
17
	echo -en "(3) : "
17
	echo -en "(3) : "
18
	rm -f /root/ALCASAR* && echo -n "1, " # The files in /usr/local/ will be removed at the end (still usefull here)
18
	rm -f /root/ALCASAR* && echo -n "1, " # The files in /usr/local/ will be removed at the end (still usefull here)
19
	[ -e /boot/grub2/user.cfg ] && rm -f /boot/grub2/user.cfg && echo -n "2, "
19
	[ -e /boot/grub2/user.cfg ] && rm -f /boot/grub2/user.cfg && echo -n "2, "
20
	[ -e /root/grub.default ] && mv -f /root/grub.default /etc/grub.d/10_linux && echo -n "3"
20
	[ -e /root/grub.default ] && mv -f /root/grub.default /etc/grub.d/10_linux && echo -n "3"
21
	## mga7 --> mga8 : remove unused .rpmnew conf files (used .rpmnew files are moved in each functions) 
-
 
22
	[ -e /etc/shadow.rpmnew ] && rm -f /etc/shadow.rpmnew
-
 
23
	[ -e /etc/sysconfig/system.rpmnew ] && rm -f /etc/sysconfig/system.rpmnew
-
 
24
	[ -e /etc/rpm/macros.rpmnew ] && rm -f /etc/rpm/macros.rpmnew
-
 
25
	[ -e /etc/fstab.rpmnew ] && rm -f /etc/rpm/fstab.rpmnew
-
 
26
	[ -e /etc/shells.rpmnew ] && rm -f /etc/rpm/shells.rpmnew
-
 
27
	[ -e /etc/hosts.rpmnew ] && rm -f /etc/rpm/hosts.rpmnew
-
 
28
	[ -e /etc/systemd/journald.conf.rpmnew ] && rm -f /etc/systemd/journald.conf.rpmnew
-
 
29
}
21
}
30
 
22
 
31
ACC ()
23
ACC ()
32
{
24
{
33
	echo -en "(11) : "
25
	echo -en "(11) : "
34
	[ -d /var/www/html ] && rm -rf /var/www/html && echo -n "1, "
26
	[ -d /var/www/html ] && rm -rf /var/www/html && echo -n "1, "
35
	[ -d /etc/freeradius-web ] && rm -rf /etc/freeradius-web && echo -n "2, "
27
	[ -d /etc/freeradius-web ] && rm -rf /etc/freeradius-web && echo -n "2, "
36
	[ -e /etc/php.d/05_date.ini.default ] && mv -f /etc/php.d/05_date.ini.default /etc/php.d/05_date.ini && echo -n "3, "
28
	[ -e /etc/php.d/05_date.ini.default ] && mv -f /etc/php.d/05_date.ini.default /etc/php.d/05_date.ini && echo -n "3, "
37
	[ -e /etc/php.ini.rpmnew ] && mv -f /etc/php.ini.rpmnew /etc/php.ini.default
-
 
38
	[ -e /etc/php.ini.default ] && mv -f /etc/php.ini.default /etc/php.ini && echo -n "4, "
29
	[ -e /etc/php.ini.default ] && mv -f /etc/php.ini.default /etc/php.ini && echo -n "4, "
39
	[ -e /etc/lighttpd/lighttpd.conf.rpmnew ] && mv -f /etc/lighttpd/lighttpd.conf.rpmnew /etc/lighttpd/lighttpd.conf.default
-
 
40
	[ -e /etc/lighttpd/lighttpd.conf.default ] && mv -f /etc/lighttpd/lighttpd.conf.default /etc/lighttpd/lighttpd.conf && echo -n "5, "
30
	[ -e /etc/lighttpd/lighttpd.conf.default ] && mv -f /etc/lighttpd/lighttpd.conf.default /etc/lighttpd/lighttpd.conf && echo -n "5, "
41
	[ -e /etc/lighttpd/modules.conf.rpmnew ] && mv -f /etc/lighttpd/modules.conf.rpmnew /etc/lighttpd/modules.conf.default
-
 
42
	[ -e /etc/lighttpd/modules.conf.default ] && mv -f /etc/lighttpd/modules.conf.default /etc/lighttpd/modules.conf && echo -n "6, "
31
	[ -e /etc/lighttpd/modules.conf.default ] && mv -f /etc/lighttpd/modules.conf.default /etc/lighttpd/modules.conf && echo -n "6, "
43
	[ -e /etc/lighttpd/conf.d/fastcgi.conf.default ] && mv -f /etc/lighttpd/conf.d/fastcgi.conf.default /etc/lighttpd/conf.d/fastcgi.conf && echo -n "7, "
32
	[ -e /etc/lighttpd/conf.d/fastcgi.conf.default ] && mv -f /etc/lighttpd/conf.d/fastcgi.conf.default /etc/lighttpd/conf.d/fastcgi.conf && echo -n "7, "
44
	[ -e /etc/php-fpm.conf.default ] && mv -f /etc/php-fpm.conf.default /etc/php-fpm.conf && echo -n "8, "
33
	[ -e /etc/php-fpm.conf.default ] && mv -f /etc/php-fpm.conf.default /etc/php-fpm.conf && echo -n "8, "
45
	[ -d /etc/lighttpd/vhosts.d ] && rm -rf /etc/lighttpd/vhosts.d && echo -n "9, "
34
	[ -d /etc/lighttpd/vhosts.d ] && rm -rf /etc/lighttpd/vhosts.d && echo -n "9, "
46
	[ -d /usr/local/etc/digest ] && rm -rf /usr/local/etc/digest && echo -n "10, "
35
	[ -d /usr/local/etc/digest ] && rm -rf /usr/local/etc/digest && echo -n "10, "
Line 78... Line 67...
78
}
67
}
79
 
68
 
80
freeradius ()
69
freeradius ()
81
{
70
{
82
	echo -en "(22) : "
71
	echo -en "(22) : "
83
	[ -e /etc/raddb/certs/dh.rpmnew ] && rm /etc/raddb/certs/dh.rpmnew
-
 
84
	[ -e /etc/raddb/empty-radiusd-db.sql ] && rm /etc/raddb/empty-radiusd-db.sql && echo -n "1, "
72
	[ -e /etc/raddb/empty-radiusd-db.sql ] && rm /etc/raddb/empty-radiusd-db.sql && echo -n "1, "
85
	[ -e /etc/raddb/radiusd.conf.default ] && mv /etc/raddb/radiusd.conf.default /etc/raddb/radiusd.conf && echo -n "2, "
73
	[ -e /etc/raddb/radiusd.conf.default ] && mv /etc/raddb/radiusd.conf.default /etc/raddb/radiusd.conf && echo -n "2, "
86
	[ -e /etc/raddb/dictionary.default ] && mv /etc/raddb/dictionary.default /etc/raddb/dictionary && echo -n "3, "
74
	[ -e /etc/raddb/dictionary.default ] && mv /etc/raddb/dictionary.default /etc/raddb/dictionary && echo -n "3, "
87
	[ -e /etc/raddb/dictionary.alcasar ] && rm /etc/raddb/dictionary.alcasar && echo -n "4, "
75
	[ -e /etc/raddb/dictionary.alcasar ] && rm /etc/raddb/dictionary.alcasar && echo -n "4, "
88
	[ -e /etc/raddb/dictionary.coovachilli ] && rm /etc/raddb/dictionary.coovachilli && echo -n "5, "
76
	[ -e /etc/raddb/dictionary.coovachilli ] && rm /etc/raddb/dictionary.coovachilli && echo -n "5, "
Line 122... Line 110...
122
	[ -d /var/dansguardian ] && rm -rf /var/dansguardian
110
	[ -d /var/dansguardian ] && rm -rf /var/dansguardian
123
	if [ -e /etc/systemd/system/e2guardian.service ]; then
111
	if [ -e /etc/systemd/system/e2guardian.service ]; then
124
		rm -f /etc/systemd/system/e2guardian.service
112
		rm -f /etc/systemd/system/e2guardian.service
125
		echo -n "1, "
113
		echo -n "1, "
126
	fi
114
	fi
127
	[ -e /etc/e2guardian/e2guardian.conf.rpmnew ] && mv -f /etc/e2guardian/e2guardian.conf.rpmnew /etc/e2guardian/e2guardian.conf.default
-
 
128
	[ -e /etc/e2guardian/e2guardian.conf.default ] && mv /etc/e2guardian/e2guardian.conf.default /etc/e2guardian/e2guardian.conf && echo -n "2, "
115
	[ -e /etc/e2guardian/e2guardian.conf.default ] && mv /etc/e2guardian/e2guardian.conf.default /etc/e2guardian/e2guardian.conf && echo -n "2, "
129
	[ -e /etc/e2guardian/e2guardianf1.conf.rpmnew ] && mv -f /etc/e2guardian/e2guardianf1.conf.rpmnew /etc/e2guardian/e2guardianf1.conf.default
-
 
130
	[ -e /etc/e2guardian/e2guardianf1.conf.default ] && mv /etc/e2guardian/e2guardianf1.conf.default /etc/e2guardian/e2guardianf1.conf && echo -n "3, "
116
	[ -e /etc/e2guardian/e2guardianf1.conf.default ] && mv /etc/e2guardian/e2guardianf1.conf.default /etc/e2guardian/e2guardianf1.conf && echo -n "3, "
131
	[ -e /etc/e2guardian/e2guardianf2.conf ] && rm -f /etc/e2guardian/e2guardianf2.conf && echo -n "4, "
117
	[ -e /etc/e2guardian/e2guardianf2.conf ] && rm -f /etc/e2guardian/e2guardianf2.conf && echo -n "4, "
132
	[ -e /usr/share/e2guardian/languages/french/alcasar-e2g.html ] && rm /usr/share/e2guardian/languages/french/alcasar-e2g.html && echo -n "5, "
118
	[ -e /usr/share/e2guardian/languages/french/alcasar-e2g.html ] && rm /usr/share/e2guardian/languages/french/alcasar-e2g.html && echo -n "5, "
133
	[ -e /usr/share/e2guardian/languages/ukenglish/alcasar-e2g.html ] && rm /usr/share/e2guardian/languages/ukenglish/alcasar-e2g.html && echo -n "6, "
119
	[ -e /usr/share/e2guardian/languages/ukenglish/alcasar-e2g.html ] && rm /usr/share/e2guardian/languages/ukenglish/alcasar-e2g.html && echo -n "6, "
134
	[ -e /etc/e2guardian/lists/bannedphraselist.default ] && mv /etc/e2guardian/lists/bannedphraselist.default /etc/e2guardian/lists/bannedphraselist && echo -n "7, "
120
	[ -e /etc/e2guardian/lists/bannedphraselist.default ] && mv /etc/e2guardian/lists/bannedphraselist.default /etc/e2guardian/lists/bannedphraselist && echo -n "7, "
Line 137... Line 123...
137
	[ -e /etc/e2guardian/lists/exceptioniplist.default ] && mv /etc/e2guardian/lists/exceptioniplist.default /etc/e2guardian/lists/exceptioniplist && echo -n "10, "
123
	[ -e /etc/e2guardian/lists/exceptioniplist.default ] && mv /etc/e2guardian/lists/exceptioniplist.default /etc/e2guardian/lists/exceptioniplist && echo -n "10, "
138
	[ -e /etc/e2guardian/lists/greysitelist.default ] && mv /etc/e2guardian/lists/greysitelist.default /etc/e2guardian/lists/greysitelist && echo -n "11, "
124
	[ -e /etc/e2guardian/lists/greysitelist.default ] && mv /etc/e2guardian/lists/greysitelist.default /etc/e2guardian/lists/greysitelist && echo -n "11, "
139
	[ -e /etc/e2guardian/lists/bannedurllist.default ] && mv /etc/e2guardian/lists/bannedurllist.default /etc/e2guardian/lists/bannedurllist && echo -n "12, "
125
	[ -e /etc/e2guardian/lists/bannedurllist.default ] && mv /etc/e2guardian/lists/bannedurllist.default /etc/e2guardian/lists/bannedurllist && echo -n "12, "
140
	[ -e /etc/e2guardian/lists/exceptionsitelist.default ] && mv /etc/e2guardian/lists/exceptionsitelist.default /etc/e2guardian/lists/exceptionsitelist && echo -n "13, "
126
	[ -e /etc/e2guardian/lists/exceptionsitelist.default ] && mv /etc/e2guardian/lists/exceptionsitelist.default /etc/e2guardian/lists/exceptionsitelist && echo -n "13, "
141
	[ -e /etc/e2guardian/lists/exceptionurllist.default ] && mv /etc/e2guardian/lists/exceptionurllist.default /etc/e2guardian/lists/exceptionurllist && echo -n "14, "
127
	[ -e /etc/e2guardian/lists/exceptionurllist.default ] && mv /etc/e2guardian/lists/exceptionurllist.default /etc/e2guardian/lists/exceptionurllist && echo -n "14, "
142
	[ -e /etc/e2guardian/lists/urlregexplist.rpmnew ] && mv -f /etc/e2guardian/lists/urlregexplist.rpmnew /etc/e2guardian/lists/urlregexplist.default
-
 
143
	[ -e /etc/e2guardian/lists/urlregexplist.default ] && mv /etc/e2guardian/lists/urlregexplist.default /etc/e2guardian/lists/urlregexplist && echo -n "15, "
128
	[ -e /etc/e2guardian/lists/urlregexplist.default ] && mv /etc/e2guardian/lists/urlregexplist.default /etc/e2guardian/lists/urlregexplist && echo -n "15, "
144
	[ -e /etc/e2guardian/lists/bannedregexpurllist.rpmnew ] && mv -f /etc/e2guardian/lists/bannedregexpurllist.rpmnew /etc/e2guardian/lists/bannedregexpurllist.default
-
 
145
	[ -e /etc/e2guardian/lists/bannedregexpurllist.default ] && mv -f /etc/e2guardian/lists/bannedregexpurllist.default /etc/e2guardian/lists/bannedregexpurllist && echo -n "16"
129
	[ -e /etc/e2guardian/lists/bannedregexpurllist.default ] && mv -f /etc/e2guardian/lists/bannedregexpurllist.default /etc/e2guardian/lists/bannedregexpurllist && echo -n "16"
146
}
130
}
147
 
131
 
148
antivirus ()
132
antivirus ()
149
{
133
{
Line 154... Line 138...
154
	fi
138
	fi
155
	if [ -e /etc/systemd/system/clamav-daemon.socket ]; then
139
	if [ -e /etc/systemd/system/clamav-daemon.socket ]; then
156
		rm -f /etc/systemd/system/clamav-daemon.socket
140
		rm -f /etc/systemd/system/clamav-daemon.socket
157
		echo -n "2, "
141
		echo -n "2, "
158
	fi
142
	fi
159
	[ -e /etc/clamd.conf.rpmnew ] && mv /etc/clamd.conf.rpmnew /etc/clamd.conf.default
-
 
160
	[ -e /etc/clamd.conf.default ] && mv /etc/clamd.conf.default /etc/clamd.conf && echo -n "3, "
143
	[ -e /etc/clamd.conf.default ] && mv /etc/clamd.conf.default /etc/clamd.conf && echo -n "3, "
161
	[ -e /etc/freshclam.conf.rpmnew ] && mv /etc/freshclam.conf.rpmnew /etc/freshclam.conf.default
-
 
162
	[ -e /etc/freshclam.conf.default ] && mv /etc/freshclam.conf.default /etc/freshclam.conf && echo -n "4"
144
	[ -e /etc/freshclam.conf.default ] && mv /etc/freshclam.conf.default /etc/freshclam.conf && echo -n "4"
163
}
145
}
164
 
146
 
165
ulogd ()
147
ulogd ()
166
{
148
{
Line 183... Line 165...
183
}
165
}
184
 
166
 
185
vnstat ()
167
vnstat ()
186
{
168
{
187
	echo -en "(2) : "
169
	echo -en "(2) : "
188
	[ -e /etc/vnstat.conf.rpmnew ] && mv /etc/vnstat.conf.rpmnew /etc/vnstat.conf.default
-
 
189
	[ -e /etc/vnstat.conf.default ] && mv /etc/vnstat.conf.default /etc/vnstat.conf && echo -n "1, "
170
	[ -e /etc/vnstat.conf.default ] && mv /etc/vnstat.conf.default /etc/vnstat.conf && echo -n "1, "
190
	if [ -e /etc/systemd/system/vnstat.service ]; then
171
	if [ -e /etc/systemd/system/vnstat.service ]; then
191
		rm -f /etc/systemd/system/vnstat.service
172
		rm -f /etc/systemd/system/vnstat.service
192
		echo -n "2"
173
		echo -n "2"
193
	fi
174
	fi
Line 238... Line 219...
238
}
219
}
239
 
220
 
240
fail2ban ()
221
fail2ban ()
241
{
222
{
242
	echo -en "(11) : "
223
	echo -en "(11) : "
243
	[ -e /etc/fail2ban/jail.conf.rpmnew ] && mv /etc/fail2ban/jail.conf.rpmnew /etc/fail2ban/jail.conf.default
-
 
244
	[ -e /etc/fail2ban/jail.conf.default ] && mv /etc/fail2ban/jail.conf.default /etc/fail2ban/jail.conf && echo -n "1, "
224
	[ -e /etc/fail2ban/jail.conf.default ] && mv /etc/fail2ban/jail.conf.default /etc/fail2ban/jail.conf && echo -n "1, "
245
	[ -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 # only for ALCASAR version <= V3.5.1
225
	[ -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 # only for ALCASAR version <= V3.5.1
246
	i=2
226
	i=2
247
	for filter in `ls /etc/fail2ban/filter.d/alcasar_* 2>/dev/null`
227
	for filter in `ls /etc/fail2ban/filter.d/alcasar_* 2>/dev/null`
248
	do
228
	do
Line 298... Line 278...
298
post_install ()
278
post_install ()
299
{
279
{
300
echo -en "(7) : "
280
echo -en "(7) : "
301
	[ -e /etc/mageia-release.default ] && mv -f /etc/mageia-release.default /etc/mageia-release && echo -n "1, "
281
	[ -e /etc/mageia-release.default ] && mv -f /etc/mageia-release.default /etc/mageia-release && echo -n "1, "
302
	[ -e /etc/ssh/alcasar-banner-ssh ] && rm -f /etc/ssh/alcasar-banner-ssh && echo -n "2, "
282
	[ -e /etc/ssh/alcasar-banner-ssh ] && rm -f /etc/ssh/alcasar-banner-ssh && echo -n "2, "
303
	[ -e /etc/ssh/sshd_config.rpmnew ] && mv -f /etc/ssh/sshd_config.rpmnew /etc/ssh/sshd_config.default 
-
 
304
	[ -e /etc/ssh/sshd_config.default ] && mv -f /etc/ssh/sshd_config.default /etc/ssh/sshd_config && echo -n "3, "
283
	[ -e /etc/ssh/sshd_config.default ] && mv -f /etc/ssh/sshd_config.default /etc/ssh/sshd_config && echo -n "3, "
305
	[ -e /etc/bashrc.default ] && mv -f /etc/bashrc.default /etc/bashrc && echo -n "4, "
284
	[ -e /etc/bashrc.default ] && mv -f /etc/bashrc.default /etc/bashrc && echo -n "4, "
306
	[ -e /etc/sudoers.default ] && mv -f /etc/sudoers.default /etc/sudoers && echo -n "5, "
285
	[ -e /etc/sudoers.default ] && mv -f /etc/sudoers.default /etc/sudoers && echo -n "5, "
307
	[ -e /etc/security/limits.conf.default ] && mv -f /etc/security/limits.conf.default /etc/security/limits.conf && echo -n "6, "
286
	[ -e /etc/security/limits.conf.default ] && mv -f /etc/security/limits.conf.default /etc/security/limits.conf && echo -n "6, "
308
	[ -e /etc/default/grub.default ] && mv -f /etc/default/grub.default /etc/default/grub && echo -n "7"
287
	[ -e /etc/default/grub.default ] && mv -f /etc/default/grub.default /etc/default/grub && echo -n "7"
Line 415... Line 394...
415
	sleep 1
394
	sleep 1
416
fi
395
fi
417
 
396
 
418
# Reset "skip.list" (we keep "kernel" in order not to download kernel we don't want to have)
397
# Reset "skip.list" (we keep "kernel" in order not to download kernel we don't want to have)
419
echo "/^kernel/" > /etc/urpmi/skip.list
398
echo "/^kernel/" > /etc/urpmi/skip.list
420
[ -e /etc/dnf/dnf.conf.rpmnew ] && mv -f /etc/dnf/dnf.conf.rpmnew /etc/dnf/dnf.conf
-
 
421
if [ `egrep '^exclude=' /etc/dnf/dnf.conf |wc -l` -eq "1" ]; then
399
if [ `egrep '^exclude=' /etc/dnf/dnf.conf |wc -l` -eq "1" ]; then
422
	$SED "s?^exclude=.*?exclude=kernel\*?g" /etc/dnf/dnf.conf
400
	$SED "s?^exclude=.*?exclude=kernel\*?g" /etc/dnf/dnf.conf
423
else
401
else
424
	echo "exclude=kernel*" >> /etc/dnf/dnf.conf
402
	echo "exclude=kernel*" >> /etc/dnf/dnf.conf
425
fi
403
fi