Subversion Repositories ALCASAR

Rev

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

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