#!/ibin/sh
#******************************************************************************
#	by Ronald Joe Record (rr@caldera.com) 23-Jan-2002
#-----------------------------------------------------------------------------
#       input:
#           $1 is the name of the step
#           $2 is the keyword list (e.g. UPGRADE)
#           $3 is the package list
#=============================================================================

# Read arguments into variables
scriptname="$0"
keywords="$1"
pkglist="$2"

# Source in the standard functions library, ccsSetup.sh
. /ibin/ccsSetup.sh

# Set global variables that may be used elsehere in this script

CNTLDIR=${SSO_SHARED_ROOT}/cntl

# some messages

old_upgrade=
sso_upgrade=
iqm_file_exists=
local_client=
true_client=
customMode=LAYERED
for word in $keywords
do
    case "$word" in 
        OLD_CUSTOM_UPGRADE) old_upgrade=TRUE
                 ;;
	UPGRADE)            sso_upgrade=TRUE
		;;
	IQM_SAVE)	    iqm_file_exists=TRUE
                	    customMode="IQM"
		;;
	FOR_LOCAL_CLIENT)   local_client=TRUE
		;;
	TRUE_CLIENT_ROOT)   true_client=TRUE
		;;
    esac
done

# Set the appropriate NLSPATH to enable the 'dspmsg' utility to work later
# in this script.  

NLSPATH="${SSO_SHARED_ROOT}/cntl/msg/%L/%N.cat":"${NLSPATH}"
export NLSPATH

#******************************************************************************
#  cleanup --
#
#    cleanup exits the package script with the passed argument
#
#******************************************************************************

cleanup() {
        exit $1
}

#=============================================================================
#
# getyn
#
# Prompt for yes or no answer - returns non-zero for no
#
# Usage: getyn "question"
# Argument is a quoted question
# Notes: getyn returns 0 if the answer is y or Y
#        and 1 if the answer is n or N
#        and 2 if the answer is q or Q
#=============================================================================
getyn() {
        while   echo "$* (y/n/q) \c"
        do      read yn rest
                case $yn in
                [yY])   return 0                                ;;
                [nN])   return 1                                ;;
                [qQ])   return 2                                ;;
                *)      echo "Please Make a selection\n"          ;;
                esac
        done
}

#====================================================================== INT ===
#  main --
#   
#------------------------------------------------------------------------------
#
# Test for perl and libz
#

PERL=
LIBZ=
BASH=
PERL_MSG="Perl is required by vncserver. It appears Perl is not installed. A custom installable version is available at ftp://ftp2.caldera.com/pub/skunkware/osr5/vols/"
LIBZ_MSG="The Glib package is required by Xvnc. It appears Glib is not installed. A custom installable version is available at ftp://ftp2.caldera.com/pub/skunkware/osr5/vols/"
BASH_MSG="Bash is required by vncserver. It appears Bash is not installed. A custom installable version is available at ftp://ftp2.caldera.com/pub/skunkware/osr5/vols/"

[ -e /usr/local/bin/perl ] && PERL=1
[ -e /usr/local/lib/libz.so ] && LIBZ=1
[ -e /bin/bash ] && BASH=1

if [ "${BASH}" ]
then
	continue
else
	ccsWarning "${BASH_MSG}"
	getyn "\nDo you wish to proceed with the installation? "
	
	if [ $? -eq 0 ]
	then
		continue
	else
		exit ${FAIL}
	fi
fi

if [ "${PERL}" ]
then
	continue
else
	ccsWarning "${PERL_MSG}"
	getyn "\nDo you wish to proceed with the installation? "
	
	if [ $? -eq 0 ]
	then
		continue
	else
		exit ${FAIL}
	fi
fi
if [ "${LIBZ}" ]
then
	continue
else
	ccsWarning "${LIBZ_MSG}"
	getyn "\nDo you wish to proceed with the installation? "
	
	if [ $? -eq 0 ]
	then
		continue
	else
		exit ${FAIL}
	fi
fi

# the exit value from this script

cqs_return_value=0

exit $cqs_return_value
