s390utils/SOURCES/zfcpconf.sh

78 lines
2.1 KiB
Bash
Raw Permalink Normal View History

2019-08-06 18:58:26 +00:00
#!/bin/sh
# config file syntax:
# deviceno WWPN FCPLUN
2021-03-30 15:16:34 +00:00
# deviceno # allowed when auto LUN scan is enabled and port is in NPIV mode
2019-08-06 18:58:26 +00:00
#
# Example:
# 0.0.4000 0x5005076300C213e9 0x5022000000000000
# 0.0.4001 0x5005076300c213e9 0x5023000000000000
2021-03-30 15:16:34 +00:00
# 0.0.5000
2019-08-06 18:58:26 +00:00
#
#
# manual setup:
# modprobe zfcp
# echo 1 > /sys/bus/ccw/drivers/zfcp/0.0.4000/online
# echo LUN > /sys/bus/ccw/drivers/zfcp/0.0.4000/WWPN/unit_add
#
# Example:
# modprobe zfcp
# echo 1 > /sys/bus/ccw/drivers/zfcp/0.0.4000/online
# echo 0x5022000000000000 > /sys/bus/ccw/drivers/zfcp/0.0.4000/0x5005076300c213e9/unit_add
CONFIG=/etc/zfcp.conf
PATH=/bin:/sbin
2021-03-30 15:16:34 +00:00
set_online()
{
DEVICE=$1
[ `cat /sys/bus/ccw/drivers/zfcp/${DEVICE}/online` = "0" ] \
&& echo 1 > /sys/bus/ccw/drivers/zfcp/${DEVICE}/online
}
2019-08-06 18:58:26 +00:00
if [ -f "$CONFIG" ]; then
if [ ! -d /sys/bus/ccw/drivers/zfcp ]; then
modprobe zfcp
fi
if [ ! -d /sys/bus/ccw/drivers/zfcp ]; then
2021-10-06 17:40:09 +00:00
exit 1
2019-08-06 18:58:26 +00:00
fi
sed 'y/ABCDEF/abcdef/' < $CONFIG | while read line; do
case $line in
\#*) ;;
*)
[ -z "$line" ] && continue
set $line
2021-03-30 15:16:34 +00:00
if [ $# -eq 1 ]; then
DEVICE=${1##*0x}
if [ `cat /sys/module/zfcp/parameters/allow_lun_scan` = "Y" ]; then
set_online ${DEVICE}
grep -q NPIV /sys/bus/ccw/devices/${DEVICE}/host*/fc_host/host*/port_type || \
echo "Error: Only device ID (${DEVICE}) given, but port not in NPIV mode"
else
echo "Error: Only device ID (${DEVICE}) given, but LUN scan is disabled for the zfcp module"
fi
continue
fi
2019-08-06 18:58:26 +00:00
if [ $# -eq 5 ]; then
DEVICE=$1
SCSIID=$2
WWPN=$3
SCSILUN=$4
FCPLUN=$5
echo "Warning: Deprecated values in /etc/zfcp.conf, ignoring SCSI ID $SCSIID and SCSI LUN $SCSILUN"
elif [ $# -eq 3 ]; then
DEVICE=${1##*0x}
WWPN=$2
FCPLUN=$3
fi
2021-03-30 15:16:34 +00:00
set_online ${DEVICE}
2019-08-06 18:58:26 +00:00
[ ! -d /sys/bus/ccw/drivers/zfcp/${DEVICE}/${WWPN}/${FCPLUN} ] \
&& echo $FCPLUN > /sys/bus/ccw/drivers/zfcp/${DEVICE}/${WWPN}/unit_add
;;
esac
done
fi
2021-10-06 17:40:09 +00:00
exit 0