ffd055
From 59d51f92475f1b4dc81b1e6f5537f63876952c39 Mon Sep 17 00:00:00 2001
ffd055
From: Jan Macku <jamacku@redhat.com>
ffd055
Date: Fri, 8 Nov 2019 16:24:13 +0100
ffd055
Subject: [PATCH] Replace ln with systemctl
ffd055
ffd055
(cherry picked from commit 70b19acf941c0bf41b2c69c761124425910c0653)
ffd055
ffd055
Cherry-picked from: 70b19acf941c0bf41b2c69c761124425910c0653
ffd055
Resolves: #1888779
ffd055
---
ffd055
 modules.d/00systemd/module-setup.sh          | 6 ++----
ffd055
 modules.d/02systemd-networkd/module-setup.sh | 8 ++++----
ffd055
 modules.d/06rngd/module-setup.sh             | 5 ++---
ffd055
 modules.d/90multipath/module-setup.sh        | 3 +--
ffd055
 modules.d/90stratis/module-setup.sh          | 3 +--
ffd055
 modules.d/95iscsi/module-setup.sh            | 8 +++-----
ffd055
 modules.d/98dracut-systemd/module-setup.sh   | 3 +--
ffd055
 modules.d/99squash/module-setup.sh           | 3 +--
ffd055
 8 files changed, 15 insertions(+), 24 deletions(-)
ffd055
ffd055
diff --git a/modules.d/00systemd/module-setup.sh b/modules.d/00systemd/module-setup.sh
ffd055
index e4a3f323..4ab2a896 100755
ffd055
--- a/modules.d/00systemd/module-setup.sh
ffd055
+++ b/modules.d/00systemd/module-setup.sh
ffd055
@@ -225,9 +225,7 @@ install() {
ffd055
         systemd-ask-password-console.service \
ffd055
         systemd-ask-password-plymouth.service \
ffd055
         ; do
ffd055
-        mkdir -p "${initdir}${systemdsystemunitdir}/${i}.wants"
ffd055
-        ln_r "${systemdsystemunitdir}/systemd-vconsole-setup.service" \
ffd055
-            "${systemdsystemunitdir}/${i}.wants/systemd-vconsole-setup.service"
ffd055
+        systemctl -q --root "$initdir" add-wants "$i" systemd-vconsole-setup.service
ffd055
     done
ffd055
 
ffd055
     mkdir -p "$initdir/etc/systemd"
ffd055
@@ -239,6 +237,6 @@ install() {
ffd055
         echo "RateLimitBurst=0"
ffd055
     } >> "$initdir/etc/systemd/journald.conf"
ffd055
 
ffd055
-    ln_r "${systemdsystemunitdir}/multi-user.target" "${systemdsystemunitdir}/default.target"
ffd055
+    systemctl -q --root "$initdir" set-default multi-user.target
ffd055
 }
ffd055
 
ffd055
diff --git a/modules.d/02systemd-networkd/module-setup.sh b/modules.d/02systemd-networkd/module-setup.sh
ffd055
index b86751ea..8b87923f 100755
ffd055
--- a/modules.d/02systemd-networkd/module-setup.sh
ffd055
+++ b/modules.d/02systemd-networkd/module-setup.sh
ffd055
@@ -61,11 +61,11 @@ install() {
ffd055
 
ffd055
     for i in \
ffd055
         systemd-networkd-wait-online.service \
ffd055
-            systemd-networkd.service \
ffd055
-            systemd-networkd.socket
ffd055
-#            systemd-timesyncd.service
ffd055
+        systemd-networkd.service \
ffd055
+        systemd-networkd.socket
ffd055
+#       systemd-timesyncd.service
ffd055
     do
ffd055
-        systemctl --root "$initdir" enable "$i"
ffd055
+        systemctl -q --root "$initdir" enable "$i"
ffd055
     done
ffd055
 }
ffd055
 
ffd055
diff --git a/modules.d/06rngd/module-setup.sh b/modules.d/06rngd/module-setup.sh
ffd055
index 43d5c2d3..354bd0bb 100644
ffd055
--- a/modules.d/06rngd/module-setup.sh
ffd055
+++ b/modules.d/06rngd/module-setup.sh
ffd055
@@ -33,7 +33,6 @@ check() {
ffd055
 install() {
ffd055
     inst rngd
ffd055
     inst_simple "${moddir}/rngd.service" "${systemdsystemunitdir}/rngd.service"
ffd055
-    mkdir -p "${initdir}${systemdsystemunitdir}/sysinit.target.wants"
ffd055
-    ln -rfs "${initdir}${systemdsystemunitdir}/rngd.service" \
ffd055
-        "${initdir}${systemdsystemunitdir}/sysinit.target.wants/rngd.service"
ffd055
+
ffd055
+    systemctl -q --root "$initdir" add-wants sysinit.target rngd.service
ffd055
 }
ffd055
diff --git a/modules.d/90multipath/module-setup.sh b/modules.d/90multipath/module-setup.sh
ffd055
index 2b9a3166..8a032c86 100755
ffd055
--- a/modules.d/90multipath/module-setup.sh
ffd055
+++ b/modules.d/90multipath/module-setup.sh
ffd055
@@ -110,8 +110,7 @@ install() {
ffd055
 
ffd055
     if dracut_module_included "systemd"; then
ffd055
         inst_simple "${moddir}/multipathd.service" "${systemdsystemunitdir}/multipathd.service"
ffd055
-        mkdir -p "${initdir}${systemdsystemunitdir}/sysinit.target.wants"
ffd055
-        ln -rfs "${initdir}${systemdsystemunitdir}/multipathd.service" "${initdir}${systemdsystemunitdir}/sysinit.target.wants/multipathd.service"
ffd055
+        systemctl -q --root "$initdir" enable multipathd.service
ffd055
     else
ffd055
         inst_hook pre-trigger 02 "$moddir/multipathd.sh"
ffd055
         inst_hook cleanup   02 "$moddir/multipathd-stop.sh"
ffd055
diff --git a/modules.d/90stratis/module-setup.sh b/modules.d/90stratis/module-setup.sh
ffd055
index 29f0765b..943f572e 100755
ffd055
--- a/modules.d/90stratis/module-setup.sh
ffd055
+++ b/modules.d/90stratis/module-setup.sh
ffd055
@@ -24,8 +24,7 @@ install() {
ffd055
 
ffd055
     if dracut_module_included "systemd"; then
ffd055
         inst_simple "${moddir}/stratisd-init.service" "${systemdsystemunitdir}/stratisd-init.service"
ffd055
-        mkdir -p "${initdir}${systemdsystemunitdir}/sysinit.target.wants"
ffd055
-        ln -rfs "${initdir}${systemdsystemunitdir}/stratisd-init.service" "${initdir}${systemdsystemunitdir}/sysinit.target.wants/stratisd-init.service"
ffd055
+        systemctl -q --root "$initdir" enable stratisd-init.service
ffd055
     else
ffd055
         inst_hook cmdline 25 "$moddir/stratisd-start.sh"
ffd055
         inst_hook cleanup 25 "$moddir/stratisd-stop.sh"
ffd055
diff --git a/modules.d/95iscsi/module-setup.sh b/modules.d/95iscsi/module-setup.sh
ffd055
index f6f3520d..47a92e94 100755
ffd055
--- a/modules.d/95iscsi/module-setup.sh
ffd055
+++ b/modules.d/95iscsi/module-setup.sh
ffd055
@@ -242,20 +242,18 @@ install() {
ffd055
                       $systemdsystemunitdir/iscsiuio.socket \
ffd055
                       iscsiadm iscsid
ffd055
 
ffd055
-        mkdir -p "${initdir}/$systemdsystemunitdir/sockets.target.wants"
ffd055
         for i in \
ffd055
                 iscsid.socket \
ffd055
                 iscsiuio.socket \
ffd055
             ; do
ffd055
-            ln_r "$systemdsystemunitdir/${i}" "$systemdsystemunitdir/sockets.target.wants/${i}"
ffd055
+            systemctl -q --root "$initdir" enable "$i"
ffd055
         done
ffd055
-
ffd055
-        mkdir -p "${initdir}/$systemdsystemunitdir/basic.target.wants"
ffd055
+        
ffd055
         for i in \
ffd055
                 iscsid.service \
ffd055
                 iscsiuio.service \
ffd055
             ; do
ffd055
-            ln_r "$systemdsystemunitdir/${i}" "$systemdsystemunitdir/basic.target.wants/${i}"
ffd055
+            systemctl -q --root "$initdir" add-wants basic.target "$i"
ffd055
         done
ffd055
 
ffd055
         # Make sure iscsid is started after dracut-cmdline and ready for the initqueue
ffd055
diff --git a/modules.d/98dracut-systemd/module-setup.sh b/modules.d/98dracut-systemd/module-setup.sh
ffd055
index 900162c3..1387433a 100755
ffd055
--- a/modules.d/98dracut-systemd/module-setup.sh
ffd055
+++ b/modules.d/98dracut-systemd/module-setup.sh
ffd055
@@ -43,7 +43,6 @@ install() {
ffd055
 
ffd055
     inst_script "$moddir/rootfs-generator.sh" $systemdutildir/system-generators/dracut-rootfs-generator
ffd055
 
ffd055
-    mkdir -p "${initdir}/$systemdsystemunitdir/initrd.target.wants"
ffd055
     for i in \
ffd055
         dracut-cmdline.service \
ffd055
         dracut-cmdline-ask.service \
ffd055
@@ -55,7 +54,7 @@ install() {
ffd055
         dracut-pre-udev.service \
ffd055
         ; do
ffd055
         inst_simple "$moddir/${i}" "$systemdsystemunitdir/${i}"
ffd055
-        ln_r "$systemdsystemunitdir/${i}" "$systemdsystemunitdir/initrd.target.wants/${i}"
ffd055
+        systemctl -q --root "$initdir" add-wants initrd.target "$i"
ffd055
     done
ffd055
 
ffd055
     inst_simple "$moddir/dracut-tmpfiles.conf" "$tmpfilesdir/dracut-tmpfiles.conf"
ffd055
diff --git a/modules.d/99squash/module-setup.sh b/modules.d/99squash/module-setup.sh
ffd055
index e7e9ed8e..7aa0b447 100644
ffd055
--- a/modules.d/99squash/module-setup.sh
ffd055
+++ b/modules.d/99squash/module-setup.sh
ffd055
@@ -25,6 +25,5 @@ install() {
ffd055
     inst $moddir/init.sh /squash/init.sh
ffd055
 
ffd055
     inst "$moddir/squash-mnt-clear.service" "$systemdsystemunitdir/squash-mnt-clear.service"
ffd055
-    mkdir -p "$initdir$systemdsystemunitdir/initrd-switch-root.target.wants"
ffd055
-    ln_r "$systemdsystemunitdir/squash-mnt-clear.service" "$systemdsystemunitdir/initrd-switch-root.target.wants/squash-mnt-clear.service"
ffd055
+    systemctl -q --root "$initdir" add-wants initrd-switch-root.target squash-mnt-clear.service
ffd055
 }
ffd055