]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
fix(dracut-systemd): do not hardcode the systemd generator directory
authorAntonio Alvarez Feijoo <antonio.feijoo@suse.com>
Wed, 1 Mar 2023 10:21:16 +0000 (11:21 +0100)
committerLaszlo Gombos <laszlo.gombos@gmail.com>
Wed, 10 May 2023 12:10:01 +0000 (08:10 -0400)
The normal directory is the first argument passed to the systemd generator,
so use it instead of hardcoding /run/systemd/generator.

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

index b98e4e5771e0d130bcaa9bf3c5247ea42c5e10ed..32179fb40b1fe79a0a82952f3f7795f150614050 100755 (executable)
@@ -17,7 +17,7 @@ generator_wait_for_dev() {
         # after remote-fs-pre.target since the initqueue is ordered before it so
         # it will never actually show up (think Tang-pinned rootfs).
         cat > "$hookdir/initqueue/finished/devexists-${_name}.sh" << EOF
-if ! grep -q After=remote-fs-pre.target /run/systemd/generator/systemd-cryptsetup@*.service 2>/dev/null; then
+if ! grep -q After=remote-fs-pre.target "$GENERATOR_DIR"/systemd-cryptsetup@*.service 2>/dev/null; then
     [ -e "$1" ]
 fi
 EOF
@@ -77,12 +77,12 @@ generator_fsck_after_pre_mount() {
     [ -z "$1" ] && return 0
 
     _name=$(dev_unit_name "$1")
-    [ -d /run/systemd/generator/systemd-fsck@"${_name}".service.d ] || mkdir -p /run/systemd/generator/systemd-fsck@"${_name}".service.d
-    if ! [ -f /run/systemd/generator/systemd-fsck@"${_name}".service.d/after-pre-mount.conf ]; then
+    [ -d "$GENERATOR_DIR"/systemd-fsck@"${_name}".service.d ] || mkdir -p "$GENERATOR_DIR"/systemd-fsck@"${_name}".service.d
+    if ! [ -f "$GENERATOR_DIR"/systemd-fsck@"${_name}".service.d/after-pre-mount.conf ]; then
         {
             echo "[Unit]"
             echo "After=dracut-pre-mount.service"
-        } > /run/systemd/generator/systemd-fsck@"${_name}".service.d/after-pre-mount.conf
+        } > "$GENERATOR_DIR"/systemd-fsck@"${_name}".service.d/after-pre-mount.conf
     fi
 
 }