Код: Выделить всё
steam# cat server_27015
#!/bin/sh
DEDSERVER='Source dedicated server'
LONGNAME='Counter-Strike Source'
WORKDIR='/usr/games/css_steam27015'
DAEMON='./srcds_run'
IP='77.94.175.70'
PORT='27015'
MAP='cs_office'
TICK='100'
SIZE='26'
GAME='cstrike'
NAME='css'
CONFIG='server.cfg'
FPS_MAX='600'
SV_LAN='0'
LOG='on'
OPTIONS="-game cstrike +ip $IP -port $PORT +map $MAP -tickrate $TICK +log $LOG +maxplayers $SIZE +sv_lan $SV_LAN +exec $CONFIG -norestart -secure -pidfile $WORKDIR/$GAME/$NAME.pid"
service_start(){
if [ ! -f $WORKDIR/$GAME/$NAME.pid ]; then
echo "Starting $DEDSERVER - $LONGNAME"
echo "Server IP: $IP"
echo "Server port: $PORT"
echo "Server size: $SIZE players"
cd $WORKDIR
su css_steam27015 $DAEMON $OPTIONS >> css_server.log 2>&1 &
sleep 5
ps -aux |grep $GAME |grep $PORT |awk '{ print $2}' >> $WORKDIR/$GAME/$NAME.pid
echo "$LONGNAME server process ID written to $STEAM/$GAME/$NAME.pid"
echo "$DEDSERVER started"
else
echo "$DEDSERVER - $LONGNAME already running"
fi
}
service_stop(){
if [ -f $WORKDIR/$GAME/$NAME.pid ]; then
echo "Stoping $DEDSERVER - $LONGNAME"
for id in `cat $WORKDIR/$GAME/$NAME.pid`
do kill -9 $id
echo "Killing process ID $id"
echo "Removing $LONGNAME server pid file"
rm -rf $WORKDIR/$GAME/$NAME.pid
break
done
echo "$LONGNAME server stopped."
else
echo "Cannot stop $LONGNAME server. Server is not running."
fi
}
case "$1" in
'start')
service_start
;;
'stop')
service_stop
;;
'restart')
service_stop
sleep 1
service_start
;;
*)
echo "Usage $0 start|stop|restart"
esac