summaryrefslogtreecommitdiff
path: root/scripts/boot/9990-mount-iscsi.sh
diff options
context:
space:
mode:
authorTails developers <amnesia@boum.org>2012-12-07 22:31:36 +0100
committerDaniel Baumann <mail@daniel-baumann.ch>2013-05-06 13:54:13 +0200
commitd7c33ee024a4c044345e9d5b79ad039c8dafd8cd (patch)
tree5c7ba6e7dc5c038b3c9c43c4c12eb16c79b7a277 /scripts/boot/9990-mount-iscsi.sh
parent82b09bfb04c51925877df3c5b8efaac9db6d4e5b (diff)
downloadlive-boot-d7c33ee024a4c044345e9d5b79ad039c8dafd8cd.tar.gz
live-boot-d7c33ee024a4c044345e9d5b79ad039c8dafd8cd.zip
Using 'local' in a safe way.
First of all, 'local' is non-POSIX, but it is a really good safeguard against hard-to-find bugs. However, doing a local + initializing combo like `local X=$Y` in dash is error prone. If `Y=1 2` will get an error since dash will expand $Y so we get `local X=1 2`, but it will treat the "2" as another variable to be made local, which isn't what we want. Hence, let's declare variables local and initialize them in separate commands, which is safe.
Diffstat (limited to 'scripts/boot/9990-mount-iscsi.sh')
-rwxr-xr-xscripts/boot/9990-mount-iscsi.sh13
1 files changed, 8 insertions, 5 deletions
diff --git a/scripts/boot/9990-mount-iscsi.sh b/scripts/boot/9990-mount-iscsi.sh
index fd29d91..6ce9851 100755
--- a/scripts/boot/9990-mount-iscsi.sh
+++ b/scripts/boot/9990-mount-iscsi.sh
@@ -7,7 +7,8 @@ do_iscsi()
do_netsetup
#modprobe ib_iser
modprobe iscsi_tcp
- local debugopt=""
+ local debugopt
+ debugopt=""
[ "${DEBUG}" = "true" ] && debugopt="-d 8"
#FIXME this name is supposed to be unique - some date + ifconfig hash?
ISCSI_INITIATORNAME="iqn.1993-08.org.debian.live:01:$(echo "${HWADDR}" | sed -e s/://g)"
@@ -21,12 +22,14 @@ do_iscsi()
then
panic "Failed to log into iscsi target"
fi
- local host="$(ls -d /sys/class/scsi_host/host*/device/iscsi_host:host* \
- /sys/class/scsi_host/host*/device/iscsi_host/host* | sed -e 's:/device.*::' -e 's:.*host::')"
+ local host
+ host="$(ls -d /sys/class/scsi_host/host*/device/iscsi_host:host* \
+ /sys/class/scsi_host/host*/device/iscsi_host/host* | sed -e 's:/device.*::' -e 's:.*host::')"
if [ -n "${host}" ]
then
- local devices=""
- local i=0
+ local devices i
+ devices=""
+ i=0
while [ -z "${devices}" -a $i -lt 60 ]
do
sleep 1