#! /bin/sh

# This is basically a version of the init script without dependencies on lsb
# and without all the sanity checks. The installer is a clean environment, so
# we don't need all of that.

# Generate a unique InitiatorName and save it
INAME=`iscsi-iname -p iqn.1993-08.org.debian:01`
echo "## DO NOT EDIT OR REMOVE THIS FILE!" > /etc/iscsi/initiatorname.iscsi
echo "## If you remove this file, the iSCSI daemon will not start." >> /etc/iscsi/initiatorname.iscsi
echo "## If you change the InitiatorName, existing access control lists" >> /etc/iscsi/initiatorname.iscsi
echo "## may reject this initiator.  The InitiatorName must be unique">> /etc/iscsi/initiatorname.iscsi
echo "## for each iSCSI initiator.  Do NOT duplicate iSCSI InitiatorNames." >> /etc/iscsi/initiatorname.iscsi
printf "InitiatorName=$INAME\n"  >> /etc/iscsi/initiatorname.iscsi
chmod 600 /etc/iscsi/initiatorname.iscsi

modprobe -q iscsi_tcp 2>/dev/null >&2
/sbin/iscsid
