Subversion Repositories ALCASAR

Rev

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

Rev 1056 Rev 1393
1
#!/bin/sh
1
#!/bin/sh
2
# $Id: alcasar-daemon.sh 1056 2013-03-26 21:46:36Z stephane $
2
# $Id: alcasar-daemon.sh 1393 2014-06-19 08:44:51Z richard $
3
 
3
 
4
# alcasar-daemon.sh
4
# alcasar-daemon.sh
5
# by Franck BOUIJOUX
5
# by Franck BOUIJOUX
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
SERVICE="sshd dnsmasq httpd chilli radiusd mysqld dansguardian dnsmasq havp freshclam ntpd squid master squid"
13
SERVICE="sshd dnsmasq httpd chilli radiusd mysqld dansguardian dnsmasq havp havp2 freshclam ntpd squid master squid"
14
 
14
 
15
function ServiceTest () {
15
function ServiceTest () {
16
	 CMD=`pidof $s`
16
	 CMD=`pidof $s`
17
	 if [ -z "$CMD" ]
17
	 if [ -z "$CMD" ]
18
	 then
18
	 then
19
	    service $s restart
19
	    service $s restart
20
#	 else
20
#	 else
21
#	    echo "Service $s is On on PID : $CMD"
21
#	    echo "Service $s is On on PID : $CMD"
22
	 fi
22
	 fi
23
}
23
}
24
 
24
 
25
 
25
 
26
for s in $SERVICE
26
for s in $SERVICE
27
do
27
do
28
	if [ $s != "sshd" ] 
28
	if [ $s != "sshd" ] 
29
	then
29
	then
30
	    ServiceTest
30
	    ServiceTest
31
	else
31
	else
32
	{
32
	{
33
	    if [ $SSH == "ON" ] | [ $SSH == "on" ] | [ $SSH == "On" ]
33
	    if [ $SSH == "ON" ] | [ $SSH == "on" ] | [ $SSH == "On" ]
34
	    then
34
	    then
35
		  ServiceTest
35
		  ServiceTest
36
	    fi
36
	    fi
37
	}
37
	}
38
	fi
38
	fi
39
done
39
done
40
 
40