acrash.sh:
Code
#!/bin/sh
#Переменные
pidfile='/var/run/27015.pid'
#
patch='/opt/games/cs2'
#adress servera
adress='77.243.98.233:27015'
#
run_script='/games/cs_27015/runserver.sh'
#log
logg='/games/cs_27015/crash.log'
#time
cd $patch
if test -r $pidfile
then
pid=`cat ./27015.pid`
if `kill -CHLD $pid >/dev/null 2>&1`
then
st=`/opt/games/monitoring/qstat/bin/qstat -a2s $adress |grep "DOWN" | wc -l`
if [ "1" == "$st" ]
then
`kill -9 $pid`
echo $(date +"%d.%m.%y %T") restart Counter-Strike server >>$logg
else
# echo $(date +"%d.%m.%y %T") status ok >> $logg
fi
else
echo $(date +"%d.%m.%y %T") restart Counter-Strike server >> $logg
`$run_script`
fi
else
echo $(date +"%d.%m.%y %T") start Counter-Strike server >> $logg
`$run_script`
fi
runserver.sh:
Code
#!/bin/bash
echo "Start Public: Done."
sleep 1
screen -A -h 3500 -m -d -S cs_27015 ./hlds_run -binary ./hlds_i686 -game cstrike -port 27015 +map de_dust2 +maxplayers 18 +ip 77.243.98.233 -sys_ticrate 1500 -pingboost 2 -pidfile /var/run/cs_27015.pid -timeout 0