# (c) Copyright	Empress Software Inc.	1983, 2000

. $INSTUTIL_DIR/echon.sh
. $INSTUTIL_DIR/shrc.sh
. $INSTUTIL_DIR/pkg.sh
. $INSTUTIL_DIR/msg.sh
. $INSTUTIL_DIR/utils.sh
. $INSTUTIL_DIR/licutil.sh
. $INSTUTIL_DIR/instpath.sh
. $INSTUTIL_DIR/usrinput.sh
. $INSTUTIL_DIR/agreelic.sh

# clean up temporary files from previous installation if any.
rm -fr $TMPDIR/empinstl_t.* 2> /dev/null

EMPRESSPATH=$TMPDIR/empinstl_t.$$
export EMPRESSPATH

mkdir $EMPRESSPATH

if test ! -d $EMPRESSPATH
then
	echo "$MSG_CANNOT_CREAT_DIR '$EMPRESSPATH'"
	exit 1
fi

. $INSTUTIL_DIR/pkgvar.sh

. $INSTUTIL_DIR/inst_c.sh

##################################################################
#	get installation key
##################################################################

clear_screen


if test "$MS_INSTALL" != "netscape"
then
	if agree_licence
	then
		:
	else
		installation_cleanup
		exit 0
	fi
fi

echo_message "$MSG_INSTALL_BANNER"

MKMSGDB=X
export MKMSGDB
RETRY=
LICFILE=$EMPRESSPATH/config/initfile

LIC_STRING=`$EMPRESSPATH/empinstl/instbin/inst $LICFILE`

if test "$?" != "0"
then
	installation_cleanup
	exit 1
fi

EVALUATION=`licutil_licenced_product evaluation`
shrc_check_login_shell

if test "$EVALUATION" = "yes"
then
	instpath_check_install_dir || instpath_ask_installation_path
else
	usrinput_ask_default_installation && usrinput_ask_customize_options
	instpath_ask_installation_path
	usrinput_ask_extra_question
fi

while :
do
	usrinput_last_confirmation && break
	usrinput_ask_default_installation && usrinput_ask_customize_options
	instpath_ask_installation_path
	usrinput_ask_extra_question
done

INSTLOG=$EMPRESSPATH/install.log-`date "+%Y-%m-%d-%T"`

date > $INSTLOG
echo_message "$MSG_INFO_BEGIN_INSTALLATION"

instpath_cleanup_install_path 2>&1 | tee -a $INSTLOG
pkg_unpack_all_packages 2>&1 | tee -a $INSTLOG
pkg_config_all_packages
shrc_update_startup_file 2>&1 | tee -a $INSTLOG

mkdir -p $INSTALL_DIR/empinstl
cd $INSTALL_DIR
ls -lR > empinstl/ls_lR

hit_enter_to_continue

shrc_inform_setup_empress | tee -a $INSTLOG
echo_message "$MSG_INFO_INSTALLATION_COMPLETE" $INSTALL_DIR | tee -a $INSTLOG

date >> $INSTLOG

cp $INSTLOG $INSTALL_DIR/empinstl
rm -fr $INSTALL_DIR/empinstl/install.log
X=`$INSTALL_DIR/common/sys_bin/basename $INSTLOG`
ln -s $X $INSTALL_DIR/empinstl/install.log

cd

test "$INSTALL_EMPRESSPATH" = "" || echo $INSTALL_DIR > $INSTALL_EMPRESSPATH
hit_enter_to_continue

installation_cleanup

exit 0
