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