#! /bin/sh
# Executed the IDL-based Exelis license wizard.
#

if [ "$IDL_DIR" = "" ]; then
    IDL_DIR=/usr/local/exelis/idl85
    export IDL_DIR
fi

IDL_DEVICE=X
export IDL_DEVICE

if [ ! -f $IDL_DIR/lib/hook/license_wizard.sav ]; then
   echo "	The License wizard has not been installed.  Please consult the
	installation guide for instructions on installing the Program Files."
   exit 0
fi

# Define an environment variable to cache the real value of HOME
# so that the exelislicense app can set HOME to this after IDL initialization
# This is needed because we will be setting HOME to a temporary location
# for IDL initialization to prevent creation of the user's .idl directory.
LICENSEWIZARD_HOMEREAL=$HOME
export LICENSEWIZARD_HOMEREAL


# Define a temporary home dir so that the IDL session running
# license_wizard creates a temporary .idl directory instead of the
# user's actual .idl directory. This is necessary since the user
# installing IDL may have used sudo to get root permission, but
# running IDL later without root permission would not be able to
# access the .idl directory created by the session invoked with sudo.
LICENSEWIZARD_HOMETMP=$HOME/.license_wizard_tmp
HOME=$LICENSEWIZARD_HOMETMP
export HOME
 
$IDL_DIR/bin/idl $* -em=$IDL_DIR/lib/hook/license_wizard.sav
 
rm -r $LICENSEWIZARD_HOMETMP
