Subversion Repositories ALCASAR

Rev

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

Rev 1474 Rev 1476
1
#!/bin/sh
1
#!/bin/sh
2
# $Id: alcasar-daemon.sh 1474 2014-11-03 22:55:09Z richard $
2
# $Id: alcasar-daemon.sh 1476 2014-11-04 18:18:07Z richard $
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
SERVICES="mysqld httpd ntpd iptables dnsmasq dnsmasq-blacklist dnsmasq-whitelist dnsmasq-blackhole radiusd nfsen dansguardian freshclam ulogd-ssh ulogd-traceability ulogd-ext-access chilli fail2ban sshd"
13
SERVICES="mysqld httpd ntpd iptables dnsmasq dnsmasq-blacklist dnsmasq-whitelist dnsmasq-blackhole radiusd nfsen dansguardian freshclam ulogd-ssh ulogd-traceability ulogd-ext-access chilli fail2ban sshd"
14
 
14
 
15
function ServiceTest () {
15
function ServiceTest () {
16
	 CMD=`pidof $s`
16
	 CMD=`systemctl is-active $s`
17
	 if [ -z "$CMD" ]
17
	 if [ $CMD != "active" ]
18
	 then
18
	 then
-
 
19
		logger -i "!! $s is inactive. Activation attempt"
19
		systemctl start $s.service
20
		systemctl start $s.service
20
	 fi
21
	 fi
21
}
22
}
22
 
23
 
23
 
24
 
24
for s in $SERVICES
25
for s in $SERVICES
25
do
26
do
26
	if [ $s != "sshd" ] 
27
	if [ $s != "sshd" ] 
27
	then
28
	then
28
	    ServiceTest
29
	    ServiceTest
29
	else
30
	else
30
	{
31
	{
31
	    if [ $SSH == "ON" ] | [ $SSH == "on" ] | [ $SSH == "On" ]
32
	    if [ $SSH == "ON" ] | [ $SSH == "on" ] | [ $SSH == "On" ]
32
	    then
33
	    then
33
		  ServiceTest
34
		  ServiceTest
34
	    fi
35
	    fi
35
	}
36
	}
36
	fi
37
	fi
37
done
38
done
38
 
39