From df506a6857b0a3395c4a65fa564f094ae0f5ffc7 Mon Sep 17 00:00:00 2001 From: Hannes Reinecke Date: Tue, 6 Oct 2009 09:01:28 +0200 Subject: [PATCH] mkinitrd: Add script for iBFT setup iBFT has a dual purpose, one to figure out the target to connect to and the other to setup the network properly. So we need some additional scripts to set it up properly. References: bnc#541892 Signed-off-by: Hannes Reinecke diff --git a/Makefile b/Makefile index de66ae1..f544ac4 100644 --- a/Makefile +++ b/Makefile @@ -89,6 +89,10 @@ install_initd_suse: $(DESTDIR)$(mkinitrd)/setup-iscsi.sh $(INSTALL) -m 755 etc/mkinitrd/mkinitrd-stop.sh \ $(DESTDIR)$(mkinitrd)/boot-killiscsi.sh + $(INSTALL) -m 755 etc/mkinitrd/ibft-boot.sh \ + $(DESTDIR)$(mkinitrd)/boot-ibft.sh + $(INSTALL) -m 755 etc/mkinitrd/ibft-setup.sh \ + $(DESTDIR)$(mkinitrd)/setup-ibft.sh install_initd_redhat: $(INSTALL) -d $(DESTDIR)$(initddir) diff --git a/etc/mkinitrd/ibft-boot.sh b/etc/mkinitrd/ibft-boot.sh new file mode 100644 index 0000000..61cdd14 --- /dev/null +++ b/etc/mkinitrd/ibft-boot.sh @@ -0,0 +1,49 @@ +#!/bin/bash +#%stage: device +#%modules: iscsi_ibft +#%if: "$ibft_available" +#: ${ibft_nic:=/sys/firmware/ibft/ethernet0} +# +###### iBFT network configuration +## +## This script obtains network configuration parameters +## from the iBFT, if available + +load_modules + +ibft_get_att() { + if [ -f $ibft_nic/$1 ]; then + cat $ibft_nic/$1 + else + echo "" + fi +} + +ibft_get_ethdev() { + (cd $ibft_nic/device/net; ls -d eth* 2>/dev/null) +} + +ibft_get_initiatorname() { + cat /sys/firmware/ibft/initiator/initiator-name +} + +print_par() { + local val + while [ $# -gt 0 ]; do + eval "val=\$$1" + echo "[IBFT] $1='$val'" + shift + done +} + +if [ -d $ibft_nic ]; then + if [ -s $ibft_nic/dhcp ]; then + nettype='dhcp' + else + nettype='static' + fi + ip="$(ibft_get_att ip-addr)::$(ibft_get_att gateway):$(ibft_get_att subnet-mask):$ibft_hostname:$(ibft_get_ethdev):$nettype" + interface=$(ibft_get_ethdev) + macaddress=$(ibft_get_att mac) + InitiatorName=$(ibft_get_initiatorname) +fi diff --git a/etc/mkinitrd/ibft-setup.sh b/etc/mkinitrd/ibft-setup.sh new file mode 100644 index 0000000..b3137ed --- /dev/null +++ b/etc/mkinitrd/ibft-setup.sh @@ -0,0 +1,27 @@ +#!/bin/bash +# +#%stage: device +#%depends: network + +ibft_set_iface() { + local if=$(cd $ibft_nic/device/net; ls -d eth* 2>/dev/null) + [ "$if" ] && { + interface=$if + if [ ! "$nettype" -a -e $ibft_nic/dhcp ]; then + nettype=dhcp + else + nettype=static + fi + } +} + +ibft_nic=/sys/firmware/ibft/ethernet0 +ibft_hostname=$(hostname) + +if [ "$root_iscsi" = 1 -a -d $ibft_nic ]; then + ibft_available=1 + ibft_set_iface +fi +save_var ibft_available +save_var ibft_hostname +save_var ibft_nic