#!/bin/sh
#
# Name: qla2300
# Copyright: (C)2003 Hewlett-Packard Company
#
# Description:
#
# Start/Stop script for the qla2300 module
#
# Modification History
#
# Name          Date     Modification
#
# Chad Dupuis   01/13/03 Initial Development     
# Chad Dupuis   02/13/03 Remove any instance to
#                        something using the /opt, /var
#                        or /usr filesystems; changed
#                        way that script searches for 
#                        the presence of Secure Path 

# set path

PATH=/sbin:/bin:/usr/bin:/usr/sbin

# check qdepth from /etc/hp_qla2x00.conf file.  If there is an
# entry, use that.  If there isn't an entry, use default of 16

QDEPTHFILE=`ls /etc/hp_qla2x00.conf`

if [ "$QDEPTHFILE" = "" ]
then
 QDEPTH=16
else
 QDEPTH=`cat $QDEPTHFILE | grep qdepth | awk '{print $3}'`

 # double check to make sure that we got something from file

 if [ "$QDEPTH" = "" ]
 then
  QDEPTH="16"
 fi
fi

# Check to see if Secure Path is installed; if it is,
# set the port down retry count to 1, else retrieve
# what the default is from hp_qla2x00.conf

if [ -d /etc/CPQswsp ]
then
 # Secure Path is installed

 PDRC=1

 # now that we have value, put whole command line option together
 PDRCCMD="qlport_down_retry=$PDRC"
else
 # Secure Path is not installed

 PDRCFILE=`ls /etc/hp_qla2x00.conf`

 if [ "$PDRCFILE" = "" ]
 then
  PDRC=""
 else
 
  PDRC=`cat $PDRCFILE | grep port_down_retry_count | awk '{print $3}'`
 
  # now that we have value, put whole command line option together
  PDRCCMD="qlport_down_retry=$PDRC"
 fi
fi
 
# load driver module

start () {
 # Try to unload any module that was loaded from the initrd

 rmmod qla2300 1>/dev/null 2>/dev/null

 # attempt to insmod module with proper attributes

 insmod qla2300 ql2xmaxqdepth=$QDEPTH $PDRCCMD 1>/dev/null 2>/dev/null
 RETVAL=$?

 return $RETVAL
}

# remove driver module

stop () {
 
 RETVAL=1
 return $RETVAL
}

#
# Script Main
#

case "$1" in
 "start") start;;
 "stop") stop;;
 *) echo $"Usage: $0 start | stop"
    RETVAL=1;;
esac

exit $RETVAL
 
 
