#!/usr/bin/sh
#
# ###################################################################
# Copyright (c) 2005-2023, Dell Inc. or its subsidiaries. All Rights Reserved.
#
# /etc/init.d/PowerPathPost
# This file is a part of Dell PowerPath.
#
# chkconfig: 35 99 77
# description: Configures FCoE, iSCSI devices during boot and runs \
#              PPME recovery if required on bootup
#
# ###################################################################
#
### BEGIN INIT INFO
# Provides:          PowerPathPost
# Required-Start:
# Required-Stop:
# Default-Start:     3 5
# Default-Stop:      0 1 2 6
# Description:       PowerPathPost -- Configures FCoE, Iscsi \
#                    devices during boot and runs PPME recovery \
#                    if required on bootup
### END INIT INFO

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

# SW_PROTOCOL can be iSCSI,FCoE or both
SW_PROTOCOL=no
SW_ISCSI_PROTOCOL_ACTIVE=no
SW_FCOE_PROTOCOL_ACTIVE=no
fcoe_ports_online=0

NVME_PROTOCOL=no
PFLEX_PROTOCOL=no

# Used to pass mounted pseudo partition device name from
# function check_holders_holders.
#
g_partition_dev_name=""

PMAX_FILE_CONFIG="/etc/enaslogconf"

#
# Store powermt display and  powermt display dev=all output.
#
powermt_display=`powermt display`
powermt_display_all=`powermt display dev=all`

#
# Check if a dm device of a LVM volume is contained in a holders directory.
#
# Parameter 1 - holders directory
#           2 - the dm device of the mounted LVM volume
# Return values 0 - The the dm device is not contained in the holders
#                   directory.
#               1 - The dm device is contained in the holders directory.
#
check_holders()
{
    local holders_path=$1
    local dm=$2

    for h in $holders_path/* ; do
        [ "${h##*/}" != "*" ] || break
        [ "${h##*/}" = "${dm##*/}" ] && return 1
    done
    return 0
}

#
# Check for a pseudo device's holders' holders or partitions' holders
# to see if the pseudo device contains the dm device of a mounted
# LVM volume.
#
# Parameter 1 - pseudo device name
#           2 - whether the psdudo device is a partition(1: yes 0: no)
#           3 - the dm device of the mounted LVM volume
# Return values 0 - The pseudo device doesn't contain the dm device.
#               1 - The pseudo device contains the dm device.
#
check_holders_holders()
{
    local dev=$1
    local is_partition=$2
    local dm=$3

    if [ $is_partition -eq 1 ] ; then
        empty_string="emcpower*"
        parent_path="/sys/devices/virtual/block/$dev/$empty_string"
    else
        empty_string="*"
        parent_path="/sys/devices/virtual/block/$dev/holders/$empty_string"
    fi

    for p in $parent_path ; do
        [ "${p##*/}" != "$empty_string" ] || break

        if [ $is_partition -eq 1 ] ; then
            holders_path="$p/holders/"
            g_partition_dev_name="${p##*/}"
        else
            holders_path="/sys/devices/virtual/block/"${p##*/}"/holders/"
        fi
        check_holders $holders_path $dm
        if [ $? -eq 1 ] ; then
            [ $is_partition -eq 1 ] && g_partition_dev_name="${p##*/}"
            return 1
        fi
    done
    return 0
}

#
# If umount fails and the mounted device is a LVM volume, then
# reset the dm table for dm devices associated with an iSCSI
# pseudo device to use pseudo device's first active native
# path to prevent open-iscsi:stop from logging out the iSCSI
# session the native path belongs to.
#
# parameter 1 - the pseudo device or pseudo device partition
#
reset_dm_table_to_use_native()
{
    local dev=$1
    local partition_no="${dev##*[a-z]}"
    local dev_without_partition="${dev%$partition_no}"
    local pseudo_major=`grep -e "$dev$" /proc/partitions | \
        sed -e "s/^ *\([0-9]*\) *[0-9]* *[0-9]* *$dev$/\1/"`""
    local pseudo_minor=`grep -e "$dev$" /proc/partitions | \
        sed -e "s/^ *[0-9]* *\([0-9]*\) *[0-9]* *$dev$/\1/"`
    local pseudo_major_minor="$pseudo_major:$pseudo_minor"
    local native_dev_names=`echo "$powermt_display_all" | \
                awk  -vpseudo="${dev_without_partition}" '$0 ~ pseudo \
                {flag=1;next} /$^/ {flag=0} flag { print }' \
                egrep 'active|standby|unlic|asb:iopf|asb:fpin' | grep -v unknown | \
                sed -ne 's:\(.*\) \(sd[a-z]*\) \(.*\):\2:p')`
    local table_file="/etc/opt/emcpower/.tmp/poweriscsi_table_file"

    for n in $(echo $native_dev_names)
    do
        first_native_path="$n$partition_no"
        break
    done

    [ "$first_native_path" != "" ] || return


    native_major=`grep -e "$first_native_path$" /proc/partitions | \
        sed -e "s/^ *\([0-9]*\) *[0-9]* *[0-9]* *$first_native_path$/\1/"`""
    native_minor=`grep -e "$first_native_path$" /proc/partitions | \
        sed -e "s/^ *[0-9]* *\([0-9]*\) *[0-9]* *$first_native_path$/\1/"`
    native_major_minor="$native_major:$native_minor"

    DM_LIST=`dmsetup ls 2>/dev/null | grep -v "No devices found" | \
        sed -e 's/^\(\S*\) *.*/\1/'`
    DM_MAJOR=`cat /proc/devices|grep device-mapper|awk '{print $1}'`

    for DM_DEV in $DM_LIST
    do
        OLD_TABLE=`dmsetup table $DM_DEV 2>/dev/null`
        NEW_TABLE=`echo "$OLD_TABLE" | \
            sed -e "s/$pseudo_major_minor/$native_major_minor/g"`

        if [ "$OLD_TABLE" != "$NEW_TABLE" ] ; then
            echo "$NEW_TABLE" > $table_file
            dmsetup suspend $DM_DEV 2>/dev/null
            dmsetup reload $DM_DEV $table_file 2>/dev/null
            dmsetup resume $DM_DEV 2>/dev/null
            rm $table_file 2>/dev/null
        fi
    done
}

#
# Unmount any mount points associated with a pseudo device that
# are using the specific transport protocol
#
# Parameter 1 - an pseudo device such as emcpowera
# Parameter 2 - a transport protocol (i.e. iSCSI, FCoE)
#
umount_if_mounted()
{
    local dev=$1
    local protocol=$2
    local d m x islink holder_path mount_link

    cat /proc/mounts | sed -ne '/^\/dev\/.*/p' | while read d m x; do
        islink=0
        if [ -L "$d" ] ; then
            # Mounted device is LVM volume such as /dev/mapper/vg01-lvol0.
            # Use readlink to get its dm device, such /dev/dm-1.
            d=$(readlink -f $d)
            islink=1
        fi
        [ -b "$d" ] || continue
        [ "$m" != "/" ] || continue  # Skip root mount point

        is_mounted=0
        g_partition_dev_name=""

        if [ $islink -eq 0 ] ; then
            #
            # The mounted device can be /dev/emcpowera, /dev/emcpowera2,
            # /dev/sda and /dev/sda2, etc.
            #
            # Strip the path and partition from the mount device.
            #
            d="${d##*/}"
            d="${d%"${d##*[a-z]}"}"

            if [ "$dev" = "$d" ]; then
               is_mounted=1
            else # Check native path as well
            echo "$powermt_display_all" \
                       | awk  -vpseudo="${dev##*/}" '$0 ~ pseudo \
                       {flag=1;next} /$^/ {flag=0} flag { print }' \
                       | grep $protocol > /dev/null 2>&1
                if [ $? -eq 0 ] ; then
                    is_mounted=1
                fi
            fi
        else
            #
            # Mounted device is a LVM volume. Check for $dev's holders and
            # holders' holders(i.e., in the case of mirrored LVM volumes)
            # to see if $dev contains the dm device of the LVM volume.
            #
            # Check for partitions' holders as well because volume can be
            # created with partitions.
            #
            check_holders "/sys/devices/virtual/block/$dev/holders/" $d && \
                check_holders_holders $dev 0 $d && \
                check_holders_holders $dev 1 $d
            is_mounted=$?
        fi

        if [ $is_mounted -eq 1 ] ; then
            if  ! umount $m 2> /dev/null  && [ $islink -eq 1 ] ; then
                #
                # If umount fails and the mounted device is a LVM volume,
                # then reset the dm table for dm devices associated with this
                # pseudo device to use pseudo device's first active native
                # path to prevent open-iscsi:stop from logging out the FCoE
                # session this the native path belongs to.
                #
                if [ "$g_partition_dev_name" != "" ] ; then
                    reset_dm_table_to_use_native $g_partition_dev_name
                else
                    reset_dm_table_to_use_native $dev
                fi
            fi
        fi
    done
}


#
# Check if a device-mapper device is mounted by UUID and maps to a
# LVM logical volume which uses Dell PowerPath pseudo device names.
# If a match is found unmount the file system which corresponds to
# the device-mapper device.
#
# Parameter 1 - protocol string to search for (i.e. iSCSI, FCoE)
#
umount_if_mounted_by_uuid()
{
    local protocol=$1
    #
    # Loop through the file systems that are currently mounted on
    # device-mapper devices.
    #
    cat /proc/mounts | grep -e "^\/dev\/dm-" | awk '{print $1}' \
        | while read filesystem;
    do
        #
        # Use the block ID command to get the UUID for the
        # device-mapper device.
        #
        dm_dev_uuid=`/sbin/blkid $filesystem | awk 'BEGIN {FS = "\""} \
            ; {print $2}'`
        #
        # For each device-mapper volume still mounted loop through the
        # LVM volume groups and check if it has an Dell PowerPath pseudo
        # device.
        #
        vgdisplay -c | awk 'BEGIN {FS = ":"} ; {print $1}' | while read vg;
        do
            pp_dev=`vgdisplay -v $vg 2>/dev/null | grep -e "PV Name" \
                | grep -e "emcpower" | awk '{print $3}'`
            if [ "$pp_dev" != "" ] ; then
                #
                # Get the Dell PowerPath pseudo device name from the
                # LVM physical volume.
                #
                pp_pseudo=`echo $pp_dev | awk 'BEGIN {FS = "/"} \
                    ; {print $3}'`
                #
                # strip the partition
                #
                pp_pseudo="${pp_pseudo##*/}"
                pp_pseudo="${pp_pseudo%"${pp_pseudo##*[a-z]}"}"
                #
                # Check if the Dell PowerPath pseudo device matches
                # the specified transport protocol
                #
                is_match=`echo "$powermt_display_all" | \
                       awk  -vpseudo="${pp_pseudo}" '$0 ~ pseudo \
                       {flag=1;next} /$^/ {flag=0} flag { print }' \
                       | grep -e $protocol`
                if [ "$is_match" != "" ] ; then
                    #
                    # We have a LVM volume group that has an Dell PowerPath
                    # pseudo device. Check to see if our current
                    # device-mapper device UUID matches a LVM logical
                    # volume UUID from this volume group.
                    #
                    vgdisplay -v $vg 2>/dev/null | grep -e "LV Name" \
                        | awk '{print $3}' | while read lv;
                    do
                        #
                        # Use the block ID command to get the UUID for the
                        # LVM logical volume.  Then compare the current
                        # device-mapper UUID with the LVM logical volume
                        # UUID.
                        #
                        lvm_uuid=`/sbin/blkid $lv | awk 'BEGIN {FS = "\""} \
                            ; {print $2}'`
                        if [ "$dm_dev_uuid" = "$lvm_uuid" ] ; then
                            #
                            # We have matching UUIDs. Search the fstab file
                            # for the mount point for unmounting.
                            #
                            fs_to_unmount=`grep -e $dm_dev_uuid /etc/fstab \
                                | awk '{print $2}'`
                            /bin/umount $fs_to_unmount
                            #
                            # Deactivate the volume group
                            #
                            /sbin/vgchange -a n $vg > /dev/null 2>&1
                        fi
                    done
                fi
            fi
        done
    done
}


umount_pp_all()
{
    local protocol=$1

    for dev in /dev/emcpower?*
    do
        [ "${dev##*/}" != "emcpower?*" ] || break

        #
        # Skip partitions here.  They will be handled in
        # umount_if_mounted()
        #
        if [ "`expr \"${dev##*/}\" : \
            \"emcpower[a-z][a-z]*[0-9][0-9]*\"`" != "0" ] ; then
            continue
        fi

        echo "$powermt_display_all" | \
                       awk  -vpseudo="${dev##*/}" '$0 ~ pseudo \
                       {flag=1;next} /$^/ {flag=0} flag { print }' \
                       | grep $protocol > /dev/null 2>&1
        if [ $? -eq 0 ] ; then
            umount_if_mounted "${dev##*/}" $protocol
        fi
    done
}


#-----------------
# main starts here
#-----------------

#
# This script needs to be run only if PowerPath is active.
#
lsmod | grep -w '^emcp' > /dev/null 2>&1
if [ $? != 0 ]; then
    if [ -e /var/lock/subsys/PowerPathPost ]; then
        rm /var/lock/subsys/PowerPathPost
    fi
    exit
fi

NDI_LOCK_FILE="/etc/opt/emcpower/.ndi_lock"
BINDINGS_PP="/etc/multipath/bindings_pp"
pp_config_complete="/etc/emc/.pp_config_complete"

if [ "`iscsiadm --mode node 2> /dev/null`" == "" ]; then
    SW_ISCSI_PROTOCOL_ACTIVE=no
else
    SW_ISCSI_PROTOCOL_ACTIVE=yes
fi

if [ -f /usr/lib/systemd/system/iscsid.service -o -f /etc/init.d/iscsi ] && [ -f /usr/lib/systemd/system/fcoe.service -o -f /etc/init.d/fcoe ]
then
    SW_PROTOCOL=both
elif [ -f /usr/lib/systemd/system/iscsid.service -o -f /etc/init.d/iscsi ]
then
    SW_PROTOCOL=iscsi
elif [ -f /usr/lib/systemd/system/fcoe.service -o -f /etc/init.d/fcoe ]
then
    SW_PROTOCOL=fcoe
fi

ls /sys/block/nvme* > /dev/null 2>&1
if [ $? -eq 0 ]; then
    NVME_PROTOCOL=yes
fi

ls /sys/block/scini* > /dev/null 2>&1
if [ $? -eq 0 ]; then
    PFLEX_PROTOCOL=yes
fi

case "$1" in
start)

    if [ -d /var/lock/subsys ] ; then
        touch /var/lock/subsys/PowerPathPost
    fi
    nvmeCount1=0
    sciniCount1=0

    fcoe_ports_found="no"
    if [ "$SW_PROTOCOL" == "iscsi" -o "$SW_PROTOCOL" == "fcoe" -o \
        "$SW_PROTOCOL" == "both"   -o "$NVME_PROTOCOL" == "yes" ]; then
               
        while true
        do
            #FCoE
            if [ "$SW_PROTOCOL" == "fcoe" -o "$SW_PROTOCOL" == "both" ];then
                #
                # Wait for upto 30 seconds for atleast some of
                # the FCoE ports to be initialized
                #
                for (( i=0; i<6; i++ ))
                    do
                    fcoe_ports=`/usr/sbin/fcoeadm -i | grep "Symbolic Name" | wc -l`
                    if [ ${fcoe_ports} -gt 0 ]; then
                        fcoe_ports_found="yes"
                        break;
                    fi
                    sleep 5
                done

                if [ ${fcoe_ports_found} == "yes" ]; then
                    sleep 10
                    #
                    # Wait for upto 150 seconds for all the FCoE ports to
                    # become online
                    #
                    for (( i=0; i<30; i++ ))
                    do
                        fcoe_ports=`/usr/sbin/fcoeadm -i | grep "Symbolic Name" | wc -l`
                        fcoe_ports_online=`/usr/sbin/fcoeadm -i | grep State | grep Online | wc -l`

                        if [ ${fcoe_ports_online} -gt 0 ]; then
                            SW_FCOE_PROTOCOL_ACTIVE=yes
                        fi
                        if [ ${fcoe_ports} -eq ${fcoe_ports_online} ]; then
                             break;
                        fi
                        sleep 5
                    done
                else
                    if [ "$SW_PROTOCOL" != "both" ]; then
                        break;
                    fi
                fi
            fi

            if [ "$SW_FCOE_PROTOCOL_ACTIVE" == "yes" -o \
                 "$SW_ISCSI_PROTOCOL_ACTIVE" == "yes" -o \
                 "$NVME_PROTOCOL" == "yes" ]; then

                if [ ! -d $PMAX_FILE_CONFIG ] ; then
                    /sbin/udevadm settle --timeout=180

                    if [ -e /etc/SuSE-release ]; then
                        if [ -s /var/run/fcoemon.pid -o -s /var/run/iscsid.pid ]; then
                            sleep 10
                            for (( cnt=0; $cnt < 360; cnt++ ))
                            do
                                hw=`ps ax | grep -w hwscan | grep -v grep | wc -l`
                                if [ $hw -eq 0 ]; then
                                    sleep 6
                                    hw=`ps ax | grep -w hwscan | grep -v grep | wc -l`
                                    if [ $hw -eq 0 ]; then
                                        break;
                                    fi
                                fi
                                sleep 10
                            done
                        fi # if [ -s /var/run/fcoemon.pid -o -s /var/run/iscsid.pid ]; then
                    fi # if [ -e /etc/SuSE-release ]; then
                fi # if [ ! -d $PMAX_FILE_CONFIG ] ; then

                for ((i=0; (i<30);i++)); do
                    sdfound=1
                    for sd in `/bin/ls -d /sys/block/sd* 2> /dev/null`; do
                        bsd=`basename $sd`
                        if [ ! -e /dev/$bsd ]; then
                            sdfound=0
                            sleep 2
                            break;
                        fi
                    done
                    if [ "$sdfound" -eq 1 ]; then
                        break
                    fi
                done

                for ((i=0; (i<30);i++)); do
                    nvmefound=1
                    for nvme in `/bin/ls -d /sys/block/nvme* 2> /dev/null`; do
                        bnvme=`basename $nvme`
                        if [ ! -e /dev/$bnvme ]; then
                            nvmefound=0
                            sleep 2
                            break;
                        fi
                    done
                    if [ "$nvmefound" -eq 1 ]; then
                        break
                    fi
                done
                # Keep track of number of NVME devices found
                nvmeCount1=`/bin/ls -l /sys/block/nvme* 2> /dev/null | wc -l`

                for ((i=0; (i<30);i++)); do
                    scinifound=1
                    for scini in `/bin/ls -d /sys/block/scini* 2> /dev/null`; do
                        bscini=`basename $scini`
                        if [ ! -e /dev/$bscini ]; then
                            scinifound=0
                            sleep 2
                            break;
                        fi
                    done
                    if [ "$scinifound" -eq 1 ]; then
                        break
                    fi
                done
                # Keep track of number of scini devices found
                sciniCount1=`/bin/ls -l /sys/block/scini* 2> /dev/null | wc -l`

                /sbin/powermt config

                #  Wait for udev to finish creating emcpower devices
                pdfound=1
                for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15; do
                pdfound=1
                    for pd in `/bin/ls -d /sys/block/emcpower* 2> /dev/null`; do
                        bpd=`basename $pd`
                        if [ ! -e /dev/$bpd ]; then
                            pdfound=0
                            sleep 2
                            break;
                        fi
                    done
                    if [ "$pdfound" -eq 1 ]; then
                        break;
                    fi
                done
                /sbin/powermt load > /dev/null 2>&1

                break;
            else
                break;
            fi  # "$SW_FCOE_PROTOCOL_ACTIVE" == "yes" -o "$SW_ISCSI_PROTOCOL_ACTIVE" == "yes"
        done  #while true

        # Device mapper devices may have been started with dependencies on native devices. Reset the
        # dependencies to emcpower devices. If NDI is active then don't change the DM deps.
        if [ ! -f $NDI_LOCK_FILE ]; then
            /etc/opt/emcpower/pp_reset_dm_deps.sh  pseudo
        fi
    fi    

    #
    # Set the IO scheduler by running the script pp_udev.sh.
    # If the host is booting, scheduler is reset in
    # PowerPathPost script. After the pp_udev.sh executes, a marker
    # file .pp_config_complete is created. The code block is added to
    # ensure that there are no udev storms in case of max config setup.
    # Once host boots up, the udev rule 80-udev-pp2.rules will be 
    # triggered for new devices being added and for devices which
    # transition from dead to alive.
    #
    # Changing the scheduler need not be done in inline, when large number
    # devices presented to host, this utility will take some time to complete
    # which will delay the boot process.
    /usr/lib/udev/pp_udev.sh scheduler all  & > /dev/null 2>&1

    touch $pp_config_complete

    #
    # Only after creation of pp_config_complete file, PP udev events are triggerred to configure
    # newly added NVME and/or PowerFlex devices. Before the creation of this file, there could be
    # some NVME and/or PowerFlex devices added by the system since last powermt config.  Need to take
    # care of configuring those devices. In such case only, call powermt config again.
    #
    nvmeCount2=`/bin/ls -l /sys/block/nvme* 2> /dev/null | wc -l`
    sciniCount2=`/bin/ls -l /sys/block/scini* 2> /dev/null | wc -l`
    if [ $nvmeCount1 -ne $nvmeCount2 -o $sciniCount1 -ne $sciniCount2 ]; then
        powermt config
    fi

    # Save PowerPath configuration only if any devices are configured
    # in PowerPath. This is to ensure that a previously saved configuration
    # is preserved in case the host boots up without any paths attached.
    if [ ! -d $PMAX_FILE_CONFIG ] ; then
       /sbin/powermt display | grep -i "HW Path" >  /dev/null 2>&1
       if [ $? -eq 0 ]; then
           /sbin/powermt save >  /dev/null 2>&1
       fi                  
  
       # PPME
       if [ -f /sbin/powermig ] ; then
           /sbin/powermig transition -startup -noprompt   > /dev/null 2>&1
           if [ ! -f "/etc/opt/emcpower/.ndi_lock" ] ; then 
              /sbin/powermig recover -all -no > /dev/null 2>&1
           fi 
           /sbin/powermig info -all -query > /dev/null 2>&1
           /sbin/powermig options -startupInProgress 0 > /dev/null 2>&1
       fi
    fi

    /etc/opt/emcpower/emcpmgr startup_cfg_done > /dev/null 2>&1

    if [ -d $PMAX_FILE_CONFIG ]; then
        /sbin/powermt set device_add_notifications=on > /dev/null 2>&1
    fi

    ;;

stop)

    #
    # Updated multipath bindings file with altered WWID of source and target mpath
    # device should be replaced with original bindings file during host reboot.
    #
    if [[ -f $NDI_LOCK_FILE && -f $BINDINGS_PP ]]; then
        cp /etc/multipath/bindings_pp /etc/multipath/bindings > /dev/null 2>&1
    fi
    #  
    # The marker file should be removed during host reboot. Hence removing
    # marker file here.
    #
    if [ -f $pp_config_complete ]; then
        rm -f $pp_config_complete
    fi
    #
    # Delete the udev rule in the directory /etc/udev/rules.d/
    # to avoid triggering udev rules when PowerPath is not
    # active.
    #
    rm -f /etc/udev/rules.d/04-nvme-pp.rules \
          /etc/udev/rules.d/04-pflex-pp.rules \
          /etc/udev/rules.d/05-udev-pp.rules \
          /etc/udev/rules.d/80-udev-pp2.rules

    if [ ! -d $PMAX_FILE_CONFIG ] ; then
        # The existence of /etc/emc/ppme ensures that PP has been
        # started, otherwise the umd open will fail (opt 400490).
        if [ -d /etc/emc/ppme ]; then
           /sbin/powermig recover -all -no > /dev/null 2>&1
           /sbin/powermig transition -no > /dev/null 2>&1
        fi
    fi

    #Fcoe
    if [ "$SW_PROTOCOL" == "fcoe" -o "$SW_PROTOCOL" == "both" ]; then
 
        #
        # Umount all mount points associated with each PP FCoE device.
        #
        umount_pp_all FCoE
  
        #
        # Check existing mounted file systems to see if there
        # are device-mapper devices mounted by UUID which use
        # Dell PowerPath pseudo devices.
        #
        umount_if_mounted_by_uuid FCoE

        hbano=`echo "$powermt_display" | grep FCoE | awk '{ print $1 }'`
        for i in $hbano; do
            powermt remove force hba=$i
        done
    fi

    #iSCSI
    if [ "$SW_PROTOCOL" == "iscsi" -o "$SW_PROTOCOL" == "both" ]; then

        #
        # Umount all mount points associated with each PP iSCSI device. 
        #
        umount_pp_all iSCSI
                            
        #
        # Check existing mounted file systems to see if there
        # are device-mapper devices mounted by UUID which use 
        # Dell PowerPath pseudo devices.
        #
        umount_if_mounted_by_uuid iSCSI
        
        hbano=`echo "$powermt_display" | grep iSCSI | awk '{ print $1 }'`
        
        for i in $hbano; do
            powermt remove force hba=$i
        done
    fi

    if [ -e /var/lock/subsys/PowerPathPost ]; then
        rm /var/lock/subsys/PowerPathPost
    fi
    ;;

    *)
    ;;
esac

