#! /sbin/sh
########
# Product: Ignite-UX
# Fileset: RECOVERY
# configure
# @(#) $Revision: 10.11 $
########
#
# (c) Copyright Hewlett-Packard Company 1999
#
########################################################################

##########################################################################
# This script does the following:
#
# Creates the directory structure under /var/opt/ignite
# 
UTILS=/usr/lbin/sw/control_utils
if [ -f $UTILS ]
then
    . $UTILS
else
    echo "ERROR:   Cannot find $UTILS"
    exit 1
fi

if [[ -n $SW_DEFERRED_KERNBLD ]]
then
    echo "WARNING: Ignite-UX will not function from an NFS Diskless"
    echo "         client, although swlist(1M) will report the product"
    echo "         as installed."
    exit $WARNING
fi

result=$SUCCESS

INST_DIR=/opt/ignite
VAR_DIR=/var/opt/ignite
VAR_INDEX=$VAR_DIR/INDEX
REC_DEPOT=/var/opt/ignite/depots/recovery_cmds

# Copy the makrec.append file
SW_LOCATION=/opt/ignite/ newconfig_cp $VAR_DIR/recovery/makrec.append
SW_LOCATION=/opt/ignite/ newconfig_msgs $?

#
# Check to see if the OBAM-RUN fileset is required, and if so and
# it was not loaded, then give an error
#

case $(uname -r) in
*.10.00|*.10.01|*.10.10|*.10.20)
    # A new obam is needed on these releases.  If it was not loaded, then
    # complain.
    if [ ! -f $INST_DIR/obam.10/lib/libobam.1 ] ; then
        echo "\
ERROR:   The system does not appear to have the Ignite-UX.OBAM-RUN fileset
         installed.  It is necessary for the \"make_net_recovery\" user interface."
         result=$FAILURE
    fi
    ;;
*)
    # The original obam is sufficient on 10.30 and newer, so just check
    # to make sure it is here.
    if [ ! -f /usr/obam/lib/libobam.1 ] ; then
        echo "\
ERROR:   The system does not appear to have the SystemAdmin.OBAM-RUN fileset
         installed.  It is necessary for the \"make_net_recovery\" user interface."
         result=$FAILURE
    fi
    ;;
esac

if [ -d $REC_DEPOT ] ; then
    #
    # determine the architecture we are running on and set the location of
    # native binaries to link to /opt/ignite/bin and /opt/ignite/lbin
    ############
    case $(uname -m) in
        ia64*) bindir=/opt/ignite/binia
               lbindir=/opt/ignite/lbinia
               ;;
            *) bindir=/opt/ignite/binpa
               lbindir=/opt/ignite/lbinpa
               ;;
    esac

    if [[ -x /opt/ignite/lbin/pkg_rec_depot ]]; then
        pkgrecdepot=/opt/ignite/lbin/pkg_rec_depot
    elif [[ -x ${lbindir}/pkg_rec_depot ]]; then
        pkgrecdepot=${lbindir}/pkg_rec_depot
    fi

    ${pkgrecdepot} -f
    if [ $? != 0 ] ; then
        echo "\
ERROR:   Failed to update the depot: $REC_DEPOT
         using the command \"/opt/ignite/lbin/pkg_rec_depot -f\".
         See preceding messages for details."
         result=$FAILURE
    fi
fi
exit $result
