1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
|
#! /bin/sh
# /etc/init.d/cod2
### BEGIN INIT INFO
# Provides: CoD2
# Default-Start: 2 3 5
# Default-Stop: 0 1 6
# X-UnitedLinux-Should-Start: network
# Description: Start CoD2 server
### END INIT INFO
# Version 2 (11/12/2005)
# Copyright (c) 2005 Soenke Gluch
# [EMAIL]gluch@informatik.uni-bonn.de[/EMAIL]
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
###
# Settings
#
# server port
SrvPort="28960"
#
# rcon password
SrvRCONPwd="ChangeMe"
#
# logfile (this is NOT the games_mp.log file from the server!)
log="/var/log/cod/cod2.log"
#
# user under which the server should run
user="cod"
#
# path to the server
path="/opt/cod2-srv"
#
# the server executable
codX="$path/cod2_lnxded"
#
# server parameters
params="+set fs_homepath $path +set net_port $SrvPort +exec cod2.cfg"
#
# timeout after that the server will be killed (in seconds)
timeout=20
#
###
. /etc/rc.status
SrvIP="localhost"
case "$1" in
start)
echo -n "Starting CoD2 server"
checkproc $codX && echo -n "(already running)" || su -c "cd $path && $codX $params 2> $log >&2" $user &
rc_status -v
;;
stop)
echo -n "Shutting down CoD2 server"
checkproc $codX || echo -n "(not running)" && echo "ÿÿÿÿrcon $SrvRCONPwd quit" | netcat -u -w1 $SrvIP $SrvPort 2> /dev/null >&2
for ((i=0; i <= timeout ; i++)); do
checkproc $codX || break && sleep 1
done
checkproc $codX && killproc $codX || echo -n
rc_status -v
;;
restart)
$0 stop
$0 start
rc_status
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
;;
esac |