summaryrefslogtreecommitdiffstats
path: root/builder/modules.d/dnbd3-rootfs/hooks/prepare-root-partition.sh
diff options
context:
space:
mode:
authorJonathan Bauer2020-05-13 11:04:02 +0200
committerJonathan Bauer2020-05-13 11:04:02 +0200
commit1130873aa55c9b0a7e5af48edc44bd6c6fd1f888 (patch)
tree0fcfa186cd631d8d36611b3d4bc509fd38841d51 /builder/modules.d/dnbd3-rootfs/hooks/prepare-root-partition.sh
parentMerge branch 'centos8' into downloader (diff)
downloadsystemd-init-1130873aa55c9b0a7e5af48edc44bd6c6fd1f888.tar.gz
systemd-init-1130873aa55c9b0a7e5af48edc44bd6c6fd1f888.tar.xz
systemd-init-1130873aa55c9b0a7e5af48edc44bd6c6fd1f888.zip
restructure repo
* remove packager * move everything from builder/* back to root
Diffstat (limited to 'builder/modules.d/dnbd3-rootfs/hooks/prepare-root-partition.sh')
-rwxr-xr-xbuilder/modules.d/dnbd3-rootfs/hooks/prepare-root-partition.sh107
1 files changed, 0 insertions, 107 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
deleted file mode 100755
index aa782184..00000000
--- a/builder/modules.d/dnbd3-rootfs/hooks/prepare-root-partition.sh
+++ /dev/null
@@ -1,107 +0,0 @@
-#!/usr/bin/env bash
-type emergency_shell > /dev/null 2>&1 || source /lib/dracut-lib.sh
-source /etc/openslx
-
-export PATH="/usr/local/bin:$PATH"
-export LD_LIBRARY_PATH="/usr/local/lib"
-
-
-# hardcode dnbd device path
-declare -rg _dnbd3_dev="/dev/dnbd0"
-
-# all outputs are redirected to stderr, since this functions should
-# only echo the path to the unpacked container to stdout.
-container_unpack_xmount() {
- local in_device="$1"
- local out_path="/mnt/xmount"
- mkdir -p "$out_path"
- # check tools first
- if ! hash xmount systemd-preserve-process-marker; then
- 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
- 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
- warn "Failed to attach '$in_device' to '$out_device'."
- return 1
- fi
- udevadm settle
- echo "$out_device"
-}
-
-container_unpack_losetup() {
- local in_device="$1"
- local out_device="$(losetup -f)"
- if ! losetup -r -t QCOW "$out_device" "$in_device" --partscan; then
- warn "Failed to attach '$in_device' to '$out_device'."
- return
- fi
- udevadm settle
- echo "$out_device"
-}
-# endregion
-
-(
-IFS=", "
-for host in ${SLX_DNBD3_SERVERS} FAIL; do
- if [ "$host" = "FAIL" ]; then
- emergency_shell "Failed to connect '${SLX_DNBD3_IMAGE}' "\
- "${SLX_DNBD3_RID:+(revision: $SLX_DNBD3_RID)} "
- "from one of '$SLX_DNBD3_SERVERS' to '$_dnbd3_dev'."
- fi
- info "Trying host \"$host\"."
- if systemd-preserve-process-marker dnbd3-client \
- --host "$host" \
- --image "${SLX_DNBD3_IMAGE}" \
- --device "$_dnbd3_dev" \
- ${SLX_DNBD3_RID:+--rid "$SLX_DNBD3_RID"}; then
- break
- fi
-done
-)
-# endregion
-# region unpack dnbd3 image
-[ -z "$SLX_QCOW_HANDLER" ] && SLX_QCOW_HANDLER="xmount"
-if [ "$SLX_QCOW_HANDLER" = "xmount" ]; then
- read_only_device="$(container_unpack_xmount "$_dnbd3_dev")"
-elif [ "$SLX_QCOW_HANDLER" = "kernel" ]; then
- read_only_device="$(container_unpack_losetup "$_dnbd3_dev")"
-else
- warn "Unsupported QCOW handler: $SLX_QCOW_HANDLER"
-fi
-
-# Fail fast if unpacking dnbd3 image failed.
-[ -z "$read_only_device" ] && exit 1
-
-# endregion
-# region find system partition within dnbd3 image
-if [ -z "$SLX_SYSTEM_PARTITION_PREPARATION_SCRIPT" ]; then
- if [ -z "$SLX_SYSTEM_PARTITION_IDENTIFIER" ]; then
- # if empty use whole device
- read_only_partition="$read_only_device"
- true
- else
- read_only_partition="$(slx-tools dev_find_partitions \
- "$read_only_device" "$SLX_SYSTEM_PARTITION_IDENTIFIER")"
- fi
-else
- eval "$SLX_SYSTEM_PARTITION_PREPARATION_SCRIPT"
-fi
-if [[ ! $? || -z "$read_only_partition" ]]; then
- warn "Failed to find unique device with identifier" \
- "\"${SLX_SYSTEM_PARTITION_IDENTIFIER}\"; matched devices:" \
- "\"${read_only_partition}\""
- exit 1
-fi
-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