#!/bin/sh
#
# script to start up LambdaMoo.
# By Joey Hess <joeyh@master.debian.org>
#
# Params are: 
# 1. database file
# 2. port to listen at
# 3. logfile

test -x /usr/sbin/lambdamoo || exit 1

cd `dirname $1`
if [ ! -r $1 ]; then
	echo "Unknown database: $1"
	exit 1
fi
if [ -r $1.new ]; then
	mv $1 $1.old
	mv $1.new $1
	rm -f $1.old.gz
	gzip $1.old &
fi

touch $3
echo `date`: STARTED >> $3
nohup /usr/sbin/lambdamoo $1 $1.new $2 >> $3 2>&1 &
