]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
systemd/rootfs-generator.sh: generate units in /run/systemd/generator
authorHarald Hoyer <harald@redhat.com>
Tue, 25 Feb 2014 11:54:28 +0000 (12:54 +0100)
committerHarald Hoyer <harald@redhat.com>
Wed, 26 Feb 2014 14:02:42 +0000 (15:02 +0100)
Generate the units in /run/systemd/generator, so they are picked up by
systemd.

https://bugzilla.redhat.com/show_bug.cgi?id=1069133
https://bugzilla.redhat.com/show_bug.cgi?id=949697

modules.d/98systemd/rootfs-generator.sh

index 9810026da0223a3a1d9204a8dab95d7a2bcab047..a11ce595f9223e188248df4debe004c5d8ffeba4 100755 (executable)
@@ -3,6 +3,37 @@
 # ex: ts=8 sw=4 sts=4 et filetype=sh
 
 type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
+
+generator_wait_for_dev()
+{
+    local _name
+
+    _name="$(str_replace "$1" '/' '\x2f')"
+
+    [ -e "$hookdir/initqueue/finished/devexists-${_name}.sh" ] && return 0
+
+    printf '[ -e "%s" ]\n' $1 \
+        >> "$hookdir/initqueue/finished/devexists-${_name}.sh"
+    {
+        printf '[ -e "%s" ] || ' $1
+        printf 'warn "\"%s\" does not exist"\n' $1
+    } >> "$hookdir/emergency/80-${_name}.sh"
+
+    _name=$(dev_unit_name "$1")
+    if ! [ -L /run/systemd/generator/initrd.target.wants/${_name}.device ]; then
+        [ -d /run/systemd/generator/initrd.target.wants ] || mkdir -p /run/systemd/generator/initrd.target.wants
+        ln -s ../${_name}.device /run/systemd/generator/initrd.target.wants/${_name}.device
+    fi
+
+    if ! [ -f /run/systemd/generator/${_name}.device.d/timeout.conf ]; then
+        mkdir -p /run/systemd/generator/${_name}.device.d
+        {
+            echo "[Unit]"
+            echo "JobTimeoutSec=3600"
+        } > /run/systemd/generator/${_name}.device.d/timeout.conf
+    fi
+}
+
 root=$(getarg root=)
 case "$root" in
     block:LABEL=*|LABEL=*)
@@ -29,6 +60,6 @@ case "$root" in
         rootok=1 ;;
 esac
 
-[ "${root%%:*}" = "block" ] && wait_for_dev -n "${root#block:}"
+[ "${root%%:*}" = "block" ] && generator_wait_for_dev "${root#block:}"
 
 exit 0