6,20 → 6,56 |
# by Franck BOUIJOUX, Pascal LEVANT and Richard REY |
# This script is distributed under the Gnu General Public License (GPL) |
|
# Désisntallation d'ALCASAR |
# Uninstall ALCASAR |
# Désisntallation ou mise à jour d'ALCASAR |
# Uninstall or update ALCASAR |
|
usage="Usage: alcasar-uninstall.sh {-update or --update} | {-full or --full}" |
SED="/bin/sed -i" |
|
nb_args=$# |
args=$1 |
if [ $nb_args -eq 0 ] |
then |
nb_args=1 |
args="-h" |
fi |
case $args in |
-\? | -h* | --h*) |
echo "$usage" |
exit 0 |
;; |
--update | -update) |
mode="update" |
;; |
--full | -full) |
mode="full" |
;; |
*) |
echo "Argument inconnu :$1"; |
echo "$usage" |
exit 1 |
;; |
esac |
|
clear |
echo "-----------------------------------------------------------------------------" |
echo "** Uninstall/Update ALCASAR **" |
echo "-----------------------------------------------------------------------------" |
echo |
/usr/local/bin/alcasar-logout.sh all |
# services_stop |
if [ $mode == "full" ] |
then |
echo "----------------------------------------------------------------------------" |
echo "** Uninstall/Désinstallation d'ALCASAR **" |
echo "----------------------------------------------------------------------------" |
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" |
/usr/local/bin/alcasar-logout.sh all # logout everybody |
else |
echo "----------------------------------------------------------------------------" |
echo "** update/mise à jour d'ALCASAR **" |
echo "----------------------------------------------------------------------------" |
# dnsmasq & sshd should stay on to allow remote update |
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" |
/usr/local/bin/alcasar-bypass.sh -on # to allow remote update |
fi |
echo "Stopping service : " |
/usr/local/bin/alcasar-sms.sh --stop |
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 |
for i in $services |
do |
if [ -e /lib/systemd/system/$i.service ] |
then |
31,7 → 67,7 |
fi |
done |
echo "Check the service clearing" |
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 |
for i in $services |
do |
if [ `systemctl is-active $i.service` == "active" ] |
then |
42,7 → 78,7 |
done |
echo "Reset ALCASAR main functions : " |
echo -en "\n- init(1) : " |
# les fichiers situés dans /usr/local/ seront supprimés à la fin car encore utiles ici |
# The files in /usr/local/ will be removed at the end (usefull here) |
rm -f /root/ALCASAR* && echo -n "1" |
sleep 1 |
|
111,10 → 147,9 |
|
echo -en "\n- antivirus(5) : " |
if [ -e /etc/init.d/havp ] |
then |
then |
[ -e /etc/havp/havp.config.default ] && mv /etc/havp/havp.config.default /etc/havp/havp.config && echo -n "1, " |
userdel -r havp 2>/dev/null && echo -n "2, " |
[ `grep havp /etc/fstab|wc -l` -ne "0" ] && $SED "/havp/d" /etc/fstab # anciennes versions (mémoire tampon sur disque) |
[ -e /etc/init.d/havp.default ] && mv /etc/init.d/havp.default /etc/init.d/havp && echo -n "3, " |
[ -e /lib/systemd/system/havp.service.default ] && mv /lib/systemd/system/havp.service.default /lib/systemd/system/havp.service && echo -n "4, " |
[ -e /etc/freshclam.conf.default ] && mv /etc/freshclam.conf.default /etc/freshclam.conf && echo -n "5" |
124,7 → 159,7 |
|
echo -en "\n- tinyproxy(2) : " |
if [ -e /etc/init.d/tinyproxy ] |
then |
then |
[ -e /etc/tinyproxy/tinyproxy.conf.default ] && mv /etc/tinyproxy/tinyproxy.conf.default /etc/tinyproxy/tinyproxy.conf && echo -n "1, " |
userdel -r tinyproxy 2>/dev/null && echo -n "2" |
else echo -n "uninstalled" |
134,12 → 169,12 |
echo -en "\n- ulogd(6) : " |
i=0 |
for log_type in traceability ssh ext-access |
do |
i=`expr $i + 1` |
[ -e /etc/ulogd-$log_type.conf ] && rm -f /etc/ulogd-$log_type.conf && echo -n "$i, " |
i=`expr $i + 1` |
[ -e /lib/systemd/system/ulogd-$log_type.service ] && rm -f /lib/systemd/system/ulogd-$log_type.service && echo -n "$i, " |
done |
do |
i=`expr $i + 1` |
[ -e /etc/ulogd-$log_type.conf ] && rm -f /etc/ulogd-$log_type.conf && echo -n "$i, " |
i=`expr $i + 1` |
[ -e /lib/systemd/system/ulogd-$log_type.service ] && rm -f /lib/systemd/system/ulogd-$log_type.service && echo -n "$i, " |
done |
sleep 1 |
|
echo -en "\n- nfsen(1) : " |
171,14 → 206,6 |
echo -en "\n- BL(0) : " |
sleep 1 |
|
echo -en "\n- dhcp-server(1) : " |
if [ -e /etc/init.d/dhcpd ] |
then |
/usr/sbin/urpme --auto dhcp-server --auto-orphans && echo -n "1" |
else echo -n "uninstalled" |
fi |
sleep 1 |
|
echo -en "\n- fail2ban(8) : " |
[ -e /etc/fail2ban/fail2ban.conf.default ] && mv /etc/fail2ban/fail2ban.conf.default /etc/fail2ban/fail2ban.conf && echo -n "1, " |
[ -e /etc/fail2ban/jail.conf.default ] && mv /etc/fail2ban/jail.conf.default /etc/fail2ban/jail.conf && echo -n "2, " |
210,29 → 237,31 |
[ -e /var/log/gammu-smsd ] && rm -rf /var/log/gammu-smsd && echo -n "3" |
sleep 1 |
|
echo -en "\n- network(9) : " |
hostname localhost |
CONF_FILE="/usr/local/etc/alcasar.conf" |
EXTIF=`grep ^EXTIF= $CONF_FILE|cut -d"=" -f2` # EXTernal InterFace |
INTIF=`grep ^INTIF= $CONF_FILE|cut -d"=" -f2` # INTernal InterFace |
i=0 |
for nic in $EXTIF $INTIF |
if [ mode == "full " ] |
then |
echo -en "\n- network(9) : " |
hostname localhost |
CONF_FILE="/usr/local/etc/alcasar.conf" |
EXTIF=`grep ^EXTIF= $CONF_FILE|cut -d"=" -f2` # EXTernal InterFace |
INTIF=`grep ^INTIF= $CONF_FILE|cut -d"=" -f2` # INTernal InterFace |
i=0 |
for nic in $EXTIF $INTIF |
do |
i=`expr $i + 1` |
/sbin/ifdown $nic |
[ -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, " |
i=`expr $i + 1` |
/sbin/ifdown $nic |
[ -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, " |
done |
[ -e /etc/sysconfig/network.default ] && mv /etc/sysconfig/network.default /etc/sysconfig/network && echo -n "3, " |
[ -e /etc/hosts.default ] && mv /etc/hosts.default /etc/hosts && echo -n "4, " |
[ -e /etc/hosts.allow.default ] && mv /etc/hosts.allow.default /etc/hosts.allow && echo -n "5, " |
[ -e /etc/hosts.deny.default ] && mv /etc/hosts.deny.default /etc/hosts.deny && echo -n "6, " |
[ -e /etc/modprobe.preload.default ] && mv /etc/modprobe.preload.default /etc/modprobe.preload && echo -n "7, " |
[ -e /lib/systemd/system/iptables.service.default ] && mv /lib/systemd/system/iptables.service.default /lib/systemd/system/iptables.service && echo -n "8, " |
[ -e /usr/libexec/iptables.init.default ] && mv /usr/libexec/iptables.init.default /usr/libexec/iptables.init && echo -n "9" |
[ -e /etc/sysconfig/network.default ] && mv /etc/sysconfig/network.default /etc/sysconfig/network && echo -n "3, " |
[ -e /etc/hosts.default ] && mv /etc/hosts.default /etc/hosts && echo -n "4, " |
[ -e /etc/hosts.allow.default ] && mv /etc/hosts.allow.default /etc/hosts.allow && echo -n "5, " |
[ -e /etc/hosts.deny.default ] && mv /etc/hosts.deny.default /etc/hosts.deny && echo -n "6, " |
[ -e /etc/modprobe.preload.default ] && mv /etc/modprobe.preload.default /etc/modprobe.preload && echo -n "7, " |
[ -e /lib/systemd/system/iptables.service.default ] && mv /lib/systemd/system/iptables.service.default /lib/systemd/system/iptables.service && echo -n "8, " |
[ -e /usr/libexec/iptables.init.default ] && mv /usr/libexec/iptables.init.default /usr/libexec/iptables.init && echo -n "9" |
/sbin/ifup $EXTIF |
sleep 1 |
fi |
|
/sbin/ifup $EXTIF |
sleep 1 |
|
#post_install |
echo -en "\n- post_install(6) : " |
[ -e /etc/mageia-release.default ] && mv /etc/mageia-release.default /etc/mageia-release && echo -n "1, " |
246,8 → 275,8 |
# nettoyage (on retire les services supprimés ou remplacés dans la nouvelle version) |
echo -en "\n- cleaning() : " |
for rm_fic in /usr/local/bin /usr/local/etc /usr/local/sbin |
do |
do |
rm -rf $rm_fic/alcasar* |
done |
done |
echo |
|