diff options
| author | torben | 2015-11-12 15:39:14 +0100 |
|---|---|---|
| committer | torben | 2015-11-12 15:39:14 +0100 |
| commit | e45f380b9caa3129ef0b8d6ea71aa7a2dcc9da9f (patch) | |
| tree | 0083ac147f85db1be5fe7babed4e9b51b13bb810 | |
| parent | Adding persistent storage support. (diff) | |
| download | systemd-init-e45f380b9caa3129ef0b8d6ea71aa7a2dcc9da9f.tar.gz systemd-init-e45f380b9caa3129ef0b8d6ea71aa7a2dcc9da9f.tar.xz systemd-init-e45f380b9caa3129ef0b8d6ea71aa7a2dcc9da9f.zip | |
Removes deprecated files.
| -rwxr-xr-x | builder/dnbd3-rootfs/hooks/pre-mount/mount-qcow.sh | 49 | ||||
| -rwxr-xr-x | builder/dnbd3-rootfs/hooks/pre-mount/prepare-root-partition.sh | 7 | ||||
| -rwxr-xr-x | builder/dnbd3-rootfs/hooks/pre-pivot/mount-tmp.sh | 24 | ||||
| -rwxr-xr-x | builder/dnbd3-rootfs/scripts/prepare-persistent-disks (renamed from builder/dnbd3-rootfs/scripts/prepare-disks) | 0 | ||||
| -rwxr-xr-x | builder/dnbd3-rootfs/scripts/setup-qcow2 | 137 |
5 files changed, 14 insertions, 203 deletions
diff --git a/builder/dnbd3-rootfs/hooks/pre-mount/mount-qcow.sh b/builder/dnbd3-rootfs/hooks/pre-mount/mount-qcow.sh deleted file mode 100755 index 290bc213..00000000 --- a/builder/dnbd3-rootfs/hooks/pre-mount/mount-qcow.sh +++ /dev/null @@ -1,49 +0,0 @@ -############################################################################### -# CHECKS -# - -SETUP_ROOTFS_SCRIPT="/sbin/setup-qcow2" - -if [ ! -e "${SETUP_ROOTFS_SCRIPT}" ]; then - warn "No such file of directory: ${SETUP_ROOTFS_SCRIPT}" - emergency_shell -n "Error in $0" - return 1 -fi - -if [ ! -x "${SETUP_ROOTFS_SCRIPT}" ]; then - warn "Cannot execute: ${SETUP_ROOTFS_SCRIPT}" - emergency_shell -n "Error in $0" - return 1 -fi - -# -# END CHECKS -############################################################################### - -############################################################################### -# MAIN CODE -# - -# ok, let's source the setup script -if ! . ${SETUP_ROOTFS_SCRIPT} ; then - warn "Could not source: ${SETUP_ROOTFS_SCRIPT}" - emergency_shell -n "Error in $0" - return 1 -fi - -# just go over the functions in the right order ;-) -for fun in connect_dnbd3 create_qcow export_qcow connect_qcow; do - if ! $fun; then - # something failed, drop a shell for debugging - warn "'$fun' failed with: $?" - emergency_shell -n "Error in $fun" - return 1 - fi -done - -# all good, we are done -return 0 - -# -# END MAIN CODE -############################################################################### diff --git a/builder/dnbd3-rootfs/hooks/pre-mount/prepare-root-partition.sh b/builder/dnbd3-rootfs/hooks/pre-mount/prepare-root-partition.sh index 41e2d387..6e6e98dc 100755 --- a/builder/dnbd3-rootfs/hooks/pre-mount/prepare-root-partition.sh +++ b/builder/dnbd3-rootfs/hooks/pre-mount/prepare-root-partition.sh @@ -24,11 +24,8 @@ local read_only_partition="$(utils_create_partition_via_offset "$nbd_device" \ # TODO implement persistent available indicator. local persistent="N" # 'P' for persistent storage, 'N' for not persistent if true; then - modprobe brd max_part=1 rd_size=524288 - local writable_device="/dev/ram0" && \ - #mknod --mode 660 "$writable_device" b 1 1 && \ - #chown root:disk "$writable_device" - mkfs.ext4 "$writable_device" + modprobe brd max_part=1 rd_size=524288 && \ + local writable_device="/dev/ram0" else # Use next free loop device. local writable_device="$(losetup -f)" && \ diff --git a/builder/dnbd3-rootfs/hooks/pre-pivot/mount-tmp.sh b/builder/dnbd3-rootfs/hooks/pre-pivot/mount-tmp.sh index 3e702064..c1366877 100755 --- a/builder/dnbd3-rootfs/hooks/pre-pivot/mount-tmp.sh +++ b/builder/dnbd3-rootfs/hooks/pre-pivot/mount-tmp.sh @@ -6,11 +6,11 @@ OPENSLX_TMP_DISK_FLAG="/tmp/openslx.disk.tmp" if [ ! -e "$OPENSLX_TMP_DISK_FLAG" ]; then - warn "'$OPENSLX_TMP_DISK_FLAG' not found!" - warn "Systemd will manage $NEWROOT/tmp on its own." - # no partition for the future /tmp found, just - # let systemd manage it then (probably a tmpfs) - return 1 + warn "'$OPENSLX_TMP_DISK_FLAG' not found!" + warn "Systemd will manage $NEWROOT/tmp on its own." + # no partition for the future /tmp found, just + # let systemd manage it then (probably a tmpfs) + return 1 fi # in /tmp/openslx.disk.tmp is the name of the device @@ -21,17 +21,17 @@ OPENSLX_TMP_DISK_DEV="$(cat $OPENSLX_TMP_DISK_FLAG)" # sanity check: is the content a block device? if [ ! -b "$OPENSLX_TMP_DISK_DEV" ]; then - warn "'$OPENSLX_TMP_DISK_DEV' appears not to be a block device!" - warn "Systemd will manage $NEWROOT/tmp on its own." - return 1 + warn "'$OPENSLX_TMP_DISK_DEV' appears not to be a block device!" + warn "Systemd will manage $NEWROOT/tmp on its own." + return 1 fi # all good, keep on if ! mount -t auto "$OPENSLX_TMP_DISK_DEV" $NEWROOT/tmp; then - # something else went wrong :( - warn "Mounting '$OPENSLX_TMP_DISK_DEV' to '$NEWROOT/tmp' failed with: $!" - warn "Systemd will manage $NEWROOT/tmp on its own." - return 1 + # something else went wrong :( + warn "Mounting '$OPENSLX_TMP_DISK_DEV' to '$NEWROOT/tmp' failed with: $!" + warn "Systemd will manage $NEWROOT/tmp on its own." + return 1 fi # still here? mount worked wohoo diff --git a/builder/dnbd3-rootfs/scripts/prepare-disks b/builder/dnbd3-rootfs/scripts/prepare-persistent-disks index 2e68dd9e..2e68dd9e 100755 --- a/builder/dnbd3-rootfs/scripts/prepare-disks +++ b/builder/dnbd3-rootfs/scripts/prepare-persistent-disks diff --git a/builder/dnbd3-rootfs/scripts/setup-qcow2 b/builder/dnbd3-rootfs/scripts/setup-qcow2 deleted file mode 100755 index 70babc17..00000000 --- a/builder/dnbd3-rootfs/scripts/setup-qcow2 +++ /dev/null @@ -1,137 +0,0 @@ -#!/usr/bin/bash - -# dracut-lib to use debugging functions -command -v warn >/dev/null || . /lib/dracut-lib.sh -command -v emergency_shell >/dev/null || . /lib/dracut-lib.sh - -############################################################################### -# GLOBALS -# -# TODO make this configurable -[ -f /opt/openslx/config ] && . /opt/openslx/config -[ -z $SLX_DNBD3_SERVER ] && SLX_DNBD3_SERVER="132.230.4.1" -[ -z $SLX_STAGE4 ] && SLX_STAGE4="stage4/joe/centos7" -[ -z $SLX_STAGE4_RID ] && SLX_STAGE4_RID="4" -declare -rg DNBD3_SERVER="$SLX_DNBD3_SERVER" -declare -rg DNBD3_IMAGE="$SLX_STAGE4" -declare -rg DNBD3_RID="$SLX_STAGE4_RID" -declare -rg DNBD3_DEVICE="/dev/dnbd0" -declare -rg QCOW_CONTAINER="/opt/openslx/system/system.qcow2" -# -# END GLOBALS -############################################################################### - -############################################################################### -# FUNCTION DEFINITIONS -# -# helper to do some sanity checks -check_dnbd3() { - if [ ! command -v "dnbd3-client" >/dev/null ]; then - warn "No 'dnbd3-client' found. Was the initramfs built correctly?" - emergency_shell -n "Error in $0" - return 1 - fi - return 0 -} - -# helper to connect to the dnbd3-server -connect_dnbd3() { - # check if it already connected - local current_image_name="$(cat /sys/block/${DNBD3_DEVICE#/dev/}/net/image_name)" - [ "x${current_image_name}" != "x(null)" ] && return 0 - - # not connected yet, do it - if ! dnbd3-client -h "${DNBD3_SERVER}" \ - -i "${DNBD3_IMAGE}" \ - -r "${DNBD3_RID}" \ - -d "${DNBD3_DEVICE}" ; then - warn "Failed to mount $DNBD3_IMAGE from $DNBD3_SERVER to $DNBD3_DEVICE" - emergency_shell -n "Error in $0" - return 1 - fi - return 0 -} - -# helper to create the qcow2 container file using -# DNBD3_DEVICE as the base of the filesystem -# QCOW_CONTAINER as the writable file -# (our future rootfs) -create_qcow() { - # check if we already created the qcow2-container - [ -e "$QCOW_CONTAINER" ] && return 0 - - # check if we have our target directory, if not create it - [ ! -d "$(busybox dirname $QCOW_CONTAINER)" ] && \ - mkdir -p "$(busybox dirname $QCOW_CONTAINER)" - - # we did not, let's create it - if ! qemu-img create -f qcow2 -o \ - backing_file="$DNBD3_DEVICE",backing_fmt=qcow2 "$QCOW_CONTAINER"; then - warn "Failed to create qcow2-Container from $DNBD3_DEVICE" - emergency_shell -n "Error in $0" - rm -f -- "$QCOW_CONTAINER" - return 1 - fi - return 0 -} -# helper to start qemu-nbd on localhost:2000 -# use our wrapper to set argv[0][0] to '@' -# this keeps qemu-nbd running after switching root -export_qcow() { - # check if we already have a qemu-nbd - if [ -e /tmp/qemu-nbd.pid ]; then - kill -0 $(cat /tmp/qemu-nbd.pid) && return 0 - fi - # since we use the wrapper, we need a little more logic to see if it runs - /usr/bin/systemd-preserve-process-marker \ - /usr/bin/qemu-nbd -t -p 2000 "$QCOW_CONTAINER" & - # the wrapper returns 255 if the qemu-nbd binary is missing - local qemu_nbd_pid="$!" - for i in 0.5 1 2; do - sleep $i - if ! kill -0 $qemu_nbd_pid; then - # not running - wait $qemu_nbd_pid - local ret_wrapper="$?" - if [ "${ret_wrapper}" -eq 127 ]; then - # wrapper was not found by bash - warn "No such file or directory: /usr/bin/systemd-preserve-process-marker" - elif [ "${ret_wrapper}" -eq 255 ]; then - # qemu-nbd was not found - warn "No such file or directory: /usr/bin/qemu-nbd" - fi - emergency_shell -n "Error in $0" - return 1 - else - # all good, qemu-nbd is running, remember its pid - echo $qemu_nbd_pid > /tmp/qemu-nbd.pid - return 0 - fi - done - # fallback - return 1 -} -# helper to mount the qcow2-container per nbd -connect_qcow() { - # try to mount the locally exported qcow2-container using nbd-client - if /usr/bin/systemd-preserve-process-marker \ - nbd-client --persist 127.0.0.1 2000 /dev/nbd0; then - # it worked, lets set the symlink to /dev/root as dracut needs it - # later on to mount that device to the future root (/sysroot) - ln -sf /dev/nbd0 /dev/root - return 0 - else - # this is pretty bad, dracut would spawn an emergency later on - # since there is no /dev/root to mount. - # For debugging purposes, we drop an emergency shell ourselves - # if the mount fails. - warn "Could not mount /dev/nbd0 from 127.0.0.1:2000." - emergency_shell -n "Error in $0" - return 1 - fi -} -# -# END FUNCTION DEFINITIONS -############################################################################### - -# No main, use functions! |
