From 5a9dc6ae08222a58d5275aa94d5d070bd4acad49 Mon Sep 17 00:00:00 2001 From: Fabio Erculiani Date: Fri, 13 Sep 2013 15:47:13 +0200 Subject: [PATCH] initrd.scripts: move iscsi code to 00-iscsi.sh --- defaults/initrd.d/00-iscsi.sh | 70 +++++++++++++++++++++++++++++++++++ defaults/initrd.scripts | 60 +----------------------------- 2 files changed, 71 insertions(+), 59 deletions(-) create mode 100755 defaults/initrd.d/00-iscsi.sh diff --git a/defaults/initrd.d/00-iscsi.sh b/defaults/initrd.d/00-iscsi.sh new file mode 100755 index 0000000..b7764a7 --- /dev/null +++ b/defaults/initrd.d/00-iscsi.sh @@ -0,0 +1,70 @@ +#!/bin/sh + +. /etc/initrd.d/00-common.sh + +start_iscsi() { + if [ ! -e /usr/sbin/iscsistart ]; then + return 0 # disabled + fi + + if [ ! -n "${ISCSI_NOIBFT}" ]; then + good_msg "Activating iSCSI via iBFT" + iscsistart -b + fi + + if [ -z "${ISCSI_INITIATORNAME}" ]; then + warn_msg "No iSCSI initiator found" + return 0 + fi + + if [ -z "${ISCSI_TARGET}" ]; then + warn_msg "No iSCSI target found" + return 0 + fi + + if [ -z "${ISCSI_ADDRESS}" ]; then + warn_msg "No iSCSI address found" + return 0 + fi + + good_msg "Activating iSCSI via cmdline" + + if [ "${ISCSI_TGPT}" ]; then + ADDITIONAL="${ADDITIONAL} -g ${ISCSI_TGPT}" + else + ADDITIONAL="${ADDITIONAL} -g 1" + fi + + if [ "${ISCSI_PORT}" ]; then + ADDITIONAL="${ADDITIONAL} -p ${ISCSI_PORT}" + fi + + if [ "${ISCSI_USERNAME}" ]; then + ADDITIONAL="${ADDITIONAL} -u ${ISCSI_USERNAME}" + fi + + if [ "${ISCSI_PASSWORD}" ]; then + ADDITIONAL="${ADDITIONAL} -w ${ISCSI_PASSWORD}" + fi + + if [ "${ISCSI_USERNAME_IN}" ]; then + ADDITIONAL="${ADDITIONAL} -U ${ISCSI_USERNAME_IN}" + fi + + if [ "${ISCSI_PASSWORD_IN}" ]; then + ADDITIONAL="${ADDITIONAL} -W ${ISCSI_PASSWORD_IN}" + fi + + if [ "${ISCSI_DEBUG}" ]; then + ADDITIONAL="${ADDITIONAL} -d ${ISCSI_DEBUG}" + fi + + iscsistart -i "${ISCSI_INITIATORNAME}" -t "${ISCSI_TARGET}" \ + -a "${ISCSI_ADDRESS}" ${ADDITIONAL} + + # let iscsid settle - otherwise mounting the iSCSI-disk + # will fail (very rarely, though) + # TODO(lxnay): this is horrible, find a real synchronization + # technique. + sleep 1 +} diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts index 53878e6..76b38f5 100755 --- a/defaults/initrd.scripts +++ b/defaults/initrd.scripts @@ -12,6 +12,7 @@ . /etc/initrd.d/00-keymaps.sh . /etc/initrd.d/00-crypt.sh . /etc/initrd.d/00-suspend.sh +. /etc/initrd.d/00-iscsi.sh real_root_init() { @@ -26,65 +27,6 @@ real_root_init() { fi } -start_iscsi() { - if [ ! -e /usr/sbin/iscsistart ]; then - return 0 # disabled - fi - - if [ ! -n "${ISCSI_NOIBFT}" ] - then - good_msg "Activating iSCSI via iBFT" - iscsistart -b - fi - - if [ -n "${ISCSI_INITIATORNAME}" ] && [ -n "${ISCSI_TARGET}" ] && [ -n "${ISCSI_ADDRESS}" ]; then - good_msg "Activating iSCSI via cmdline" - - if [ "${ISCSI_TGPT}" ] - then - ADDITIONAL="${ADDITIONAL} -g ${ISCSI_TGPT}" - else - ADDITIONAL="${ADDITIONAL} -g 1" - fi - if [ "${ISCSI_PORT}" ] - then - ADDITIONAL="${ADDITIONAL} -p ${ISCSI_PORT}" - fi - - if [ "${ISCSI_USERNAME}" ] - then - ADDITIONAL="${ADDITIONAL} -u ${ISCSI_USERNAME}" - fi - - if [ "${ISCSI_PASSWORD}" ] - then - ADDITIONAL="${ADDITIONAL} -w ${ISCSI_PASSWORD}" - fi - - if [ "${ISCSI_USERNAME_IN}" ] - then - ADDITIONAL="${ADDITIONAL} -U ${ISCSI_USERNAME_IN}" - fi - - if [ "${ISCSI_PASSWORD_IN}" ] - then - ADDITIONAL="${ADDITIONAL} -W ${ISCSI_PASSWORD_IN}" - fi - - if [ "${ISCSI_DEBUG}" ] - then - ADDITIONAL="${ADDITIONAL} -d ${ISCSI_DEBUG}" - fi - - iscsistart -i "${ISCSI_INITIATORNAME}" -t "${ISCSI_TARGET}" \ - -a "${ISCSI_ADDRESS}" ${ADDITIONAL} - - # let iscsid settle - otherwise mounting the iSCSI-disk - # will fail (very rarely, though) - sleep 1 - fi -} - getdvhoff() { echo $(( $(hexdump -n 4 -s $((316 + 12 * $2)) -e '"%i"' $1) * 512)) }