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