#!/ibin/sh
#******************************************************************************
#                      OpenSSL runtime pkg script
#-----------------------------------------------------------------------------
#  The package-level install script for the OpenSSL Runtime Package
#-----------------------------------------------------------------------------
#
#       Copyright (C) 2001 Caldera, Inc.
#               All Rights Reserved.
#
#       The information in this file is provided for the exclusive use of
#       the licensees of Caldera, Inc.  Such users have the right to use,
#       modify, and incorporate this code into other products for
#       purposes authorized by the license agreement provided they include
#       this notice and the associated copyright notice with any such product.
#       The information in this file is provided "AS IS" without warranty.
#
#-----------------------------------------------------------------------------
#       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"
step="$1"
keywords="$2"
pkglist="$3"

CNTLDIR="${SSO_SHARED_ROOT}"/cntl
LOGFILE=/var/tmp/OpenSSL.log

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

[ -n "$debug" ] && echo "$scriptname $step \"$keywords\" $pkglist" >> $LOGFILE

# Check $IQM_FILE to determine how custom was invoked and the installation
# type. If IQM_FILE exists, source it in
#
customMode=LAYERED
[ "$IQM_FILE" ] && {
                # Invoking custom from the IQM.  IQM output will be stored
                # in $IQM_FILE.
                customMode="IQM"
                . $IQM_FILE
}

export customMode IQM_FILE

# Set global variables indicating whether this is an upgrade or removal.

sso_upgrade=
old_upgrade=
for word in $keywords
do
    case "$word" in 
        UPGRADE) sso_upgrade=TRUE
                 ;;
        OLD_CUSTOM_UPGRADE) old_upgrade=TRUE
                 ;;
    esac
done

# get data from cqs
if [ -f "${CCS_PERSISTENT_STORAGE}/config_info" ]; then
    . "${CCS_PERSISTENT_STORAGE}/config_info"
fi

#=========================================================================
#  doPreLoad
#
#    Before the copy of the component from the media to the hard disk in
#    the /opt hierarchy. The files in /opt remain read-only.
#
#    Only the files in the SharedControl package of the component are
#    loaded on the target.
#
#    NOTE: You can legally load a component onto a system on which the
#    component cannot run; for example, the administrator might want to
#    load the component on a server and ATTACH it to network clients
#    without attaching it to the server. 
#
#=========================================================================

doPreLoad()
{
	[ -n "$debug" ] && echo "Entering doPreLoad" >> $LOGFILE
	[ -n "$debug" ] && echo "Leaving doPreLoad" >> $LOGFILE
}

#=========================================================================
#  doPostLoad
#
#    After the copy of the component from the media to the hard disk in
#    the /opt hierarchy. The files in /opt remain read-only.
#
#=========================================================================

doPostLoad()
{
	[ -n "$debug" ] && echo "Entering doPostLoad" >> $LOGFILE
	[ -n "$debug" ] && echo "Leaving doPostLoad" >> $LOGFILE
}

#=========================================================================
#  doPreUnLoad
#
#    During the UNLOAD phase, custom(ADM) removes the /opt portion of
#    the component's SSO.
#
#=========================================================================

doPreUnLoad()
{
	[ -n "$debug" ] && echo "Entering doPreUnLoad" >> $LOGFILE
	[ -n "$debug" ] && echo "Leaving doPreUnLoad" >> $LOGFILE
}

#=========================================================================
#  doPostUnLoad
#
#    The only files that remain after a full removal are the files in
#    the component's control package (the files in the SSOroot/cntl
#    directory).
#
#=========================================================================

doPostUnLoad()
{
	[ -n "$debug" ] && echo "Entering doPostUnLoad" >> $LOGFILE
	[ -n "$debug" ] && echo "Leaving doPostUnLoad" >> $LOGFILE
}

#=========================================================================
#  doPreAttach
#
#    During the ATTACH phase, custom creates and initializes the per-client
#    portion of the SSO, the /var/opt portion of the SSO. ATTACH copies the
#    non-shared files and establishes the client contents database.
#
#    The software management tools use the database to track, checksum, and
#    perform other per-client file management. 
#
#    The ccs should perform all internal configuration (configuration that
#    can be accomplished by manipulating files within the SSO or, in the
#    case of an upgrade, using configuration parameters from the previous
#    version.
#
#    The ccs should check for version compatibility. If it is not valid to
#    install the component on the client, the ccs should return an exit code
#    of 1 (FAIL).
#
#=========================================================================

doPreAttach()
{
	[ -n "$debug" ] && echo "Entering doPreAttach" >> $LOGFILE
	[ -n "$debug" ] && echo "Leaving doPreAttach" >> $LOGFILE
}

#=========================================================================
#  doPostAttach
#
#    If either the OLD_CUSTOM_UPGRADE or UPGRADE keyword is specified, the
#    ccs should merge old configuration data from the $CCS_PERSISTENT_STORAGE
#    directory into the new files. 
#
#    Once the data has been restored, the ccs should perform any specified
#    configuration using parameters gathered from the cqs. Only files in the
#    /var/opt area can be modified. 
#
#=========================================================================

doPostAttach()
{
	[ -n "$debug" ] && echo "Entering doPreLoad" >> $LOGFILE
	[ -n "$debug" ] && echo "Leaving doPreLoad" >> $LOGFILE
}

#=========================================================================
#  doPreUnAttach
#
#    During the UNATTACH phase, the ccs removes the /var/opt portion of
#    the SSO.
#
#=========================================================================

doPreUnAttach()
{
	[ -n "$debug" ] && echo "Entering doPreUnAttach" >> $LOGFILE
	[ -n "$debug" ] && echo "Leaving doPreUnAttach" >> $LOGFILE
}

#=========================================================================
#  doPostUnAttach
#=========================================================================

doPostUnAttach()
{
	[ -n "$debug" ] && echo "Entering doPostUnAttach" >> $LOGFILE
	[ -n "$debug" ] && echo "Leaving doPostUnAttach" >> $LOGFILE
}

#=========================================================================
#  doPreRegister
#
#    For components that provide system services, the ccs makes the
#    component's system services available to other components during the
#    REGISTER phase.
#
#    custom performs an ``early export'' of files or interfaces that are
#    involved in providing a system service. These files are marked in the
#    CDMT input files by the exportPathRegPhase attribute.
#    See cdmtInput(CDMT). 
#
#=========================================================================

doPreRegister()
{
	[ -n "$debug" ] && echo "Entering doPreRegister" >> $LOGFILE
	[ -n "$debug" ] && echo "Leaving doPreRegister" >> $LOGFILE
}

#=========================================================================
#  doPostRegister
#=========================================================================

doPostRegister()
{
	[ -n "$debug" ] && echo "Entering doPostRegister" >> $LOGFILE
	[ -n "$debug" ] && echo "Leaving doPostRegister" >> $LOGFILE
}

#=========================================================================
#  doPreUnRegister
#
#    For components that provide system services, the ccs removes those
#    services during the UNREGISTER phase.
#
#=========================================================================

doPreUnRegister()
{
	[ -n "$debug" ] && echo "Entering doPreUnRegister" >> $LOGFILE
	[ -n "$debug" ] && echo "Leaving doPreUnRegister" >> $LOGFILE
}

#=========================================================================
#  doPostUnRegister
#=========================================================================

doPostUnRegister()
{
	[ -n "$debug" ] && echo "Entering doPostUnRegister" >> $LOGFILE
	[ -n "$debug" ] && echo "Leaving doPostUnRegister" >> $LOGFILE
}

#=========================================================================
#  doPreConfigure
#
#    During the CONFIGURE phase, the ccs configures the component into any
#    system services that it consumes. For example, the component might add
#    a driver to the link kit using the idinstall(ADM) utility. 
#
#=========================================================================

doPreConfigure()
{
	[ -n "$debug" ] && echo "Entering doPreConfigure" >> $LOGFILE
	[ -n "$debug" ] && echo "Leaving doPreConfigure" >> $LOGFILE
}

#=========================================================================
#  doPostConfigure
#
#    The ccs performs any remaining configuration that relied upon actions
#    taken in the PRE_CONFIGURE and system step.
#
#=========================================================================

doPostConfigure()
{
	[ -n "$debug" ] && echo "Entering doPostConfigure" >> $LOGFILE
	[ -n "$debug" ] && echo "Leaving doPostConfigure" >> $LOGFILE
}

#=========================================================================
#  doPreUnConfigure
#
#    During the UNCONFIGURE phase, the ccs removes the component from any
#    system services that it consumes. For example, remove kernel device
#    drivers using a call to idinstall(ADM). 
#
#=========================================================================

doPreUnConfigure()
{
	[ -n "$debug" ] && echo "Entering doPreUnConfigure" >> $LOGFILE
	[ -n "$debug" ] && echo "Leaving doPreUnConfigure" >> $LOGFILE
}

#=========================================================================
#  doPostUnConfigure
#=========================================================================

doPostUnConfigure()
{
	[ -n "$debug" ] && echo "Entering doPostUnConfigure" >> $LOGFILE
	[ -n "$debug" ] && echo "Leaving doPostUnConfigure" >> $LOGFILE
}

#=========================================================================
#  doPreExport
#
#    During the EXPORT phase, the ccs exports all remaining public
#    interfaces to the public space.
#
#    It makes the component's public files in /opt visible by
#    symbolic-linking them to external directories, such as
#    /usr/bin.
#
#=========================================================================

doPreExport()
{
	[ -n "$debug" ] && echo "Entering doPreExport" >> $LOGFILE
	[ -n "$debug" ] && echo "Leaving doPreExport" >> $LOGFILE
}

#=========================================================================
#  doPostExport
#=========================================================================

doPostExport()
{
	[ -n "$debug" ] && echo "Entering doPostExport" >> $LOGFILE
	[ -n "$debug" ] && echo "Leaving doPostExport" >> $LOGFILE
}

#=========================================================================
#  doPreUnExport
#=========================================================================

doPreUnExport()
{
	[ -n "$debug" ] && echo "Entering doPreUnExport" >> $LOGFILE
	[ -n "$debug" ] && echo "Leaving doPreUnExport" >> $LOGFILE
}

#=========================================================================
#  doPostUnExport
#=========================================================================

doPostUnExport()
{
	[ -n "$debug" ] && echo "Entering doPostUnExport" >> $LOGFILE
	[ -n "$debug" ] && echo "Leaving doPostUnExport" >> $LOGFILE
}

#====================================================================== INT ===
#  main --
#
#------------------------------------------------------------------------------


# the exit value from this script
ccs_return_value=0

# This must be a fresh install or upgrade
# These fns get called prior to running package-specific scripts.
case "$step" in
	PRE_LOAD) doPreLoad;;
	POST_LOAD) doPostLoad;;
	PRE_UNLOAD) doPreUnLoad;;
	POST_UNLOAD) doPostUnLoad;;
	PRE_ATTACH) doPreAttach;;
	POST_ATTACH) doPostAttach;;
	PRE_UNATTACH) doPreUnAttach;;
	POST_UNATTACH) doPostUnAttach;;
	PRE_REGISTER) doPreRegister;;
	POST_REGISTER) doPostRegister;;
	PRE_UNREGISTER) doPreUnRegister;;
	POST_UNREGISTER) doPostUnRegister;;
	PRE_CONFIGURE) doPreConfigure;;
	POST_CONFIGURE) doPostConfigure;;
	PRE_UNCONFIGURE) doPreUnConfigure;;
	POST_UNCONFIGURE) doPostUnConfigure;;
        PRE_EXPORT) doPreExport;;
        POST_EXPORT) doPostExport;;
        PRE_UNEXPORT) doPreUnExport;;
        POST_UNEXPORT) doPostUnExport;;
esac

[ -n "$debug" ] && echo "$0 exit $ccs_return_value" >> $LOGFILE
exit $ccs_return_value

