Last active
April 8, 2021 05:52
-
-
Save yasuoohno/6bc378eef199a1ca874c174d9546dcb9 to your computer and use it in GitHub Desktop.
Generate iSCSI Initiator Name
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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