the following is a script i wrote for starting/stoping/restarting the halflife server. its mostly ment to be used as an init script. i wrote it with debian in mind, but it should be reasonably easy to adapt to your distribution.
the script requires start-stop-daemon (part of the debian dpkg system)
http://ftp.debian.org/debian/pool/main/d/dpkg/dpkg_1.8.3.1.tar.gz
and screen
ftp://mirrors.xmission.com/gnu/screen/screen-3.9.8.tar.gz
of course you will need to modify the default values for PATH, DAEMON, HLDIR, and ARGS to match your system's setup.
- c-dubs
script is as follows:
#! /bin/bash
#
# a script for starting/stopping/restarting the halflife server
# by
cwj@rootdown.net
#
NAME=hld
PATH=/sbin:/bin:/usr/bin:/sbin:/usr/sbin
HLDIR=/usr/local/halflife/ # path to your hl server
DAEMON=/usr/local/halflife/hlds_run # path to your hlds_run binary
ARGS="-game cstrike -port 27015 +maxplayers 16 +map cs_italy" # arguments to pass to the halflife server
export LD_LIBRARY_PATH=$HLDIR:$LD_LIBRARY_PATH
trap "" 1
export LANG=C
test -f $DAEMON || exit 0
case "$1" in
start)
echo -ne "Starting server: $NAME.\n"
cd $HLDIR
screen -m -d -S hld $DAEMON $ARGS
;;
stop)
echo -ne "Stoping server: $NAME.\n"
start-stop-daemon --stop -x $DAEMON
;;
restart)
echo -ne "Restarting server: $NAME.\n"
start-stop-daemon --stop -x $DAEMON
cd $HLDIR
screen -m -d -S hld $DAEMON $ARGS
;;
*)
echo "Usage: /etc/init.d/$NAME {start|stop|restart}"
exit 1
;;
esac
exit 0