#! /sbin/sh
########
# Product: Ignite-UX
# Fileset: MGMT-TOOLS
# configure
# @(#) $Revision: 10.17 $
########
#
# (c) Copyright Hewlett-Packard Company 1994
#
########################################################################

##########################################################################
# 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

INST_DIR=/opt/ignite
VAR_DIR=/var/opt/ignite
VAR_INDEX=$VAR_DIR/INDEX

cond_mkdir 755 bin bin $VAR_DIR/clients
cond_mkdir 755 bin bin $VAR_DIR/server
cond_mkdir 755 bin bin $VAR_DIR/logs
cond_mkdir 755 bin bin $VAR_DIR/scripts
cond_mkdir 755 bin bin $VAR_DIR/data
cond_mkdir 755 bin bin $VAR_DIR/saved_cfgs

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

#
# Create a symlink to the correct version of sd_opts for the
# release of this server.
#
case $(uname -r) in
  *11.*)
         sd_opts_file="sd_opts.11.00"
         ;;
  *10.10|*10.20)
         sd_opts_file="sd_opts.10.10"
         ;;
  *)
         sd_opts_file="sd_opts.10.01"
         ;;
esac
rm -f /opt/ignite/lib/sd_opts
ln -s /opt/ignite/lib/$sd_opts_file /opt/ignite/lib/sd_opts

#
# Add /opt/ignite/bin to the system search PATH
#
mod_pathfile -a P /opt/ignite/bin

#
# check if the commands exist in the old location AND the lbin dir
# is not a symlink (it became a sym link when we mergred multi-stream
# fileses B.5.2. If both true then remove old commands
#
if [[ -f $INST_DIR/lbin/make_config && ! -h $INST_DIR/lbin ]] ; then
    echo "Removing old Ignite-UX commands from old locations."
    rm -f $INST_DIR/lbin/make_config \
          $INST_DIR/lbin/remove_release \
          $INST_DIR/lbin/make_depots \
          $INST_DIR/lbin/manage_index
fi

##########################################################################
# Copy the manifest template file into place if needed.
#
for f in template.def
do
    SW_LOCATION=/opt/ignite/ newconfig_cp $VAR_DIR/local/manifest/$f
    SW_LOCATION=/opt/ignite/ newconfig_msgs $?
done

exit $SUCCESS
