Subversion Repositories ALCASAR

Rev

Rev 1018 | Rev 1395 | 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 1056 2013-03-26 21:46:36Z stephane $
807 franck 3
 
824 franck 4
# alcasar-daemon.sh
807 franck 5
# by Franck BOUIJOUX
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"
11
SSH=`grep SSH= $conf_file|cut -d"=" -f2`				# sshd active (on/off)
12
SSH=${SSH:=off}
13
SERVICE="sshd dnsmasq httpd chilli radiusd mysqld dansguardian dnsmasq havp freshclam ntpd squid master squid"
807 franck 14
 
824 franck 15
function ServiceTest () {
16
	 CMD=`pidof $s`
17
	 if [ -z "$CMD" ]
18
	 then
19
	    service $s restart
20
#	 else
21
#	    echo "Service $s is On on PID : $CMD"
22
	 fi
23
}
807 franck 24
 
824 franck 25
 
807 franck 26
for s in $SERVICE
27
do
824 franck 28
	if [ $s != "sshd" ] 
807 franck 29
	then
1018 franck 30
	    ServiceTest
824 franck 31
	else
32
	{
33
	    if [ $SSH == "ON" ] | [ $SSH == "on" ] | [ $SSH == "On" ]
34
	    then
1018 franck 35
		  ServiceTest
824 franck 36
	    fi
37
	}
807 franck 38
	fi
39
done