#!/bin/sh
# Copyright (C) 2003,2004 SpeedSix Software Ltd.
#
# INSTALL_S6 - Friendly interface to Monsters Installation.
# =========================================================
#
# 24-FEB-2003  V0.0  SpeedSix Installation Procedure
# 16-FEB-2003  V0.1  Modified version for Linux and Burn
# 27-JUN-2003  V0.2  Linux Burn beta (276)
# 30-JUN-2003  V0.3  Linux Burn beta (281)
# 27-FEB-2004  V0.4  Linux Burn (283)
# 08-MAR-2004  V0.5  Linux Burn for Burn V1.5 (300)
# 16-MAR-2004  V0.6  Modified for Smoke on Linux
# 17-MAR-2004  V0.7  Remembered to add help stuff (sigh)
# 19-APR-2004  V0.8  Linux Smoke for Smoke on Linux V6.0 (101)
# 21-DEC-2004  V1.0  Linux Advanced Systems on Linux Release (200)
# 02-JUN-2005  V1.1  Linux Advanced Systems on Linux Release (500)
# 06-JUN-2006  V1.2  Using JawsService kit and UCAPI Jaws / Typo.

#
# start
#

echo
echo "Installing SpeedSix Monsters V5.0 for Discreet Advanced Systems on Linux"
echo "========================================================================"
echo "      Please consult the release notes for more information."
echo

#
# Ensure we are now root
#

if [ "`whoami`" != "root" ]; then
        echo "You need to be root to run this script. You can become root"
        echo "by using the command su. Please do this, then restart the"
        echo "installation with ./install_s6"
        exit 1
fi

#
# With RH 8, we used to check that e2fsprogs was installed, and if not, install it.
# It wasn't installed by default. I am going to assume that it IS now with
# RHELWS 3. It seems to be: Version = e2fsprogs-1.32-15
#
#
#E2FSPROGS=`rpm -q e2fsprogs`
#if [ "$E2FSPROGS" != "e2fsprogs-1.27-9" ]; then
#rpm -Uvh ./e2fsprogs-1.27-9.i386.rpm
#fi
#

#
# We used to check this is the right OS - well, kernel version, anyway!
# We won't do this is this release.
#

#OSNAME=`uname -r`
#if [ "$OSNAME" != "2.4.21-4.ELsmp" ]; then
#        echo "This software is only for installation on a machine running"
#	echo "Red Hat Enterprise Linux Workstation 3.0 with kernel version"
#	echo "2.4.21-4.ELsmp"
#	echo "This machine is running: $OSNAME"
#	echo "Sorry - I cannot continue."
#	exit 1
#fi

#
# Make sure they have seen the eula and agreed to its terms etc
#

echo
echo "Please read the SpeedSix End User License Agreement before installation."
echo
echo -n "Ready to read the agreement? [y or n] > "
read inp
case $inp in
    y*) break;;
    *) echo "OK ... exiting ... "; exit 1;;
esac
echo
more ./speedsix_eula
echo 
echo "=== END OF THE LICENSE AGREEMENT ========================="
echo
echo -n "Do you agree? [y or n] > "
read inp
case $inp in
    y*) break;;
    *) echo "OK ... exiting ... "; exit 1;;
esac
echo

#
# Circumvent yet another possible fly in the ointment.
# It would be *funny* if it were not so *painful*.
# Oh yeah - and this is sh not csh, so it gets worse...
# Because if these happen NOT to be defined you get ugly messages.
# Unix never misses an opportunity to castigate you.
#

unalias cp >& /dev/null
unalias rm >& /dev/null
unalias mv >& /dev/null

#
# Silently un-install our previous version
#

rpm -ev s6smokelinuxbase 2> /dev/null
# rpm -ev smokelinuxmonsters 2> /dev/null # Leave the plugins there ... 
rpm -ev smokelinuxmonstersdata 2> /dev/null
rpm -ev smokelinuxmonstershelp 2> /dev/null

#
# Install our stuff
#

./instaid
rpm -Uvh --force ./discreetlinuxbase-5.0-706.i386.rpm
rpm -Uvh --force ./discreetlinuxmonsters-5.0-706.i386.rpm
rpm -Uvh --force ./discreetlinuxmonstersdata-5.0-706.i386.rpm
rpm -Uvh --force ./discreetlinuxmonstershelp-5.0-706.i386.rpm
rpm -Uvh --force ./discreetlinuxmonstersprxy-5.0-706.i386.rpm
cp ./uninstall_s6_linux /usr/local/SpeedSix/dl/bin
cp ./helpmonsters /usr/local/SpeedSix/dl/bin

#
# Install the Jaws kit
#

echo "Installing Jaws PostScript interpreter and JawsService server ..."
tar xzf ./LinuxJawsServiceKit.tar.gz
cd LinuxJawsServiceKit
./install_s6
cd ..

#
# Check licenses & copy the appropriate proxy image...
#

rm -f /usr/discreet/sparks/SpeedSix_V5.0/*.p
/usr/local/SpeedSix/dl/bin/CHECK_LICENSE 2> /dev/null
chmod a+w /usr/discreet/sparks/SpeedSix_V5.0/*.p

#
# Finished
#

echo
echo "Installation completed."
exit 0
