#!/bin/sh
#### Install script for Galatea on Project Athena Video Workstations

# Set the machine dependent executable directory
MACHBIN=`/bin/athena/machtype`bin;export MACHBIN
MACHETC=`/bin/athena/machtype`etc;export MACHETC

echo Remove old versions of /etc/galatead.conf /etc/galatead /tmp/rc.local
rm -f /etc/galatead.conf /etc/galatead /tmp/rc.local

echo -n Create a new rc.local which will start galatead on subsequent reboots...
cat /mit/video/install/etc/rc.athena > /tmp/rc.local
if [ -f /etc/rc.local ]; then
	cat /etc/rc.local >> /tmp/rc.local
else 
	touch /etc/rc.local
	chmod 644 /etc/rc.local
	echo exit 0 >> /tmp/rc.local
fi
cp /tmp/rc.local /etc/rc.local
echo done.

echo -n "Install the configuration file: "
echo /mit/video/install/$MACHETC/galatead.conf
cp /mit/video/install/$MACHETC/galatead.conf /etc
chmod 644 /etc/galatead.conf

echo -n "Install the server executable: "
echo /mit/video/install/$MACHBIN/galatead
cp /mit/video/install/$MACHBIN/galatead /etc
chmod 4755 /etc/galatead

if [ -f /etc/galatead.pid ]; then
  echo Kill off the old Galatea server: pid=`cat /etc/galatead.pid`
  kill `cat /etc/galatead.pid`
  echo Wait for 20 seconds for the old server to shutdown.
  sleep 20
fi

echo Start the server now, so a machine reboot is not needed.
/etc/galatead &

echo New server started.  Machine fully updated to Galatea 2.4
