我正在使用屏幕在专用服务器上托管一些Counter-Strike游戏服务器。我具有要启动/停止服务器时运行的脚本:
#! /bin/sh
# /etc/init.d/css-server
#
case "$1" in
start)
echo "Starting Nullus Imprimis war server..."
screen -A -m -d -S css-war-server /home/css-servers/war-server/css/srcds_run -game cstrike +map de_dust2 +maxplayers 16 -autoupdate -port 2555 -tick 100
echo "Nullus Imprimis war server started"
echo "Starting Nullus Imprimis pub server #1..."
screen -A -m -d -S css-pub-server-1 /home/css-servers/pub-server-1/css/srcds_run -game cstrike +map de_dust2 +maxplayers 32 -autoupdate -port 2666 -tickrate 100
echo "Nullus Imprimis pub server #1 started"
;;
stop)
echo "Stopping Nullus Imprimis war server..."
screen -S css-war-server -X quit
echo "Nullus Imprimis war server stopped"
echo "Stopping Nullus Imprimis pub server #1..."
screen -S css-pub-server-1 -X quit
echo "Nullus Imprimis pub server #1 stopped"
;;
*)
echo "Usage: /etc/init.d/css-servers {start|stop}"
exit 1
;;
esac
exit 0
我将这个脚本(称为css-servers
)放进/etc/init.d/
去,据我所知,这意味着它会在系统启动时运行。但是,当我使用检查活动屏幕时screen -ls
,没有任何运行。
如何使它们在Ubuntu Server下启动时运行?
update-rc.d
命令。我更新了脚本,然后直到运行此命令,脚本才开始运行。谢谢。顺便说一句,我们如何才能在启动时从运行中“注销”它(就像我们对update-rc.d所做的那样)?