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

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