diff options
-rwxr-xr-x | builder/dnbd3-rootfs/hooks/prepare-root-partition.sh | 9 | ||||
-rwxr-xr-x | dev-tools/exampleDracutModule/apply-package.sh | 37 |
2 files changed, 37 insertions, 9 deletions
diff --git a/builder/dnbd3-rootfs/hooks/prepare-root-partition.sh b/builder/dnbd3-rootfs/hooks/prepare-root-partition.sh index b57a915c..f97b04ce 100755 --- a/builder/dnbd3-rootfs/hooks/prepare-root-partition.sh +++ b/builder/dnbd3-rootfs/hooks/prepare-root-partition.sh @@ -84,15 +84,13 @@ else writable_device="$(losetup --find)" losetup "$writable_device" "$ramdisk_location" fi - - # endregion # region connect dnbd3 IFS_backup="$IFS" IFS="," return_code=1 for host in ${SLX_DNBD3_SERVERS}; do - logging.info "Trying host \"host\"." + logging.info "Trying host \"$host\"." if systemd-preserve-process-marker dnbd3-client --host "$host" --image \ "${SLX_DNBD3_IMAGE}" --device "$SLX_DNBD3_DEVICE" \ --rid "$SLX_DNBD3_RID" @@ -104,8 +102,9 @@ done IFS="$IFS_backup" if [[ $return_code != 0 ]]; then - logging.warn "Failed to connect '${SLX_DNBD3_IMAGE}' from" \ - "one of '$SLX_DNBD3_SERVERS' to '$SLX_DNBD3_DEVICE'." + logging.warn "Failed to connect \"${SLX_DNBD3_IMAGE}\" (revision" \ + "\"$SLX_DNBD3_RID\") from one of \"$SLX_DNBD3_SERVERS\" to" \ + "\"$SLX_DNBD3_DEVICE\"." exit 1 fi # endregion diff --git a/dev-tools/exampleDracutModule/apply-package.sh b/dev-tools/exampleDracutModule/apply-package.sh index 218740ef..10964a5e 100755 --- a/dev-tools/exampleDracutModule/apply-package.sh +++ b/dev-tools/exampleDracutModule/apply-package.sh @@ -1,8 +1,37 @@ #!/usr/bin/env bash # -*- coding: utf-8 -*- -source /etc/openslx +source '/usr/lib/rebash/core.sh' +core.import exceptions +core.import logging +type emergency_shell >/dev/null 2>&1 || source /lib/dracut-lib.sh -echo -------------------------------------------------------------------------- -echo TEST -echo -------------------------------------------------------------------------- +exceptions.try +{ + logging.set_commands_level debug + logging.set_level debug + # NOTE: "getarg" raises an exception so deactivate exceptions for now. + exceptions.deactivate + slx_server="$(getarg slxsrv=)" + slx_server_base="$(getarg slxbase=)" + exceptions.activate + + logging.info 'Getting package.' + IFS_backup="$IFS" + IFS=',' + for host in ${slx_server}; do + logging.info "Trying host \"$host\"." + if wget --timeout 5 \ + "http://${host}/${slx_server_base}config.tar.gz" \ + --output-document '/tmp/config.tar.gz' + then + break + fi + done + IFS="$IFS_backup" +} +exceptions.catch +{ + logging.error "$exceptions_last_traceback" + emergency_shell "error in ${BASH_SOURCE[0]}" +} |