#!/bin/sh # the chroot 'root' directory where your game server is installed SERVER_ROOT=/usr/local/enemy-territory # additional options that should be passed to the game server command line # for example, "+exec server.cfg +set net_ip 127.0.0.1" SERVER_OPTIONS="+exec server.cfg" # the location of a file that the PID of the running server should be written # to by this script SERVER_PIDFILE=/var/run/etded.pid # the FULL PATH to the server binary. this is used by /sbin/pidof in # determining if the server is running. SERVER_BIN=/usr/local/enemy-territory/enemy-territory/etded.x86 # the username for the account that the server should be run as SERVER_USER=et # the location of a file that the PID of this script should be stored in PIDFILE=/var/run/etded.sh.pid; echo $$ > $PIDFILE; while [ 1 ]; do if [ ! $(pidof $SERVER_BIN) ]; then screen -d -m chroot $SERVER_ROOT su - \ $SERVER_USER $SERVER_OPTIONS sleep 1 if [ ! $(pidof $SERVER_BIN) ]; then echo "\ Could not find a PID for ${SERVER_BIN}! If etded.x86 is actually running, update ${0} so that it can properly detect the PID of ${SERVER_BIN}." rm $PIDFILE exit; fi echo `pidof $SERVER_BIN` > $SERVER_PIDFILE fi sleep 30; done;