diff options
Diffstat (limited to 'modules.d')
-rwxr-xr-x | modules.d/dnbd3-rootfs/hooks/s3-mount-root.sh | 14 | ||||
-rwxr-xr-x | modules.d/dnbd3-rootfs/hooks/s3-write-fstab.sh | 15 | ||||
-rwxr-xr-x | modules.d/dnbd3-rootfs/module-setup.sh | 2 | ||||
-rwxr-xr-x | modules.d/slx-extra-script/hooks/s3-extra-script.sh | 12 | ||||
-rwxr-xr-x | modules.d/slx-extra-script/module-setup.sh | 5 | ||||
-rw-r--r-- | modules.d/slx-extra-script/services/s3-extra-post-dmsetup.service | 13 |
6 files changed, 46 insertions, 15 deletions
diff --git a/modules.d/dnbd3-rootfs/hooks/s3-mount-root.sh b/modules.d/dnbd3-rootfs/hooks/s3-mount-root.sh index 2f5fc15f..78410fce 100755 --- a/modules.d/dnbd3-rootfs/hooks/s3-mount-root.sh +++ b/modules.d/dnbd3-rootfs/hooks/s3-mount-root.sh @@ -1,5 +1,6 @@ #!/bin/bash +type emergency_shell >/dev/null 2>&1 || source /lib/dracut-lib.sh # $NEWROOT source "/etc/openslx" cnt=0 @@ -14,23 +15,20 @@ done ret=99 if [ -n "$SLX_MOUNT_ROOT_OPTIONS" ]; then # Always prefer mount options mandated by server + echo "Mounting with provided options: $SLX_MOUNT_ROOT_OPTIONS" mount "$SLX_DNBD3_DEVICE_COW" "$NEWROOT" $SLX_MOUNT_ROOT_OPTIONS ret=$? else # Let's guess it's ext4, tune for maximum performance as we don't care about recoverability - mount "$SLX_DNBD3_DEVICE_COW" "$NEWROOT" -o data=writeback,barrier=0,commit=60,noinit_itable,discard,noatime + echo "Trying optimized ext4 mount options..." + mount -t ext4 "$SLX_DNBD3_DEVICE_COW" "$NEWROOT" -o data=writeback,barrier=0,commit=60,noinit_itable,discard,noatime ret=$? if (( ret != 0 )); then # Just try with no options and hope for the best... + echo "Trying default mount with no options..." mount "$SLX_DNBD3_DEVICE_COW" "$NEWROOT" ret=$? fi fi -(( ret != 0 )) && exit $ret - -if ! [ -e "$NEWROOT/etc/fstab.keep" ] && ! grep -qF 'NODELETE' "$NEWROOT/etc/fstab"; then - echo "" > "$NEWROOT/etc/fstab" -fi - -exit 0 +exit $ret diff --git a/modules.d/dnbd3-rootfs/hooks/s3-write-fstab.sh b/modules.d/dnbd3-rootfs/hooks/s3-write-fstab.sh new file mode 100755 index 00000000..8cb252cd --- /dev/null +++ b/modules.d/dnbd3-rootfs/hooks/s3-write-fstab.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +type emergency_shell >/dev/null 2>&1 || source /lib/dracut-lib.sh # $NEWROOT + +if [ -e "/etc/fstab" ]; then + echo "Copying /etc/fstab from initrd" + cp -f "/etc/fstab" "$NEWROOT/etc/fstab" || exit 1 +elif ! [ -e "$NEWROOT/etc/fstab.keep" ] && ! grep -qF 'NODELETE' "$NEWROOT/etc/fstab"; then + echo "Wiping stage4 fstab" + echo "" > "$NEWROOT/etc/fstab" || exit 1 +else + echo "Keeping stage4 fstab untouched" +fi + +exit 0 diff --git a/modules.d/dnbd3-rootfs/module-setup.sh b/modules.d/dnbd3-rootfs/module-setup.sh index 33ab065a..bff931f7 100755 --- a/modules.d/dnbd3-rootfs/module-setup.sh +++ b/modules.d/dnbd3-rootfs/module-setup.sh @@ -159,6 +159,8 @@ install() { --after "initrd-root-device.target" \ --requires "initrd-root-device.target" \ --wbefore "initrd-root-fs.target" + slx_service "s3-write-fstab" "Write final fstab for stage4" \ + --after "s3-mount-root" # Copy systemd services to new root (so they don't get killed after # switch_root) inst_hook pre-pivot 90 \ diff --git a/modules.d/slx-extra-script/hooks/s3-extra-script.sh b/modules.d/slx-extra-script/hooks/s3-extra-script.sh index 3a8d4ff4..7ac293ee 100755 --- a/modules.d/slx-extra-script/hooks/s3-extra-script.sh +++ b/modules.d/slx-extra-script/hooks/s3-extra-script.sh @@ -1,10 +1,8 @@ -#!/bin/bash -# -*- coding: utf-8 -*- -# region imports +#!/bin/ash +# . /etc/openslx -# endregion [ -z "$SLX_EXTRA_SCRIPT_URL" ] && exit 0 -slx-tools download_retry --slx-time 20 -sS "$SLX_EXTRA_SCRIPT_URL" > /tmp/extra-init || exit 1 -chmod +x /tmp/extra-init -exec /tmp/extra-init +slx-tools download_retry --slx-time 20 -sS "$SLX_EXTRA_SCRIPT_URL" > /etc/extra-init || exit 1 +chmod +x /etc/extra-init +exec /etc/extra-init pre-dmsetup diff --git a/modules.d/slx-extra-script/module-setup.sh b/modules.d/slx-extra-script/module-setup.sh index 02f61391..da057429 100755 --- a/modules.d/slx-extra-script/module-setup.sh +++ b/modules.d/slx-extra-script/module-setup.sh @@ -10,4 +10,9 @@ install() { slx_service "s3-extra-script" "Execute extra script from URL" \ --wafter "s3-fetch-config.service" \ --before "s3-dnbd3root.service" + mkdir --parents "${initdir}/${systemdsystemunitdir}/initrd.target.wants" + inst_simple "${moddir}/services/s3-extra-post-dmsetup.service" \ + "${systemdsystemunitdir}/s3-extra-post-dmsetup.service" + ln_r "${systemdsystemunitdir}/s3-extra-post-dmsetup.service" \ + "${systemdsystemunitdir}/initrd.target.wants/s3-extra-post-dmsetup.service" } diff --git a/modules.d/slx-extra-script/services/s3-extra-post-dmsetup.service b/modules.d/slx-extra-script/services/s3-extra-post-dmsetup.service new file mode 100644 index 00000000..fd1f18e6 --- /dev/null +++ b/modules.d/slx-extra-script/services/s3-extra-post-dmsetup.service @@ -0,0 +1,13 @@ +[Unit] +Description=Run extra script after dmsetup +ConditionFileIsExecutable=/etc/extra-init +After=s3-dnbd3root.service +Before=s3-write-fstab.service +Before=initrd-switch-root.target initrd-cleanup.service + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=/etc/extra-init post-dmsetup +KillMode=process +KillSignal=SIGTERM |