|
发表于 2005-9-12 19:45:26
|
显示全部楼层
|阅读模式
来自 中国–云南–红河哈尼族彝族自治州
我的cs16放在/usr/home/lcnyg目录下,cs16.sh放在/usr/local/etc/rc.d下可以开机自动运行,手工运行时:
./cs16.sh start #启动
./cs16.sh stop #停止
./cs16.sh restart #重新启动
代码如下:
#!/bin/sh
hlds_run=`ps -ax | grep hlds_run | grep -v grep | awk '{print $1}'`
hlds_i686=`ps -ax | grep hlds_i686 | grep -v grep | awk '{print $1}'`
case $1 in
start)
if [ "$hlds_run" = "" ]; then
echo "Starting cs16"
echo ""
cd /usr/home/lcnyg/hl2738
sh ./hlds_run -game cstrike +port 27016 -insecure +sv_lan 0 +maxplayers 16 +map de_dust2 +sv_region 4 +servercfgfile 27016.cfg > /dev/null &
else
echo "cs16 already running."
fi
;;
stop)
if [ "$hlds_run" = "" ]; then
echo "cs16 not running"
echo ""
else
echo "Stoping cs16"
kill -9 $hlds_run
if [ "$hlds_i686" = "" ]; then
echo ""
kill -9 $hlds_i686
else
echo ""
fi
fi
;;
restart)
if [ "$hlds_run" = "" ]; then
echo "cs16 not running"
echo ""
else
echo "Restart cs16"
echo ""
kill -9 $hlds_run
if [ "$hlds_i686" = "" ]; then
echo ""
else
kill -9 $hlds_i686
fi
cd /usr/home/lcnyg/hl2738
sh ./hlds_run -game cstrike +port 27016 -insecure +sv_lan 0 +maxplayers 16 +map de_dust2 +sv_region 4 +servercfgfile 27016.cfg > /dev/null &
fi
;;
*)
echo "cs16 {start|stop|restart}"
echo " start Start cs16 services"
echo " stop Stop cs16 services"
echo " restart Restart cs16 services"
;;
esac
exit 0 |
|