#! /sbin/sh
########
# Product: Ignite-UX
# Fileset: FILE-SRV-*
# configure
# @(#) $Revision: 10.16 $
########
#
# (c) Copyright Hewlett-Packard Company 1994
#
########################################################################

##########################################################################
# This script does the following:
#
# Adds the INDEX file description for the configuration supplied
# by this fileset.
# 

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

case $FILESET in
FILESRV-1123IA)
    RELEASE=B.11.23;;
FILESRV-1123PA)
    RELEASE=B.11.23;;
FILESRV-1122IA)
    RELEASE=B.11.22;;
FILESRV-1122PA)
    RELEASE=B.11.22;;
FILE-SRV-11-11)
    RELEASE=B.11.11;;
FILE-SRV-11-10)
    RELEASE=B.11.10;;
FILE-SRV-11-00)
    RELEASE=B.11.00;;
FILE-SRV-10-30)
    RELEASE=B.10.30;;
FILE-SRV-10-20)
    RELEASE=B.10.20;;
FILE-SRV-10-10)
    RELEASE=B.10.10;;
FILE-SRV-10-01)
    RELEASE=B.10.01;;
*)
    echo "ERROR:   Fileset ($FILESET) does not match a recognized release"
    exit 1;;
esac

INST_DIR=/opt/ignite
VAR_DIR=/var/opt/ignite
OPT_DATA_DIR_REL=/opt/ignite/data/Rel_${RELEASE}
VAR_DATA_DIR_REL=/var/opt/ignite/data/Rel_${RELEASE}
VAR_INDEX=$VAR_DIR/INDEX
CONFIG_LOCAL=$VAR_DIR/config.local

cond_mkdir 755 bin bin $VAR_DIR

if [ ! -f $VAR_INDEX -o ! -s $VAR_INDEX ] ; then
    echo "\
# $VAR_INDEX: Ignite-UX  configurations." > $VAR_INDEX
    chmog 644 bin bin $VAR_INDEX
fi

if [ ! -f $CONFIG_LOCAL -o ! -s $CONFIG_LOCAL ] ; then
    echo "\
# $CONFIG_LOCAL: config file to be used for local customizations." > $CONFIG_LOCAL
    chmog 644 bin bin $CONFIG_LOCAL
fi

if [ ! -d $VAR_DATA_DIR_REL ] ; then
    cond_mkdir 755 bin bin $VAR_DATA_DIR_REL
fi

TAG="HP-UX $RELEASE Default"

if grep -q "$TAG" $VAR_INDEX
then
    # Configuration: "$TAG" already exists in "$VAR_INDEX"
    :
else

    cat >> $VAR_INDEX << EOF
cfg "$TAG" {
    description "This selection supplies the default system configuration that HP supplies for the $RELEASE release."
    "$OPT_DATA_DIR_REL/config"
    "$CONFIG_LOCAL"
}
EOF
fi

#
# The hw_patches_cfg file only exists for some releases (10.20 for now)
# So add it to all cfg clauses for this release if it exists.
#
if [ -f /opt/ignite/data/Rel_${RELEASE}/hw_patches_cfg ] ; 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/bin/manage_index ]]; then
        manageindex=/opt/ignite/bin/manage_index
    elif [[ -x ${bindir}/manage_index ]]; then
        manageindex=${bindir}/manage_index
    fi

    ${manageindex} -a -r ${RELEASE} -f \
             /opt/ignite/data/Rel_${RELEASE}/hw_patches_cfg 
fi

# In our initial 11.22 delivery, there was a bogus directory packaged
# in. If it exists, remove it.
if [ "$FILESET" = "FILESRV-1122IA" -a -d /opt/ig23 ] ; then
    rm -rf /opt/ig23
fi

exit $SUCCESS
