diff options
author | Thiago Abdo | 2019-11-06 14:28:47 +0100 |
---|---|---|
committer | Thiago Abdo | 2019-11-06 14:28:47 +0100 |
commit | 5d80709e96b74a27443ff6538f2c000442308471 (patch) | |
tree | 52a0f26694303206ad2ee112c4707fa0af5ca994 /builder/modules.d/dnbd3-rootfs/hooks/prepare-root-partition.sh | |
parent | Merge branch 'centos8' of git.openslx.org:openslx-ng/systemd-init into centos8 (diff) | |
parent | fix include (diff) | |
download | systemd-init-5d80709e96b74a27443ff6538f2c000442308471.tar.gz systemd-init-5d80709e96b74a27443ff6538f2c000442308471.tar.xz systemd-init-5d80709e96b74a27443ff6538f2c000442308471.zip |
Merge branch 'nobash' into centos8
Diffstat (limited to 'builder/modules.d/dnbd3-rootfs/hooks/prepare-root-partition.sh')
-rwxr-xr-x | builder/modules.d/dnbd3-rootfs/hooks/prepare-root-partition.sh | 43 |
1 files changed, 9 insertions, 34 deletions
diff --git a/builder/modules.d/dnbd3-rootfs/hooks/prepare-root-partition.sh b/builder/modules.d/dnbd3-rootfs/hooks/prepare-root-partition.sh index 8b5343cc..aa782184 100755 --- a/builder/modules.d/dnbd3-rootfs/hooks/prepare-root-partition.sh +++ b/builder/modules.d/dnbd3-rootfs/hooks/prepare-root-partition.sh @@ -1,20 +1,11 @@ #!/usr/bin/env bash -# region imports type emergency_shell > /dev/null 2>&1 || source /lib/dracut-lib.sh source /etc/openslx -source '/usr/lib/rebash/core.sh' export PATH="/usr/local/bin:$PATH" - -# quick fix, this must not be here! export LD_LIBRARY_PATH="/usr/local/lib" -core.import exceptions -core.import logging -# endregion -# region globals/helper -logging.set_log_file "${SLX_LOG_FILE_PATH:-/var/log/openslx}" # hardcode dnbd device path declare -rg _dnbd3_dev="/dev/dnbd0" @@ -26,18 +17,18 @@ container_unpack_xmount() { mkdir -p "$out_path" # check tools first if ! hash xmount systemd-preserve-process-marker; then - logging.warn "Missing xmount deps, will try raw..." 1>&2 + warn "Missing xmount deps, will try raw..." 1>&2 elif ! systemd-preserve-process-marker xmount \ --in qemu "$in_device" \ --out raw "$out_path" &>/dev/null; then - logging.warn "xmount call failed, assuming raw image." 1>&2 + warn "xmount call failed, assuming raw image." 1>&2 else in_device="${out_path}/${_dnbd3_dev##*/}.dd" fi local out_device="$(losetup -f)" if ! losetup "$out_device" "$in_device" --partscan; then - logging.warn "Failed to attach '$in_device' to '$out_device'." - return + warn "Failed to attach '$in_device' to '$out_device'." + return 1 fi udevadm settle echo "$out_device" @@ -47,7 +38,7 @@ container_unpack_losetup() { local in_device="$1" local out_device="$(losetup -f)" if ! losetup -r -t QCOW "$out_device" "$in_device" --partscan; then - logging.warn "Failed to attach '$in_device' to '$out_device'." + warn "Failed to attach '$in_device' to '$out_device'." return fi udevadm settle @@ -55,9 +46,6 @@ container_unpack_losetup() { } # endregion -exceptions.try -{ -# region connect dnbd3 image ( IFS=", " for host in ${SLX_DNBD3_SERVERS} FAIL; do @@ -66,7 +54,7 @@ for host in ${SLX_DNBD3_SERVERS} FAIL; do "${SLX_DNBD3_RID:+(revision: $SLX_DNBD3_RID)} " "from one of '$SLX_DNBD3_SERVERS' to '$_dnbd3_dev'." fi - logging.info "Trying host \"$host\"." + info "Trying host \"$host\"." if systemd-preserve-process-marker dnbd3-client \ --host "$host" \ --image "${SLX_DNBD3_IMAGE}" \ @@ -84,7 +72,7 @@ if [ "$SLX_QCOW_HANDLER" = "xmount" ]; then elif [ "$SLX_QCOW_HANDLER" = "kernel" ]; then read_only_device="$(container_unpack_losetup "$_dnbd3_dev")" else - logging.warn "Unsupported QCOW handler: $SLX_QCOW_HANDLER" + warn "Unsupported QCOW handler: $SLX_QCOW_HANDLER" fi # Fail fast if unpacking dnbd3 image failed. @@ -105,28 +93,15 @@ else eval "$SLX_SYSTEM_PARTITION_PREPARATION_SCRIPT" fi if [[ ! $? || -z "$read_only_partition" ]]; then - logging.error "Failed to find unique device with identifier" \ + warn "Failed to find unique device with identifier" \ "\"${SLX_SYSTEM_PARTITION_IDENTIFIER}\"; matched devices:" \ "\"${read_only_partition}\"" exit 1 fi -logging.info "Using read-only partition: $read_only_partition" +info "Using read-only partition: $read_only_partition" # endregion # region add rw layer to dnbd3 image # don't be fooled to think we are done, the next part is crucial dmsetup-slx-device "$read_only_partition" # endregion - -} -exceptions.catch -{ - logging.error "$exceptions_last_traceback" - emergency_shell "error in ${BASH_SOURCE[0]}" -} -# region vim modline - -# vim: set tabstop=4 shiftwidth=4 expandtab: -# vim: foldmethod=marker foldmarker=region,endregion: - -# endregion |