$NetBSD: patch-ab,v 1.1.1.1 2002/05/26 00:21:43 rh Exp $ --- restart.sh.orig Mon Mar 3 13:45:05 1997 +++ restart.sh @@ -16,28 +16,47 @@ # Pavel@Xerox.Com +compressor=gzip +suffix=gz +save_old_database=no + if [ $# -lt 1 -o $# -gt 2 ]; then - echo 'Usage: restart dbase-prefix [port]' + echo 'Usage: restart.sh dbase-prefix [port]' + echo 'examples:' + for i in "__PREFIX__/share/lambdamoo/"*.db + do + echo " restart.sh $(basename $i .db)" + done exit 1 fi -if [ ! -r $1.db ]; then - echo "Unknown database: $1.db" +if [ "$(basename $1)" = "$1" ]; then + arg1="__PREFIX__/share/lambdamoo/$1" +else + arg1="$1"; +fi + +if [ ! -r $arg1.db ]; then + echo "Unknown database: $arg1.db" exit 1 fi -if [ -r $1.db.new ]; then - mv $1.db $1.db.old - mv $1.db.new $1.db - rm -f $1.db.old.Z - compress $1.db.old & +if [ -r $arg1.db.new ]; then + mv $arg1.db $arg1.db.old + mv $arg1.db.new $arg1.db + if [ "$save_old_database" = "yes" ]; then + mv $arg1.db.old.$suffix $arg1-$(date +%Y%m%d).$suffix + else + rm -f $arg1.db.old.$suffix + fi + $compressor $arg1.db.old & fi -if [ -f $1.log ]; then - cat $1.log >> $1.log.old - rm $1.log +if [ -f $arg1.log ]; then + cat $arg1.log >> $arg1.log.old + rm $arg1.log fi -echo `date`: RESTARTED >> $1.log -nohup ./moo $1.db $1.db.new $2 >> $1.log 2>&1 & +echo `date`: RESTARTED >> $arg1.log +nohup __PREFIX__/sbin/moo $arg1.db $arg1.db.new $2 >> $arg1.log 2>&1 & ###############################################################################