radcheck radiusd решаем проблему с занятым портом при не запущенном радиусе
yum install lsof -y
#!/bin/bash
STATS="/var/log/radius_test.log"
RADTEST="/usr/bin/radtest"
RADIUS="/etc/init.d/radiusd"
FREERAD_SRV_IP="localhost"
FREERAD_SECRET="SECRET"
${RADTEST} testing radius $FREERAD_SRV_IP 10 $FREERAD_SECRET > $STATS
TEST=`tail ${STATS}| /usr/bin/awk "/$1/ { result=\\$2 } END { print result ? result : 0 }"`
if [ "$TEST" == "Access-Reject" ];
then
echo "radiusd OK "
exit 0
else
#DATE=`date +%Y-%m-%d_%Hh%Mm`
#PID=`pidof radiusd`
systemctl stop radiusd
#echo "$DATE $PID radiusd stoped, restarting" >>/var/mikbill/custom_scripts/rad.log
kill -9 $(lsof -t -i:1812)
sleep 1
# $RADIUS start
systemctl start radiusd
#PID=`pidof radiusd`
#echo "$PID" >>/var/mikbill/custom_scripts/rad.log
fi
#!/bin/bash
STATS="/var/log/radius_test.log"
RADTEST="/usr/bin/radtest"
RADIUS="/etc/init.d/radiusd"
FREERAD_SRV_IP="localhost"
FREERAD_SECRET="SECRET"
${RADTEST} testing radius $FREERAD_SRV_IP 10 $FREERAD_SECRET > $STATS
TEST=`tail ${STATS}| /usr/bin/awk "/$1/ { result=\\$2 } END { print result ? result : 0 }"`
if [ "$TEST" == "Access-Reject" ];
then
echo "radiusd OK "
exit 0
else
#DATE=`date +%Y-%m-%d_%Hh%Mm`
#PID=`pidof radiusd`
systemctl stop radiusd
#echo "$DATE $PID radiusd stoped, restarting" >>/var/mikbill/custom_scripts/rad.log
kill -9 $(lsof -t -i:1812)
sleep 1
# $RADIUS start
systemctl start radiusd
#PID=`pidof radiusd`
#echo "$PID" >>/var/mikbill/custom_scripts/rad.log
fi
Комментарии
Отправить комментарий