#!/bin/sh
#
# Because this stuff is still pretty young, you may wish to run the
# server using this script.  It'll notify if the server crashes and
# restart it after a couple of minutes.  It also puts the core in a known
# place and mails you any output generated by the terminal process.
#
# run it as  'run_daemon msqld' to run the mSQL engine.
#
#					bambi@Bond.edu.au

INST_DIR=/usr/local/coda/2.0dev/common/rcdb
MSQL_HOME=/usr/local/coda/2.0dev/common/rcdb
export MSQL_HOME
# Change the address below to your e-mail address and uncomment 
# the two mail lines below if you want.
ADMIN="noone@nowhere.gov"
PROG=$1

if test ! -d "${INST_DIR}/debug"
then
	mkdir ${INST_DIR}/debug
fi

echo "Program : ${PROG}
Started by : `/usr/ucb/whoami`
Start Time : `date`
" > msql_log.tmp
#	/usr/ucb/mail -s "Minerva Daemon Started" ${ADMIN} < msql_log.tmp
while :
do
	cd ${INST_DIR}/debug
	${PROG} > output 2>&1
	echo "Program : ${PROG}
Time : `date`
Program Output
--------------

" > msql_log.tmp
	cat output >> msql_log.tmp
#	/usr/ucb/mail -s "Minerva Daemon Crash Report" ${ADMIN} < msql_log.tmp
# If you are sending mail then
# you might want to change this depending on how much mail you like to get ;-)
# How long to sleep between attempts to start msqld...
	sleep 15
done
