Blame SOURCES/0133-systemd-rootfs-generator.sh-generate-units-in-run-sy.patch

18971c
From 5a3b267d06cc81fcb7e0374c7656a1f48d031497 Mon Sep 17 00:00:00 2001
18971c
From: Harald Hoyer <harald@redhat.com>
18971c
Date: Tue, 25 Feb 2014 12:54:28 +0100
18971c
Subject: [PATCH] systemd/rootfs-generator.sh: generate units in
18971c
 /run/systemd/generator
18971c
18971c
Generate the units in /run/systemd/generator, so they are picked up by
18971c
systemd.
18971c
18971c
https://bugzilla.redhat.com/show_bug.cgi?id=1069133
18971c
https://bugzilla.redhat.com/show_bug.cgi?id=949697
18971c
---
18971c
 modules.d/98systemd/rootfs-generator.sh | 33 ++++++++++++++++++++++++-
18971c
 1 file changed, 32 insertions(+), 1 deletion(-)
18971c
18971c
diff --git a/modules.d/98systemd/rootfs-generator.sh b/modules.d/98systemd/rootfs-generator.sh
18971c
index 9810026d..a11ce595 100755
18971c
--- a/modules.d/98systemd/rootfs-generator.sh
18971c
+++ b/modules.d/98systemd/rootfs-generator.sh
18971c
@@ -3,6 +3,37 @@
18971c
 # ex: ts=8 sw=4 sts=4 et filetype=sh
18971c
 
18971c
 type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
18971c
+
18971c
+generator_wait_for_dev()
18971c
+{
18971c
+    local _name
18971c
+
18971c
+    _name="$(str_replace "$1" '/' '\x2f')"
18971c
+
18971c
+    [ -e "$hookdir/initqueue/finished/devexists-${_name}.sh" ] && return 0
18971c
+
18971c
+    printf '[ -e "%s" ]\n' $1 \
18971c
+        >> "$hookdir/initqueue/finished/devexists-${_name}.sh"
18971c
+    {
18971c
+        printf '[ -e "%s" ] || ' $1
18971c
+        printf 'warn "\"%s\" does not exist"\n' $1
18971c
+    } >> "$hookdir/emergency/80-${_name}.sh"
18971c
+
18971c
+    _name=$(dev_unit_name "$1")
18971c
+    if ! [ -L /run/systemd/generator/initrd.target.wants/${_name}.device ]; then
18971c
+        [ -d /run/systemd/generator/initrd.target.wants ] || mkdir -p /run/systemd/generator/initrd.target.wants
18971c
+        ln -s ../${_name}.device /run/systemd/generator/initrd.target.wants/${_name}.device
18971c
+    fi
18971c
+
18971c
+    if ! [ -f /run/systemd/generator/${_name}.device.d/timeout.conf ]; then
18971c
+        mkdir -p /run/systemd/generator/${_name}.device.d
18971c
+        {
18971c
+            echo "[Unit]"
18971c
+            echo "JobTimeoutSec=3600"
18971c
+        } > /run/systemd/generator/${_name}.device.d/timeout.conf
18971c
+    fi
18971c
+}
18971c
+
18971c
 root=$(getarg root=)
18971c
 case "$root" in
18971c
     block:LABEL=*|LABEL=*)
18971c
@@ -29,6 +60,6 @@ case "$root" in
18971c
         rootok=1 ;;
18971c
 esac
18971c
 
18971c
-[ "${root%%:*}" = "block" ] && wait_for_dev -n "${root#block:}"
18971c
+[ "${root%%:*}" = "block" ] && generator_wait_for_dev "${root#block:}"
18971c
 
18971c
 exit 0