Subversion Repositories ALCASAR

Rev

Rev 2520 | Rev 2534 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log

Rev Author Line No. Line
807 franck 1
#!/bin/sh
825 franck 2
# $Id: alcasar-daemon.sh 2521 2018-04-02 19:46:16Z armand.ito $
807 franck 3
 
824 franck 4
# alcasar-daemon.sh
1474 richard 5
# by Franck BOUIJOUX & Rexy
807 franck 6
# This script is distributed under the Gnu General Public License (GPL)
7
# Watchdog of Services
8
# See /etc/cron.d/alcasar-daemon-watchdog for config the time
9
 
824 franck 10
conf_file="/usr/local/etc/alcasar.conf"
2474 tom.houday 11
SSH=`grep ^SSH= $conf_file|cut -d"=" -f2`				# sshd active (on/off)
824 franck 12
SSH=${SSH:=off}
2521 armand.ito 13
SERVICES="mysqld lighttpd ntpd havp dnsmasq dnsmasq-blacklist dnsmasq-whitelist dnsmasq-blackhole radiusd tinyproxy nfsen e2guardian freshclam ulogd-ssh ulogd-traceability ulogd-ext-access chilli fail2ban sshd vnstat"
1596 richard 14
nb_available_srv=`echo $SERVICES|wc -w`
807 franck 15
 
824 franck 16
function ServiceTest () {
1596 richard 17
	CMD=`/usr/bin/systemctl is-active $s`
18
	if [ $CMD != "active" ]
19
	then
1476 richard 20
		logger -i "!! $s is inactive. Activation attempt"
1596 richard 21
		echo "the $s service is disabled! trying to start it..."
2454 tom.houday 22
		/usr/bin/systemctl start $s.service
1596 richard 23
	else
24
		nb_srv=$((nb_srv+1))
25
	fi
824 franck 26
}
807 franck 27
 
1596 richard 28
nb_srv=0
1474 richard 29
for s in $SERVICES
807 franck 30
do
2454 tom.houday 31
	if [ $s != "sshd" ]
807 franck 32
	then
1596 richard 33
		ServiceTest
824 franck 34
	else
1596 richard 35
		{
36
		if [ $SSH == "ON" ] || [ $SSH == "on" ] || [ $SSH == "On" ]
2454 tom.houday 37
		then
1596 richard 38
			ServiceTest
39
		else
2520 rexy 40
			nb_available_srv=$((nb_available_srv-1))
1596 richard 41
		fi
42
		}
807 franck 43
	fi
44
done
2520 rexy 45
 
1596 richard 46
if [ $nb_available_srv -ne $nb_srv ]
2520 rexy 47
then
48
	echo "Restart this script to know if all is ok"
1596 richard 49
else
2520 rexy 50
	echo "$nb_srv services needed by ALCASAR are started."
1596 richard 51
fi
2520 rexy 52
 
53
if [ `lsmod|grep ipt_NETFLOW|wc -l` == 0 ]
54
then
55
	logger -i "!! ipt_netflow is inactive."
56
	echo "The Log system is disabled! try to know why (modprobe ipt_NETFLOW)"
57
else
58
	echo "The Log system is active"
59
fi