#!/bin/csh -f
# by Cygnus
# cygnus@misty.com
#

setenv CONFIG $1
setenv BOTON 1

# Link changes helpfile to CHANGES file in lib directory
echo "Linking changes..."
pushd helpfiles
rm -f changes
ln -s ../lib/CHANGES changes

# Run TOP in helpfiles directory to update topics helpfile
echo -n "Updating helpfiles list..."
./TOP
popd

#  This next part copies over the lastcommand and syslog file to a backup,
# so that when the talker restarts, whatever command crashed the talker
# isn't lost. SOMEONE was rebooting the talker after a crash without
# reading the lastcommand file to see what screwed it up (not mentioning
# any names) JOELIE!

	if (-e syslog) then
         echo "Coping system logs to backup file..."
	 cp syslog syslog.`/bin/date '+%m%d%y.%T'`
	 rm syslog
         touch syslog
	else

	endif

	if (-e lastcommand) then
         echo "Coping lastcommand file to backup file..."
	 cp lastcommand lastcommand.`/bin/date '+%m%d%y.%T'`
	else

	endif

	if (-e lib/lastlogs) then
         echo "Removing old lastlogs..."
         rm lib/lastlogs
         touch lib/lastlogs
         rm junk/*
	else

	endif

echo "Starting the talker server..."
echo ""
./server $CONFIG

# Uncomment these next lines if you want this script to start the robot
#	if ($BOTON != 0) then
#	 pushd bot
#	 ./restart
#	 popd
#	else
#
#	endif

