#!/bin/sh # # file: startmud (linked to stopmud) # version: 0.93 # date: 1993 January 09 # desc: Bourne shell script for starting the MudOS driver and related # binaries. (replaces restart_mud) # Fixed by Zak to use basename in recognizing name as stopmud # # directory for MudOS-related binaries (driver, addr_server, ftpd, etc) # BINDIR=/proj/tmi/bin/$ARCH BINDIR=/mud/tmi2/driver/bin # directory for .info files and runtime config files ETCDIR=/mud/tmi2/etc exec > $ETCDIR/startmud.log 2> $ETCDIR/startmud.err # don't change anything below this line unless you know what you are doing. umask 003 if test $# -ne 1 then echo "usage: $0 mud_name" exit 1 fi # source the info on the mud if test -f ${ETCDIR}/$1.info then . $ETCDIR/$1.info else echo "$0: Unable to find info file '$1.info'" exit 2 fi if test "`basename $0`" = "stopmud" then PID=`cat ${BINDIR}/${PIDFILE}` echo "killing ${PID}" kill ${PID} exit 0 fi if test -d ${BINDIR} then true else echo "$0: couldn't find binaries directory: ${BINDIR}" exit 3 fi echo $$ > ${BINDIR}/${PIDFILE} #if test -f ${BINDIR}/${FTPD} #then # ${BINDIR}/${FTPD} -l #else # echo "$0: Unable to find the ftp daemon: ${BINDIR}/${FTPD}." # echo "Continuing anyway." #fi if test -f ${BINDIR}/${ASERVER} then ${BINDIR}/${ASERVER} ${APORT} >> ${LOGDIR}/${ALOG} 2> ${LOGDIR}/${AERR} & else echo "$0: Unable to find the address server: ${BINDIR}/${ASERVER}." echo "Continuing anyway." fi if test -f ${BINDIR}/${DRIVER} then echo "Found driver" else echo "No driver" fi if test -f ${BINDIR}/${DRIVER} then while : do echo -n "Driver came up: " >> ${LOGDIR}/${UP} date >> ${LOGDIR}/${UP} ${BINDIR}/${DRIVER} ${CONFIG} > ${LOGDIR}/${LOG} 2> ${LOGDIR}/${ERR} ERROR=$? echo -n "Driver went down (exit code: ${ERROR}): " >> ${LOGDIR}/${UP} date >> ${LOGDIR}/${UP} rm -f ${LOGDIR}/${LOG}.old mv ${LOGDIR}/${LOG} ${LOGDIR}/${LOG}.old rm -f ${LOGDIR}/${ERR}.old mv ${LOGDIR}/${ERR} ${LOGDIR}/${ERR}.old if test $ERROR -eq 255 then echo "Driver exited with -1. Halting." >> ${LOGDIR}/${UP} echo "Halting" exit 255 fi test -f ${BINDIR}/${DRIVER} || exit 1 done else echo "$0: Unable to find the gamedriver executable: ${BINDIR}/${DRIVER}" echo "Halting." fi