Subversion Repositories ALCASAR

Rev

Rev 2537 | Rev 2574 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 2537 Rev 2572
1
#!/bin/sh
1
#!/bin/sh
2
# $Id: alcasar-daemon.sh 2537 2018-04-30 04:07:45Z tom.houdayer $
2
# $Id: alcasar-daemon.sh 2572 2018-07-20 16:55:00Z rexy $
3
 
3
 
4
# alcasar-daemon.sh
4
# alcasar-daemon.sh
5
# by Franck BOUIJOUX & Rexy
5
# by Franck BOUIJOUX & Rexy
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
# Watchdog of Services
7
# Watchdog of Services
8
# See /etc/cron.d/alcasar-daemon-watchdog for config the time
8
# See /etc/cron.d/alcasar-daemon-watchdog for config the time
9
 
9
 
10
conf_file="/usr/local/etc/alcasar.conf"
10
conf_file="/usr/local/etc/alcasar.conf"
11
SSH=`grep ^SSH= $conf_file|cut -d"=" -f2`				# sshd active (on/off)
11
SSH=`grep ^SSH= $conf_file|cut -d"=" -f2`				# sshd active (on/off)
12
SSH=${SSH:=off}
12
SSH=${SSH:=off}
-
 
13
LDAP=`grep ^LDAP= $conf_file|cut -d"=" -f2`				# ldap active (on/off)
-
 
14
LDAP=${SSH:=off}
13
SERVICES="mysqld lighttpd php-fpm 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"
15
SERVICES="mysqld lighttpd php-fpm 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"
14
nb_available_srv=`echo $SERVICES|wc -w`
16
nb_available_srv=`echo $SERVICES|wc -w`
15
 
17
 
16
function ServiceTest () {
18
function ServiceTest () {
17
	CMD=`/usr/bin/systemctl is-active $s`
19
	CMD=`/usr/bin/systemctl is-active $s`
18
	if [ $CMD != "active" ]
20
	if [ $CMD != "active" ]
19
	then
21
	then
20
		logger -t alcasar-daemon -i "$s is inactive. Activation attempt"
22
		logger -t alcasar-daemon -i "$s is inactive. Activation attempt"
21
		echo "the $s service is disabled! trying to start it..."
23
		echo "the $s service is disabled! trying to start it..."
22
		/usr/bin/systemctl start $s.service
24
		/usr/bin/systemctl start $s.service
23
	else
25
	else
24
		nb_srv=$((nb_srv+1))
26
		nb_srv=$((nb_srv+1))
25
	fi
27
	fi
26
}
28
}
27
 
29
 
28
nb_srv=0
30
nb_srv=0
29
for s in $SERVICES
31
for s in $SERVICES
30
do
32
do
31
	if [ $s != "sshd" ]
33
	if [ $s != "sshd" ]
32
	then
34
	then
33
		ServiceTest
35
		ServiceTest
34
	else
36
	else
35
		{
37
		{
36
		if [ $SSH == "ON" ] || [ $SSH == "on" ] || [ $SSH == "On" ]
38
		if [ $SSH == "ON" ] || [ $SSH == "on" ] || [ $SSH == "On" ]
37
		then
39
		then
38
			ServiceTest
40
			ServiceTest
39
		else
41
		else
40
			nb_available_srv=$((nb_available_srv-1))
42
			nb_available_srv=$((nb_available_srv-1))
41
		fi
43
		fi
42
		}
44
		}
43
	fi
45
	fi
44
done
46
done
45
 
47
 
46
if [ $nb_available_srv -ne $nb_srv ]
48
if [ $nb_available_srv -ne $nb_srv ]
47
then
49
then
48
	echo "Restart this script to know if all is ok"
50
	echo "Restart this script to know if all is ok"
49
else
51
else
50
	echo "$nb_srv services needed by ALCASAR are started."
52
	echo "$nb_srv services needed by ALCASAR are started."
51
fi
53
fi
52
 
54
 
53
if [ `lsmod|grep ipt_NETFLOW|wc -l` == 0 ]
55
if [ `lsmod|grep ipt_NETFLOW|wc -l` == 0 ]
54
then
56
then
55
	logger -t alcasar-daemon -i "ipt_netflow is inactive."
57
	logger -t alcasar-daemon -i "ipt_netflow is inactive."
56
	echo "The Log system is disabled! try to know why (modprobe ipt_NETFLOW)"
58
	echo "The Log system is disabled! try to know why (modprobe ipt_NETFLOW)"
57
else
59
else
58
	echo "The Log system is active"
60
	echo "The Log system is active"
59
fi
61
fi
-
 
62
if [ ! -e /etc/raddb/mods-enabled/ldap ]
-
 
63
then
-
 
64
	if [ $LDAP == "ON" ] || [ $LDAP == "on" ] || [ $LDAP == "On" ]
-
 
65
	then
-
 
66
	echo "Enable LDAP..."
-
 
67
	/usr/local/bin/alcasar-ldap.sh -on
-
 
68
	fi
-
 
69
fi
60
 
70