Just a quickie: this is an init script I wrote recently for a game server. Comments and suggestions appreciated :)
Put this script in /etc/init.d, then symlink it from your rc#.d directory (where # is your default runlevel(s))
example of the symlink:
ln -s /etc/init.d/sauer_init_script /etc/rc5.d/S50sauerbraten
Cheers!
Darren
The script:
#!/bin/sh
# Note: This *must* be the only instance of $BINARY running on this box.
# If you want to run two servers, you could hardlink the server binary
BINARY=/home/sauer/sauerbraten/src/sauer_server
BINDIP=203.12.xxx.yyy
PASSWORD=password
PLAYERLIMIT=16
SERVERNAME="Example Server"
OTHERFLAGS=""
LOGFILE="/var/log/sauerbraten_log"
test -x $BINARY || exit 0
case "$1" in
"start")
echo -n "Starting Sauerbraten server: "
start-stop-daemon --start --chuid sauer --group sauer --exec $BINARY -- -p$PASSWORD -c$PLAYERLIMIT -i$BINDIP -n"$SERVERNAME" $OTHERFLAGS > $LOGFILE &
echo "sauer_server."
;;
"stop")
echo -n "Stopping Sauerbraten server: "
start-stop-daemon --stop --oknodo --chuid sauer --group sauer --retry 30 --exec $BINARY
echo "sauer_server."
;;
"restart")
echo -n "Restarting Sauerbraten server: "
start-stop-daemon --stop --oknodo --chuid sauer --group sauer --retry 30 --exec $BINARY
start-stop-daemon --start --chuid sauer --group sauer --exec $BINARY -- -p$PASSWORD -c$PLAYERLIMIT -i$BINDIP -n"$SERVERNAME" $OTHERFLAGS > $LOGFILE &
echo "sauer_server."
;;
*)
echo "Usage: /etc/init.d/`basename $0` {start|stop|restart}"
exit 1
;;
esac
exit 0