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