Subversion Repositories ALCASAR

Compare Revisions

Ignore whitespace Rev 1595 → Rev 1596

/scripts/alcasar-daemon.sh
11,28 → 11,40
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"
nb_available_srv=`echo $SERVICES|wc -w`
 
function ServiceTest () {
CMD=`/usr/bin/systemctl is-active $s`
if [ $CMD != "active" ]
then
CMD=`/usr/bin/systemctl is-active $s`
if [ $CMD != "active" ]
then
logger -i "!! $s is inactive. Activation attempt"
/usr/bin/systemctl start $s.service
fi
echo "the $s service is disabled! trying to start it..."
/usr/bin/systemctl start $s.service
else
nb_srv=$((nb_srv+1))
fi
}
 
 
nb_srv=0
for s in $SERVICES
do
if [ $s != "sshd" ]
then
ServiceTest
ServiceTest
else
{
if [ $SSH == "ON" ] | [ $SSH == "on" ] | [ $SSH == "On" ]
then
ServiceTest
fi
}
{
if [ $SSH == "ON" ] || [ $SSH == "on" ] || [ $SSH == "On" ]
then
ServiceTest
else
nb_available_srv=$((nb_available_srv-1))
fi
}
fi
done
if [ $nb_available_srv -ne $nb_srv ]
then
echo "restart this script to know if all is ok"
else
echo "$nb_srv services are started. All is ok"
fi