Skip to content

Instantly share code, notes, and snippets.

@yasuoohno
Last active April 8, 2021 05:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yasuoohno/6bc378eef199a1ca874c174d9546dcb9 to your computer and use it in GitHub Desktop.
Save yasuoohno/6bc378eef199a1ca874c174d9546dcb9 to your computer and use it in GitHub Desktop.
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