You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
76 lines
1.6 KiB
76 lines
1.6 KiB
13 years ago
|
#!/sbin/runscript
|
||
|
# Copyright 1999-2011 Gentoo Foundation
|
||
|
# Distributed under the terms of the GNU General Public License v2
|
||
|
# $Header: /var/cvsroot/gentoo-x86/games-server/halflife-steam/files/hlds.rc,v 1.2 2011/10/05 09:14:03 mr_bones_ Exp $
|
||
|
|
||
|
PID_PATH="/var/run"
|
||
|
|
||
|
depend() {
|
||
|
use net
|
||
|
}
|
||
|
|
||
|
checkconfig() {
|
||
|
local var
|
||
|
for var in HLDS_PATH HLDS_MT HLDS_OPTS ; do
|
||
|
if [[ -z ${!var} ]] ; then
|
||
|
eerror "Need to set ${var} in /etc/conf.d/HLDS_PATH"
|
||
|
return 1
|
||
|
fi
|
||
|
done
|
||
|
return 0
|
||
|
}
|
||
|
|
||
|
start_server() {
|
||
|
local serv_num=$1
|
||
|
local serv_opts="`eval echo '$'HLDS_SERVER${serv_num}`"
|
||
|
local PID1=${PID_PATH}/hlds${serv_num}_1.pid
|
||
|
local PID2=${PID_PATH}/hlds${serv_num}_2.pid
|
||
|
rm -f $PID1 $PID2
|
||
|
|
||
|
test $serv_num != 1 -a -z "$serv_opts" && return 1
|
||
|
|
||
|
ebegin "Starting Halflife Dedicated Server $serv_num"
|
||
|
touch ${PID2}
|
||
|
chown @GAMES_USER@:@GAMES_GROUP@ ${PID2}
|
||
|
start-stop-daemon --start \
|
||
|
--chdir ${HLDS_PATH} -c @GAMES_USER@:@GAMES_GROUP@ \
|
||
|
-n ${HLDS_MT} -b -a ${HLDS_PATH}/${HLDS_MT} \
|
||
|
-m --pidfile ${PID1} \
|
||
|
-- \
|
||
|
-pidfile ${PID2} ${HLDS_OPTS} ${serv_opts}
|
||
|
eend $?
|
||
|
}
|
||
|
|
||
|
stop_server() {
|
||
|
local serv_num=$1
|
||
|
local PID1=${PID_PATH}/hlds${serv_num}_1.pid
|
||
|
local PID2=${PID_PATH}/hlds${serv_num}_2.pid
|
||
|
if test -f ${PID1} -a -f ${PID2}; then
|
||
|
ebegin "Stopping Halflife Dedicated Server $serv_num"
|
||
|
start-stop-daemon --stop --pidfile ${PID1}
|
||
|
start-stop-daemon --stop --pidfile ${PID2}
|
||
|
eend $?
|
||
|
rm -f $PID1 $PID2
|
||
|
else
|
||
|
return 1
|
||
|
fi
|
||
|
return 0
|
||
|
}
|
||
|
|
||
|
start() {
|
||
|
checkconfig || return $?
|
||
|
|
||
|
export LD_LIBRARY_PATH=${HLDS_PATH}:${HLDS_PATH}/bin:${LD_LIBRARY_PATH}
|
||
|
local i=1
|
||
|
while start_server $i; do
|
||
|
i=$(($i+1))
|
||
|
done
|
||
|
}
|
||
|
|
||
|
stop() {
|
||
|
local i=1
|
||
|
while stop_server $i; do
|
||
|
i=$(($i+1))
|
||
|
done
|
||
|
}
|