Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Generate iSCSI Initiator Name
#!/usr/bin/env bash
set -eu
INAME=/etc/iscsi/initiatorname.iscsi
InitiatorName=""
if [ -e ${INAME} ]; then
. ${INAME}
if [ "$InitiatorName" != "" ]; then
# nothing to do.
exit 0
fi
echo "WARN: The iSCSI initiator name is blank." >&2
echo "WARN: Regenerate iSCSI initiator name and overwrite the file." >&2
fi
cat <<EOF > ${INAME}
## DO NOT EDIT OR REMOVE THIS FILE!
## If you remove this file, the iSCSI daemon will not start.
## If you change the InitiatorName, existing access control lists
## may reject this initiator. The InitiatorName must be unique
## for each iSCSI initiator. Do NOT duplicate iSCSI InitiatorNames.
InitiatorName=`/sbin/iscsi-iname -p iqn.1993-08.org.debian:01`
EOF
chown root:root ${INAME}
chmod 600 ${INAME}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment