Renaming boot scripts for refactoring them into numbered plugins.
[debian-live-boot/hramrach.git] / scripts / boot / 9990-mount-iscsi.sh
blobfd29d915ec087f9efce5c0c3e1f94a303f1a729a
1 #!/bin/sh
3 #set -e
5 do_iscsi()
7 do_netsetup
8 #modprobe ib_iser
9 modprobe iscsi_tcp
10 local debugopt=""
11 [ "${DEBUG}" = "true" ] && debugopt="-d 8"
12 #FIXME this name is supposed to be unique - some date + ifconfig hash?
13 ISCSI_INITIATORNAME="iqn.1993-08.org.debian.live:01:$(echo "${HWADDR}" | sed -e s/://g)"
14 export ISCSI_INITIATORNAME
15 if [ -n "${ISCSI_SERVER}" ] ; then
16 iscsistart $debugopt -i "${ISCSI_INITIATORNAME}" -t "${ISCSI_TARGET}" -g 1 -a "${ISCSI_SERVER}" -p "${ISCSI_PORT}"
17 else
18 iscsistart $debugopt -i "${ISCSI_INITIATORNAME}" -t "${ISCSI_TARGET}" -g 1 -a "${ISCSI_PORTAL}" -p 3260
20 if [ $? != 0 ]
21 then
22 panic "Failed to log into iscsi target"
24 local host="$(ls -d /sys/class/scsi_host/host*/device/iscsi_host:host* \
25 /sys/class/scsi_host/host*/device/iscsi_host/host* | sed -e 's:/device.*::' -e 's:.*host::')"
26 if [ -n "${host}" ]
27 then
28 local devices=""
29 local i=0
30 while [ -z "${devices}" -a $i -lt 60 ]
32 sleep 1
33 devices="$(ls -d /sys/class/scsi_device/${host}*/device/block:* \
34 /sys/class/scsi_device/${host}*/device/block/* | sed -e 's!.*[:/]!!')"
35 i=$(expr $i + 1)
36 echo -ne $i\\r
37 done
38 for dev in $devices
40 if check_dev "null" "/dev/$dev"
41 then
42 NETBOOT="iscsi"
43 export NETBOOT
44 return 0;
46 done
47 panic "Failed to locate a live device on iSCSI devices (tried: $devices)."
48 else
49 panic "Failed to locate iSCSI host in /sys"