File mkinitrd-boot.sh of Package open-fcoe

#!/bin/bash
#%stage: device
#%depends: network lldpad
#%programs: /usr/sbin/fipvlan /usr/sbin/fcoeadm /sbin/vconfig /sbin/ip
#%modules: fcoe 8021q
#%if: "$root_fcoe"
#
##### FCoE initialization
##
## This script initializes FCoE (FC over Ethernet).

load_modules

create_fcoe_vlan()
{
    local if=$1
    local vlan=$2
    local vif=$3

    vconfig add $if $vlan
    tmp_vif=$(sed -n "s/\([^ ]*\).*${vlan}.*${if}/\1/p" /proc/net/vlan/config)
    if [ "$vif" ] && [ "$tmp_vif" != "$vif" ] ; then
	ip link set dev $tmp_vif name $vif
    fi
    wait_for_events
    ip link set $if up
    ip link set $vif up
}

wait_for_fcoe_if()
{
    local ifname=$1
    local retry_count=$udev_timeout

    echo -n "Wait for FCoE link on $ifname: "
    while [ $retry_count -gt 0 ] ; do
	status=$(/usr/sbin/fcoeadm -i $ifname 2> /dev/null | sed -n "s/.*State: *\(.*\)/\1/p")
	if [ "$status" = "Online" ] ; then
	    echo "Ok"
	    return 0
	fi
	echo -n "."
        retry_count=$(($retry_count-1))
        sleep 2
    done

    echo "Failed; dropping to /bin/sh"
    cd /
    PATH=$PATH PS1='$ ' /bin/sh -i
}

create_fcoe_vlan $fcoe_if $fcoe_vlan $fcoe_vif
/usr/sbin/fipvlan -s $fcoe_if
wait_for_fcoe_if $fcoe_vif
openSUSE Build Service is sponsored by