#!/sbin/sh

#################################################################################################
#
#	Copyright (c) 1999-2003 by Sun Microsystems, Inc. All Rights Reserved.
#	Copyright 1992-95 AT&T Global Information Solutions
#
# ident "@(#)lu.sh 5.5     03/01/29 SMI"
#
#################################################################################################

LU_PROG_FULL_PATH="$0"
LU_PROG_NAME="`basename ${LU_PROG_FULL_PATH}`"; export LU_PROG_NAME

# Dot the defaults file.

if [ ! -s /etc/default/lu ] ; then
  echo "${LU_PROG_NAME}: ""`gettext 'ERROR: Live Upgrade not installed properly (/etc/default/lu not found).'`"
  exit 1
fi
. /etc/default/lu

# Default global variables we expect to be set from /etc/default/lu.

LUBIN=${LUBIN:=/usr/lib/lu}
COPYLOCK=${COPYLOCK:=/etc/lu/COPY_LOCK}
NEXT_ACTIVE=${NEXT_ACTIVE:=/etc/lu/.NEXT_ACTIVE}
OBJ_DIR=${OBJ_DIR:=/usr/lib/lu/menu}

# Dot the Live Upgrade library functions.

if [ ! -s $LUBIN/lulib ] ; then
  echo "${LU_PROG_NAME}: ""`gettext 'ERROR: The Live Upgrade product is not installed properly (${LUBIN}/lulib not found).'`"
  exit 1
fi

. $LUBIN/lulib

# Add /usr/sadm/bin to the path so that any fmli scripts can access the system administrator tools.
# The rest of the path is expected to be properly set up by the /etc/default/lu file.
PATH=${PATH}:/usr/sadm/bin

# Default log file to write to.
LOGFILE=/etc/lu/lu.log

# Export all environment variables set here.
export LUBIN COPYLOCK LOGFILE OBJ_DIR PATH

# Validate and remove any stale copy lock.

lulib_validate_lulock

# Invoke the FMLI user interface.

if [ ! -s "${LUBIN}/menu/lu.init" ] ; then
  echo "${LU_PROG_NAME}: ""`gettext 'ERROR: The Live Upgrade product is not installed properly (${LUBIN}/menu/lu.init not found).'`"
  exit 1
elif [ ! -s "${LUBIN}/menu/Menu.lu" ] ; then
  echo "${LU_PROG_NAME}: ""`gettext 'ERROR: The Live Upgrade product is not installed properly (${LUBIN}/menu/Menu.lu not found).'`"
elif [ ! -s "/usr/bin/fmli" -o ! -x "/usr/bin/fmli" ] ; then
  echo "${LU_PROG_NAME}: ""`gettext 'ERROR: The Live Upgrade product is unable to find a required system component (/usr/bin/fmli not found).'`"
fi

# Setup the text domain from which all localized messages are retrieved for the FMLI interface.
# Up until now the text domain is set by lulib.sh to the messages for all scripts. The FMLI interface
# has its own text domain. If the FMLI interface invokes any live upgrade scripts or executables,
# they will change the text domain as necessary.

TEXTDOMAIN="SUNW_INSTALL_LU_MENU" /usr/bin/fmli -i /usr/lib/lu/menu/lu.init /usr/lib/lu/menu/Menu.lu

exit 0
