Subversion Repositories ALCASAR

Compare Revisions

Ignore whitespace Rev 2600 → Rev 2601

/scripts/alcasar-daemon.sh
1,4 → 1,4
#!/bin/sh
#!/bin/bash
# $Id$
 
# alcasar-daemon.sh
14,16 → 14,15
LDAP=${LDAP:=off}
INTIF=`grep ^INTIF= $conf_file|cut -d"=" -f2` # INTIF name
EXTIF=`grep ^EXTIF= $conf_file|cut -d"=" -f2` # EXTIF name
SERVICES="mysqld lighttpd php-fpm ntpd havp dnsmasq dnsmasq-blacklist dnsmasq-whitelist dnsmasq-blackhole radiusd tinyproxy nfsen e2guardian freshclam ulogd-ssh ulogd-traceability ulogd-ext-access chilli fail2ban sshd vnstat"
SERVICES="mysqld lighttpd php-fpm ntpd havp dnsmasq dnsmasq-blacklist dnsmasq-whitelist dnsmasq-blackhole radiusd tinyproxy nfsen e2guardian freshclam ulogd-ssh ulogd-traceability ulogd-ext-access chilli fail2ban sshd vnstat gammu-smsd"
nb_available_srv=`echo $SERVICES|wc -w`
 
function ServiceTest () {
CMD=`/usr/bin/systemctl is-active $s`
if [ $CMD != "active" ]
then
logger -t alcasar-daemon -i "$s is inactive. Activation attempt"
echo "the $s service is disabled! trying to start it..."
/usr/bin/systemctl start $s.service
service=$1
if [ $(/usr/bin/systemctl is-active $service) != "active" ]; then
logger -t alcasar-daemon -i "$service is inactive. Activation attempt"
echo "the $service service is disabled! trying to start it..."
/usr/bin/systemctl start $service.service
else
nb_srv=$((nb_srv+1))
fi
39,21 → 38,20
done
 
nb_srv=0
for s in $SERVICES
do
if [ $s != "sshd" ]
then
ServiceTest
else
{
if [ $SSH == "ON" ] || [ $SSH == "on" ] || [ $SSH == "On" ]
then
ServiceTest
else
for service in $SERVICES; do
if [ $service == 'sshd' ]; then
if [ $SSH != "ON" ] && [ $SSH != "on" ] && [ $SSH != "On" ]; then
nb_available_srv=$((nb_available_srv-1))
continue
fi
}
elif [ $service == 'gammu-smsd' ]; then
if [ $(grep '^SMS=' $conf_file | cut -d'=' -f2-) != 'on' ]; then
nb_available_srv=$((nb_available_srv-1))
continue
fi
fi
 
ServiceTest $service
done
 
if [ $nb_available_srv -ne $nb_srv ]
/scripts/alcasar-sms.sh
17,8 → 17,9
time_ban=2
#########################################
####### IDs DB ##########################
u_db="radius"
p_db="password"
PASSWD_FILE="/root/ALCASAR-passwords.txt"
u_db=$(grep '^db_user=' $PASSWD_FILE | cut -d'=' -f2-)
p_db=$(grep '^db_password=' $PASSWD_FILE | cut -d'=' -f2-)
#########################################
#########################################
 
82,15 → 83,17
fi
 
#Start gammu
echo $separator >> $logfile
sudo gammu-smsd --config $config --pid /var/run/gammu-smsd.pid --daemon
echo $separator >> $logfile
/usr/bin/systemctl -q start gammu-smsd.service
/usr/bin/systemctl -q enable gammu-smsd.service
} # end function start_gammu
 
function stop_gammu() {
#Stop gammu
sudo kill -9 gammu-smsd
sleep 10
echo $end >> $logfile
/usr/bin/systemctl -q stop gammu-smsd.service
/usr/bin/systemctl -q disable gammu-smsd.service
sleep 10
echo $end >> $logfile
} # end function stop_gammu
 
function unlock() {