From 3e0250a99bf3ddce0f9501cb7b231ecf6c90574a Mon Sep 17 00:00:00 2001 From: Rick L Bird Date: Sun, 8 May 2011 17:47:11 -0400 Subject: [PATCH] Updated restart script.. mush starts without --no-session now and it loads the right database as well. Fixes #262 --- game/restart.dst | 100 ++++++++++++--------------------------------- utils/customize.pl | 2 +- 2 files changed, 28 insertions(+), 74 deletions(-) diff --git a/game/restart.dst b/game/restart.dst index 64b9b3e..b85b04a 100644 --- a/game/restart.dst +++ b/game/restart.dst @@ -1,45 +1,22 @@ #!/bin/sh # - # usage: restart +# +# REQUIRED: You must set this to the path to your game directory. +# E.g.: /home/mush/game +GAMEDIR=`pwd` -#-- options - -# If this doesn't work, you can set GAMEDIR to the directory this -# script lives in by hand. -GAMEDIR=`which $0 | sed 's/\/[^\/]*$//'` - -# The config file -CONF_FILE=mush.cnf +# OPTIONAL things that you may want to tweak. -# The error log file -LOG=log/netmush.log +# Name of file to write the game's process id to. Used by restart to +# check for an already running game. +PIDFILE=netmush.pid # Uncomment the line below to attempt to allow crashes to produce # core dumps. If you're getting crashes, this is the best way # to debug them. #ulimit -c unlimited - -# Uncomment the line below to attempt to allow crashes to produce -# core dumps. If you're getting crashes, this is the best way -# to debug them. -#ulimit -c unlimited - -if [ ! -d "$GAMEDIR" ]; then - echo "GAMEDIR doesn't appear to be a directory. It's: $GAMEDIR" - exit 1 -fi - -cd $GAMEDIR -echo Running from `pwd` - -if [ ! -f "$CONF_FILE" ]; then - echo "CONF_FILE doesn't exist. It's: $CONF_FILE" - echo "Create $CONF_FILE from $GAMEDIR/mushcnf.dst and run 'make update'" - exit 1 -fi - # Internationalization stuff # Set LANG here to get international character sets and, if someone's # done it, translation of messages. @@ -49,7 +26,7 @@ fi # Time zone stuff # If you want your MUSH to run in a different timezone than the one -# you're in, you need to identify the target time zone file in +# you're in, you need to identify the target time zone file in # /usr/share/zoneinfo or /usr/lib/zoneinfo. Then uncomment the next # two lines and set TZ to the desired timezone file, as shown, with # an initial colon: @@ -76,35 +53,9 @@ fi cd $GAMEDIR echo Running from `pwd` -if [ ! -f $CONF_FILE ]; then - echo "CONF_FILE doesn't exist. It's: $CONF_FILE" - echo "Create $CONF_FILE from $GAMEDIR/mushcnf.dst" - exit 1 -fi - - -# The config file. Best to keep this as is. If you must change -# the name, make it a link to mush.cnf. -CONF_FILE=mush.cnf - -####################################################################### - -if [ -z $GAMEDIR ]; then - echo "You must set GAMEDIR in the restart script." - exit 1 -fi - -if [ ! -d $GAMEDIR ]; then - echo "GAMEDIR doesn't appear to be a directory. It's: $GAMEDIR" - exit 1 -fi - -cd $GAMEDIR -echo Running from `pwd` - -if [ ! -f $CONF_FILE ]; then +if [ ! -f "$CONF_FILE" ]; then echo "CONF_FILE doesn't exist. It's: $CONF_FILE" - echo "Create $CONF_FILE from $GAMEDIR/mushcnf.dst" + echo "Create $CONF_FILE from $GAMEDIR/mushcnf.dst and run 'make update'" exit 1 fi @@ -113,7 +64,7 @@ fi if [ ! -e netmush ]; then echo "I don't see $GAMEDIR/netmush. Did you remember to make install?" exit 1 -fi +fi # # Read the cnf file and set some variables. @@ -132,15 +83,25 @@ if [ "$nocompress" -eq 0 ]; then COMPRESSOR=`egrep "^compress_program" $CONF_FILE | sed "s/[^[:space:]]*[[:space:]]*\(.*\)/\1/" | sed 's/\r$//'` SUFFIX=`egrep "^compress_suffix" $CONF_FILE | sed "s/[^[:space:]]*[[:space:]]*\(.*\)/\1/" | sed 's/\r$//'` fi - + #-- start up everything # Prevent double-starting things. You may need to provide a pathname for # some of the commands. System V flavors need "ps -f" instead of "ps uwx". -mush=`ps uwwx | grep " $GAMEDIR/$CONF_FILE" | grep -v grep | wc -l` +# Old style, look for a program using the config file. +#mush=`ps uwwx | grep " $GAMEDIR/$CONF_FILE" | grep -v grep | wc -l` +# if [ "$mush" -gt 0 ]; then -if [ "$mush" -gt 0 ]; then +# New style, look for a pid file. +if [ -f $PIDFILE ]; then + foo=`kill -0 \`cat $PIDFILE\` 2>/dev/null` + mush=$? +else + mush=1; +fi + +if [ "$mush" -eq 0 ]; then echo Mush already active or some other process is using $GAMEDIR/$CONF_FILE. exit 0 fi @@ -169,15 +130,6 @@ for log in log/*.log; do BASE=`basename $log` mv -f $log save/$BASE.$TIMESTAMP done - - -# Copy the latest core or netmud.core to save/ -if [ -r "core" ]; then - cp core save/ -fi -if [ -r "netmud.core" ]; then - cp netmud.core save/ -fi if [ -r "data/$OUTDB$SUFFIX" ]; then ln -f data/$INDB$SUFFIX save/$INDB$SUFFIX.old @@ -205,4 +157,6 @@ fi DATEMSK="${GAMEDIR}/getdate.template" export DATEMSK +export GAMEDIR + LC_ALL=$LANG LANG=$LANG ./netmush $@ --pid-file=$PIDFILE $GAMEDIR/$CONF_FILE & diff --git a/utils/customize.pl b/utils/customize.pl index 628b105..44fee96 100755 --- a/utils/customize.pl +++ b/utils/customize.pl @@ -11,7 +11,7 @@ # to .restart and mush.cnf (which it calls .cnf) to # make it easier to keep track of multiple MUSHes. # -# $Id: customize.pl,v 1.1.1.1 2004-06-06 20:32:51 ari Exp $ +# $Id: customize.pl 1.2 Tue, 09 Jan 2001 17:56:37 -0600 dunemush $ # $tar1="(cd game; tar cf - .) | (cd "; -- 2.30.2