#!/sbin/sh
########
# Product: Ignite-UX
# Fileset: MGMT-TOOLS
# postinstall
# @(#) $Revision: 10.3 $
########
#
# (c) Copyright Hewlett-Packard Company 2003
#
########################################################################

##########################################################################
# Source SD contol_utils library
#
UTILS=/usr/lbin/sw/control_utils
if [ -f $UTILS ]
then
    . $UTILS
else
    echo "ERROR:   Cannot find $UTILS"
    exit 1
fi

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

#
# cleanup previous installs 
#######
# Always remove the old version of bin and lbin so we can make them
# sym links. Move them aside if they have busy files
# Also if we failed the remove in the past, try [bin|lbin].ok_to_rm as well.
for rmvDir in bin lbin
{
    rm -rf /opt/ignite/${rmvDir} /opt/ignite/${rmvDir}.ok_to_rm > /dev/null 2>&1
    if [ -d /opt/ignite/${rmvDir} ] ; then
        mv /opt/ignite/${rmvDir} /opt/ignite/${rmvDir}.ok_to_rm
    #
    # note that the indentation of the "echo" statement is wierd so the it conforms to
    # the SD message standard of text starting in column 9 (0 based counting)
            echo "\
NOTE:    Could not remove the directory: \"/opt/ignite/${rmvDir}.ok_to_rm\", it
         may have busy files in it.  You may remove it manually later."
    fi

}

#
# link native binaries
#######
ln -s ${bindir} /opt/ignite/bin
ln -s ${lbindir} /opt/ignite/lbin
for linkedfile in $(find /opt/ignite/bin /opt/ignite/lbin -type l)
{
    IPD_addfile -N ${linkedfile}
}

exit $SUCCESS