#!/sbin/sh
#############################################################################
#  Product: FCMassStorage
#  Fileset: FCMS-KRN
#  configure
#  @(#) $Revision: 1.1.98.1 $
#############################################################################
# (c) Copyright Hewlett-Packard Company, 1995
#############################################################################

####### add our entry to the kernel config file only if on a client system
if [ -z "$SW_DEFERRED_KERNBLD" ] ; then
        # we are on a standalone or server; the postinstall script has
        # already updated the kernel config file
        exit $SUCCESS
fi


####### setup environment 
PATH=${SW_PATH}:${SW_ROOT_DIRECTORY}usr/lbin/sw
UTILS="/usr/lbin/sw/control_utils"
if [ ! -f $UTILS ] ; then
    echo "ERROR:   Cannot find \"$UTILS\"."
    exit $FAILURE
fi
. $UTILS


####### For now, do something only if this is a Series 800 machine

ARCHITECTURE=`get_arch`
if [ $ARCHITECTURE -ne "800" ]; then
    exit $SUCCESS
fi

####### add our entry to the kernel config file

#BABY_HUGO_TEST=$FAILURE
#
#for LINE in `ioscan -C fc -F | sed 's/ /~/g'` ; do
#    SVERS_MODEL=`echo "$LINE" | awk -F':' '{ print $12 }' | sed 's/~/ /g' | \
#	    awk '{printf("%02x%02x%02x\n",$5,$6,$7)}' | \
#            awk '{ $1=substr($1,2,5); print $1 }'`
#    case $SVERS_MODEL in
#        00091)
#            # 0x91 ---> GSC+ Fibre Channel adapter card
#	    BABY_HUGO_TEST=$SUCCESS
#            ;;
#        *)
#    esac
#done


EXITVAL=$SUCCESS    # anticipate success

####### if we didn't find any Baby Hugo cards, tell the user and let the 
####### install go on
#
#if [ $BABY_HUGO_TEST -ne $SUCCESS ] ; then
#    echo "WARNING: Cannot find a Baby Hugo Fibre Channel card installed"
#    echo "         in the system.  No FCMS drivers have been configured"
#    echo "         into the kernel."
#    exit $WARNING
#fi

####### add the drivers to the kernel

RES_FCP=0
RES_FCPMUX=0
mod_systemfile $SW_SYSTEM_FILE_PATH -a fcgsc_fcp
RES_FCP=$?
mod_systemfile $SW_SYSTEM_FILE_PATH -a fcpmux
RES_FCPMUX=$?


####### see if the mod_systemfiles worked
if [ $RES_FCP -ne $SUCCESS ] ; then
    echo "ERROR:   Cannot modify the kernel configuration file for the fcp"
    echo "         driver. It must be manually configured into the kernel."
    EXITVAL=$FAILURE
fi

if [ $RES_FCPMUX -ne $SUCCESS ] ; then
    echo "ERROR:   Cannot modify the kernel configuration file for the fcpmux"
    echo "         driver. It must be manually configured into the kernel."
    EXITVAL=$FAILURE
fi

##### Export the master file to the FCMS-RUN fileset.

MASTER_FILE="${SW_LOCATION}usr/conf/master.d/fcms"
if swlist -l file $PRODUCT.$FILESET 2>/dev/null | grep -q $MASTER_FILE
then        # master file not yet exported
  export_master $MASTER_FILE
  if [[ $? -ne $SUCCESS ]]
    then
      echo "WARNING: Cannot give the master file(s) \"$MASTER_FILE\""
      echo "         to ${FILESET%%-KRN}-RUN.  If you delete this"
      echo "         fileset, SAM will not be able to handle your"
      echo "         device files"
      if [[ $EXITVAL -ne $FAILURE ]]
        then
          EXITVAL=$WARNING
      fi # [[ $EXITVAL -ne $FAILURE ]]
    fi # [[ $? -ne $SUCCESS ]]
fi # swlist -l file $PRODUCT.$FILESET

exit $EXITVAL
