network: don't use "ifup -m"
[dracut.git] / modules.d / 95zfcp_rules / parse-zfcp.sh
bloba3282d29aff7f6dd83afad4d72fded9c3ab7b7ca
1 #!/bin/sh
3 create_udev_rule() {
4 local ccw=$1
5 local wwpn=$2
6 local lun=$3
7 local _rule=/etc/udev/rules.d/51-zfcp-${ccw}.rules
9 local _cu_type _dev_type
10 local _rule=/etc/udev/rules.d/51-zfcp-${ccw}.rules
12 if [ -e /sys/bus/ccw/devices/${ccw} ] ; then
13 read _cu_type < /sys/bus/ccw/devices/${ccw}/cutype
14 read _dev_type < /sys/bus/ccw/devices/${ccw}/devtype
16 if [ "$_cu_type" != "1731/03" ] ; then
17 return 0;
19 if [ "$_dev_type" != "1732/03" ] && [ "$_dev_type" != "1732/04" ] ; then
20 return 0;
23 [ -e ${_rule} ] && return 0
25 if [ ! -f "$_rule" ] ; then
26 cat > $_rule <<EOF
27 ACTION=="add", SUBSYSTEM=="ccw", KERNEL=="$ccw", IMPORT{program}="collect $ccw %k ${ccw} zfcp"
28 ACTION=="add", SUBSYSTEM=="drivers", KERNEL=="zfcp", IMPORT{program}="collect $ccw %k ${ccw} zfcp"
29 ACTION=="add", ENV{COLLECT_$ccw}=="0", ATTR{[ccw/$ccw]online}="1"
30 EOF
32 m=$(sed -n "/.*${wwpn}.*${lun}.*/p" $_rule)
33 if [ -z "$m" ] ; then
34 cat >> $_rule <<EOF
35 ACTION=="add", KERNEL=="rport-*", ATTR{port_name}=="$wwpn", SUBSYSTEMS=="ccw", KERNELS=="$ccw", ATTR{[ccw/$ccw]$wwpn/unit_add}="$lun"
36 EOF
40 for zfcp_arg in $(getargs rd.zfcp); do
42 IFS=","
43 set $zfcp_arg
44 create_udev_rule $1 $2 $3
46 done
48 for zfcp_arg in $(getargs root=) $(getargs resume=); do
50 case $zfcp_arg in
51 /dev/disk/by-path/ccw-*)
52 ccw_arg=${zfcp_arg##*/}
53 break;
54 esac
55 if [ -n "$ccw_arg" ] ; then
56 IFS="-"
57 set -- $ccw_arg
58 wwpn=${4%:*}
59 lun=${4#*:}
60 create_udev_rule $2 $wwpn $lun
63 done