test: support open-iscsi >= 2.1.2

Since open-iscsi 2.1.2 [0] the initiator name should be generated via
a one-time service instead of distro package's post-install scripts.
However, some distros still use this approach even after this patch,
so prefer the already existing initiatorname.iscsi file if it exists.

[0] f37d5b653f
This commit is contained in:
Frantisek Sumsal 2022-09-26 23:14:18 +02:00
parent dd51b0f952
commit d9e1cb288f

View File

@ -1026,7 +1026,17 @@ install_iscsi() {
mkdir -p "${initdir:?}"/var/lib/iscsi/{ifaces,isns,nodes,send_targets,slp,static}
mkdir -p "${initdir:?}/etc/iscsi"
echo "iscsid.startup = /bin/systemctl start iscsid.socket" >"${initdir:?}/etc/iscsi/iscsid.conf"
inst_simple "/etc/iscsi/initiatorname.iscsi"
# Since open-iscsi 2.1.2 [0] the initiator name should be generated via
# a one-time service instead of distro package's post-install scripts.
# However, some distros still use this approach even after this patch,
# so prefer the already existing initiatorname.iscsi file if it exists.
#
# [0] https://github.com/open-iscsi/open-iscsi/commit/f37d5b653f9f251845db3f29b1a3dcb90ec89731
if [[ ! -e /etc/iscsi/initiatorname.iscsi ]]; then
image_install "${ROOTLIBDIR:?}"/system/iscsi-init.service
else
inst_simple "/etc/iscsi/initiatorname.iscsi"
fi
fi
# Install server-side stuff ("target" in iSCSI jargon) - TGT in this case