Subversion Repositories ALCASAR

Rev

Rev 1474 | Rev 1596 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log

#!/bin/sh
# $Id: alcasar-daemon.sh 1476 2014-11-04 18:18:07Z richard $

# alcasar-daemon.sh
# by Franck BOUIJOUX & Rexy
# 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}
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"

function ServiceTest () {
         CMD=`systemctl is-active $s`
         if [ $CMD != "active" ]
         then
                logger -i "!! $s is inactive. Activation attempt"
                systemctl start $s.service
         fi
}


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