#!/bin/sh
#
# INSTALL_LICENSE_5D - Friendly interface to FlexLM licensing.
# ============================================================
#
# 29-SEP-1998  V0.0  Introduced to make double clicking in fm not screw up.
# 30-NOV-1998  V0.1  Jaleo version.

#
# Check the expected license directory actually exists.
#

if [ "${DIR_5D}" = "" ]; then
	DIR_5D=/usr/local/5D
fi

if [ ! -d ${DIR_5D}/jaleo/licenses ]; then
        xconfirm -c \
        -header "Error" \
        -icon error \
        -t "${DIR_5D}/jaleo/licenses does not exist!" \
        -t "This is probably because 5D Monsters for Discreet Logic" \
        -t "have not been installed correctly on this machine." \
	-t "I am giving up!" \
        -B "OK"
        exit 1
fi

#
# Ensure we are now root
#

if [ "`whoami`" != "root" ]; then
        xconfirm -c \
        -header "Error" \
        -icon error \
        -t "You need to be root to run this script. You can become root" \
        -t "by using the command su. Please do this, then restart the" \
        -t "script, which is called:" \
	-t "/usr/local/5D/bin/INSTALL_LICENSE_5D" \
        -B "OK"
        exit 1
fi

#
# Spawn a pseudo TTY and run install_license_5d.sh in it.
# This does all the hard work...
#


xwsh -title "5D Monster Licensing" -icontitle "5DLicense" \
	 -e /usr/local/5D/jaleo/bin/install_license_5D.sh

#
# Finished...
#

case `xconfirm -c \
        -header "View License File" \
        -icon question \
	-t "You can run this script again whenever you wish." \
	-t "It is called:" \
	-t "/usr/local/5D/jaleo/bin/INSTALL_LICENSE_5D" \
	-t " " \
	-t "Do you wish to view the updated license file?" \
        -B "Yes" -b "No"`
        in
        Yes) jot /usr/local/5D/jaleo/licenses/5D_licenses.dat;;
        No)  echo "... Goodbye ...";;
esac
