]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
nbd: use systemd-run to start nbd-client
authorHarald Hoyer <harald@redhat.com>
Fri, 28 Jul 2017 13:14:17 +0000 (15:14 +0200)
committerHarald Hoyer <harald@redhat.com>
Fri, 28 Jul 2017 13:15:02 +0000 (15:15 +0200)
modules.d/95nbd/nbdroot.sh

index 7057f23329ff6cad14ec5d61beb75aef0024455c..697387a614393dbb587c924d4289217abac01e27 100755 (executable)
@@ -109,9 +109,25 @@ if strstr "$(nbd-client --help 2>&1)" "systemd-mark"; then
 fi
 
 if [ "$nbdport" -gt 0 ] 2>/dev/null; then
-    nbd-client "$nbdserver" $nbdport /dev/nbd0 $preopts $opts || exit 1
+    if [ -z "$DRACUT_SYSTEMD" ]; then
+        nbd-client "$nbdserver" $nbdport /dev/nbd0 $preopts $opts || exit 1
+    else
+        systemd-run --no-block --service-type=forking --quiet \
+                    --description="nbd nbd0" \
+                    -p 'DefaultDependencies=no' \
+                    -p 'KillMode=none' \
+                    --unit="nbd0" -- nbd-client "$nbdserver" $nbdport /dev/nbd0 $preopts $opts >/dev/null 2>&1 || exit 1
+    fi
 else
-    nbd-client -name "$nbdport" "$nbdserver" /dev/nbd0 $preopts $opts || exit 1
+    if [ -z "$DRACUT_SYSTEMD" ]; then
+        nbd-client -name "$nbdport" "$nbdserver" /dev/nbd0 $preopts $opts || exit 1
+    else
+        systemd-run --no-block --service-type=forking --quiet \
+                    --description="nbd nbd0" \
+                    -p 'DefaultDependencies=no' \
+                    -p 'KillMode=none' \
+                    --unit="nbd0" --  nbd-client -name "$nbdport" "$nbdserver" /dev/nbd0 $preopts $opts >/dev/null 2>&1 || exit 1
+    fi
 fi
 
 # NBD doesn't emit uevents when it gets connected, so kick it