lcnyg 发表于 2005-9-12 19:45:26

贴个自己写的bsd下的启动脚本

我的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

windgao 发表于 2005-9-12 20:50:49

回复: 贴个自己写的bsd下的启动脚本

不错。!!!不过我还没测试呢?

luhe4535 发表于 2005-9-16 21:06:51

回复: 贴个自己写的bsd下的启动脚本

相当不错了,仁兄急人所急啊!正需要呢

anyliz 发表于 2005-10-7 15:27:29

回复: 贴个自己写的bsd下的启动脚本

不错,楼主厉害,学习ing :super:

kelle10309 发表于 2005-10-7 15:59:40

回复: 贴个自己写的bsd下的启动脚本

向楼主学习! ;)

wjpiao 发表于 2005-10-25 15:09:55

回复: 贴个自己写的bsd下的启动脚本

学习阶段...还看不大懂呀...
页: [1]
查看完整版本: 贴个自己写的bsd下的启动脚本