|
|
49e6a8 |
From e42ab58a70ae646d09c319c125154e970e25a994 Mon Sep 17 00:00:00 2001
|
|
|
49e6a8 |
From: Lukas Nykryn <lnykryn@redhat.com>
|
|
|
49e6a8 |
Date: Thu, 25 Apr 2019 10:11:58 +0200
|
|
|
49e6a8 |
Subject: [PATCH] rootfs-generator: rebase to upstream version
|
|
|
49e6a8 |
|
|
|
49e6a8 |
Resolves: #1640866
|
|
|
49e6a8 |
---
|
|
|
49e6a8 |
modules.d/98systemd/rootfs-generator.sh | 87 ++++++++++++++++++++-----
|
|
|
49e6a8 |
1 file changed, 70 insertions(+), 17 deletions(-)
|
|
|
49e6a8 |
|
|
|
49e6a8 |
diff --git a/modules.d/98systemd/rootfs-generator.sh b/modules.d/98systemd/rootfs-generator.sh
|
|
|
49e6a8 |
index a7bffdfd..4ae693bb 100755
|
|
|
49e6a8 |
--- a/modules.d/98systemd/rootfs-generator.sh
|
|
|
49e6a8 |
+++ b/modules.d/98systemd/rootfs-generator.sh
|
|
|
49e6a8 |
@@ -1,6 +1,4 @@
|
|
|
49e6a8 |
#!/bin/sh
|
|
|
49e6a8 |
-# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
|
|
49e6a8 |
-# ex: ts=8 sw=4 sts=4 et filetype=sh
|
|
|
49e6a8 |
|
|
|
49e6a8 |
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
|
|
|
49e6a8 |
|
|
|
49e6a8 |
@@ -10,32 +8,81 @@ generator_wait_for_dev()
|
|
|
49e6a8 |
local _timeout
|
|
|
49e6a8 |
|
|
|
49e6a8 |
_name="$(str_replace "$1" '/' '\x2f')"
|
|
|
49e6a8 |
+ _timeout=$(getarg rd.timeout)
|
|
|
49e6a8 |
+ _timeout=${_timeout:-0}
|
|
|
49e6a8 |
|
|
|
49e6a8 |
- [ -e "$hookdir/initqueue/finished/devexists-${_name}.sh" ] && return 0
|
|
|
49e6a8 |
+ if ! [ -e "$hookdir/initqueue/finished/devexists-${_name}.sh" ]; then
|
|
|
49e6a8 |
|
|
|
49e6a8 |
- printf '[ -e "%s" ]\n' $1 \
|
|
|
49e6a8 |
- >> "$hookdir/initqueue/finished/devexists-${_name}.sh"
|
|
|
49e6a8 |
- {
|
|
|
49e6a8 |
- printf '[ -e "%s" ] || ' $1
|
|
|
49e6a8 |
- printf 'warn "\"%s\" does not exist"\n' $1
|
|
|
49e6a8 |
- } >> "$hookdir/emergency/80-${_name}.sh"
|
|
|
49e6a8 |
+ printf '[ -e "%s" ]\n' $1 \
|
|
|
49e6a8 |
+ >> "$hookdir/initqueue/finished/devexists-${_name}.sh"
|
|
|
49e6a8 |
+ {
|
|
|
49e6a8 |
+ printf '[ -e "%s" ] || ' $1
|
|
|
49e6a8 |
+ printf 'warn "\"%s\" does not exist"\n' $1
|
|
|
49e6a8 |
+ } >> "$hookdir/emergency/80-${_name}.sh"
|
|
|
49e6a8 |
+ fi
|
|
|
49e6a8 |
|
|
|
49e6a8 |
_name=$(dev_unit_name "$1")
|
|
|
49e6a8 |
- if ! [ -L /run/systemd/generator/initrd.target.wants/${_name}.device ]; then
|
|
|
49e6a8 |
- [ -d /run/systemd/generator/initrd.target.wants ] || mkdir -p /run/systemd/generator/initrd.target.wants
|
|
|
49e6a8 |
- ln -s ../${_name}.device /run/systemd/generator/initrd.target.wants/${_name}.device
|
|
|
49e6a8 |
+ if ! [ -L "$GENERATOR_DIR"/initrd.target.wants/${_name}.device ]; then
|
|
|
49e6a8 |
+ [ -d "$GENERATOR_DIR"/initrd.target.wants ] || mkdir -p "$GENERATOR_DIR"/initrd.target.wants
|
|
|
49e6a8 |
+ ln -s ../${_name}.device "$GENERATOR_DIR"/initrd.target.wants/${_name}.device
|
|
|
49e6a8 |
fi
|
|
|
49e6a8 |
|
|
|
49e6a8 |
- if ! [ -f /run/systemd/generator/${_name}.device.d/timeout.conf ]; then
|
|
|
49e6a8 |
- _timeout=$(getarg rd.device.timeout || printf "0")
|
|
|
49e6a8 |
- mkdir -p /run/systemd/generator/${_name}.device.d
|
|
|
49e6a8 |
+ if ! [ -f "$GENERATOR_DIR"/${_name}.device.d/timeout.conf ]; then
|
|
|
49e6a8 |
+ mkdir -p "$GENERATOR_DIR"/${_name}.device.d
|
|
|
49e6a8 |
{
|
|
|
49e6a8 |
echo "[Unit]"
|
|
|
49e6a8 |
echo "JobTimeoutSec=$_timeout"
|
|
|
49e6a8 |
- } > /run/systemd/generator/${_name}.device.d/timeout.conf
|
|
|
49e6a8 |
+ echo "JobRunningTimeoutSec=$_timeout"
|
|
|
49e6a8 |
+ } > "$GENERATOR_DIR"/${_name}.device.d/timeout.conf
|
|
|
49e6a8 |
+ fi
|
|
|
49e6a8 |
+}
|
|
|
49e6a8 |
+
|
|
|
49e6a8 |
+generator_mount_rootfs()
|
|
|
49e6a8 |
+{
|
|
|
49e6a8 |
+ local _type=$2
|
|
|
49e6a8 |
+ local _flags=$3
|
|
|
49e6a8 |
+ local _name
|
|
|
49e6a8 |
+
|
|
|
49e6a8 |
+ [ -z "$1" ] && return 0
|
|
|
49e6a8 |
+
|
|
|
49e6a8 |
+ _name=$(dev_unit_name "$1")
|
|
|
49e6a8 |
+ [ -d "$GENERATOR_DIR" ] || mkdir -p "$GENERATOR_DIR"
|
|
|
49e6a8 |
+ if ! [ -f "$GENERATOR_DIR"/sysroot.mount ]; then
|
|
|
49e6a8 |
+ {
|
|
|
49e6a8 |
+ echo "[Unit]"
|
|
|
49e6a8 |
+ echo "Before=initrd-root-fs.target"
|
|
|
49e6a8 |
+ echo "Requires=systemd-fsck@${_name}.service"
|
|
|
49e6a8 |
+ echo "After=systemd-fsck@${_name}.service"
|
|
|
49e6a8 |
+ echo "[Mount]"
|
|
|
49e6a8 |
+ echo "Where=/sysroot"
|
|
|
49e6a8 |
+ echo "What=$1"
|
|
|
49e6a8 |
+ echo "Options=${_flags}"
|
|
|
49e6a8 |
+ echo "Type=${_type}"
|
|
|
49e6a8 |
+ } > "$GENERATOR_DIR"/sysroot.mount
|
|
|
49e6a8 |
+ fi
|
|
|
49e6a8 |
+ if ! [ -L "$GENERATOR_DIR"/initrd-root-fs.target.requires/sysroot.mount ]; then
|
|
|
49e6a8 |
+ [ -d "$GENERATOR_DIR"/initrd-root-fs.target.requires ] || mkdir -p "$GENERATOR_DIR"/initrd-root-fs.target.requires
|
|
|
49e6a8 |
+ ln -s ../sysroot.mount "$GENERATOR_DIR"/initrd-root-fs.target.requires/sysroot.mount
|
|
|
49e6a8 |
fi
|
|
|
49e6a8 |
}
|
|
|
49e6a8 |
|
|
|
49e6a8 |
+generator_fsck_after_pre_mount()
|
|
|
49e6a8 |
+{
|
|
|
49e6a8 |
+ local _name
|
|
|
49e6a8 |
+
|
|
|
49e6a8 |
+ [ -z "$1" ] && return 0
|
|
|
49e6a8 |
+
|
|
|
49e6a8 |
+ _name=$(dev_unit_name "$1")
|
|
|
49e6a8 |
+ [ -d /run/systemd/generator/systemd-fsck@${_name}.service.d ] || mkdir -p /run/systemd/generator/systemd-fsck@${_name}.service.d
|
|
|
49e6a8 |
+ if ! [ -f /run/systemd/generator/systemd-fsck@${_name}.service.d/after-pre-mount.conf ]; then
|
|
|
49e6a8 |
+ {
|
|
|
49e6a8 |
+ echo "[Unit]"
|
|
|
49e6a8 |
+ echo "After=dracut-pre-mount.service"
|
|
|
49e6a8 |
+ } > /run/systemd/generator/systemd-fsck@${_name}.service.d/after-pre-mount.conf
|
|
|
49e6a8 |
+ fi
|
|
|
49e6a8 |
+
|
|
|
49e6a8 |
+}
|
|
|
49e6a8 |
+
|
|
|
49e6a8 |
root=$(getarg root=)
|
|
|
49e6a8 |
case "$root" in
|
|
|
49e6a8 |
block:LABEL=*|LABEL=*)
|
|
|
49e6a8 |
@@ -62,6 +109,12 @@ case "$root" in
|
|
|
49e6a8 |
rootok=1 ;;
|
|
|
49e6a8 |
esac
|
|
|
49e6a8 |
|
|
|
49e6a8 |
-[ "${root%%:*}" = "block" ] && generator_wait_for_dev "${root#block:}"
|
|
|
49e6a8 |
+GENERATOR_DIR="$1"
|
|
|
49e6a8 |
+
|
|
|
49e6a8 |
+if [ "$rootok" = "1" ]; then
|
|
|
49e6a8 |
+ generator_wait_for_dev "${root#block:}" "$RDRETRY"
|
|
|
49e6a8 |
+ generator_fsck_after_pre_mount "${root#block:}"
|
|
|
49e6a8 |
+ strstr "$(cat /proc/cmdline)" 'root=' || generator_mount_rootfs "${root#block:}" "$(getarg rootfstype=)" "$(getarg rootflags=)"
|
|
|
49e6a8 |
+fi
|
|
|
49e6a8 |
|
|
|
49e6a8 |
exit 0
|