#!/bin/sh # Check if are in the initramfs environment if [ "$BOOT" = "local" ]; then # Get any iscsi command line parameters - cmdline parsing template taken from init script in initramfs for x in $(cat /proc/cmdline); do case $x in iscsi_ip=*) iscsi_ip=${x#iscsi_ip=} ;; iscsi_iqn=*) iscsi_iqn=${x#iscsi_iqn=} ;; iscsi_user=*) iscsi_user=${x#iscsi_user=} ;; iscsi_pw=*) iscsi_pw=${x#iscsi_pw=} ;; esac done # end of cmdline parsing if [ -n "${iscsi_ip}" ]; then iscsi_name='iqn.2000-09.org.local:UNKNOWN' fi # Check if an iscsi environment exists and start up the networking environment if [ -e /sys/firmware/ibft/target0/target-name -o -n "${iscsi_ip}" ]; then x=5 # Wait up to x seconds for a network interface to pop up echo -n "Searching for network cards..." until ifconfig -a|grep -q Ethernet; do sleep 1 echo -n . x=$(($x - 1)) if [ $x = 0 ]; then echo "No network cards detected!" exit 0 fi done # end of until echo "Searching for an dhcp server on all network interfaces..." CNT=5 until ifconfig ${netdev}|grep -q "inet addr"; do for netdev in `ifconfig -a|grep Ethernet|cut -d' ' -f1`; do # Do a round-robin search for dhcp servers #ip link set ${netdev} mtu 2500 # Optional: increase mtu for performance ip link set ${netdev} up # try to bring up the interface ipconfig -t 2 -c dhcp -d ${netdev} # Get an IP if ifconfig -a|grep -q "inet addr"; then break 2; fi # If we have got an address, stop searching. done # end of netdev probing CNT=$((${CNT} - 1)) if [ ${CNT} = 0 ]; then echo "No dhcp servers found!" exit 0 fi echo "Tries left: ${CNT}" done # end of until if [ -e /sys/firmware/ibft/target0/target-name ]; then #iscsistart -b # This should get the ibft parameters but it does not yet. # Lets do the following instead iscsistart \ -i `cat /sys/firmware/ibft/initiator/initiator-name` \ -t `cat /sys/firmware/ibft/target0/target-name` \ -a `cat /sys/firmware/ibft/target0/ip-addr` \ -u `cat /sys/firmware/ibft/target0/chap-name` \ -w `cat /sys/firmware/ibft/target0/chap-secret` \ -g 1 else iscsistart -i ${iscsi_name} -t ${iscsi_iqn} -a ${iscsi_ip} -u ${iscsi_user} -w ${iscsi_pw} -g 1 fi # end of iscsi firmware check fi # end of iscsi env check fi # end of initramfs check