Subversion Repositories ALCASAR

Rev

Rev 825 | Rev 958 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log

#!/bin/sh
# $Id: alcasar-daemon.sh 851 2012-04-09 10:20:16Z franck $

# alcasar-daemon.sh
# by Franck BOUIJOUX
# This script is distributed under the Gnu General Public License (GPL)
# Watchdog of Services
# See /etc/cron.d/alcasar-daemon-watchdog for config the time

conf_file="/usr/local/etc/alcasar.conf"
SSH=`grep SSH= $conf_file|cut -d"=" -f2`                                # sshd active (on/off)
SSH=${SSH:=off}
SERVICE="sshd dnsmasq httpd chilli radiusd mysqld dansguardian dnsmasq havp freshclam ntpd squid master squid"

function ServiceTest () {
         CMD=`pidof $s`
         if [ -z "$CMD" ]
         then
            service $s restart
#        else
#           echo "Service $s is On on PID : $CMD"
         fi
}


for s in $SERVICE
do
        if [ $s != "sshd" ] 
        then
            ServiceTest ($s)
        else
        {
            if [ $SSH == "ON" ] | [ $SSH == "on" ] | [ $SSH == "On" ]
            then
                  ServiceTest ($s)
            fi
        }
        fi
done