nbd: use systemd-run to start nbd-client

master
Harald Hoyer 2017-07-28 15:14:17 +02:00
parent 66a3d4053b
commit 9fd0461b7d
1 changed files with 18 additions and 2 deletions

View File

@ -109,9 +109,25 @@ if strstr "$(nbd-client --help 2>&1)" "systemd-mark"; then
fi fi


if [ "$nbdport" -gt 0 ] 2>/dev/null; then 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 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 fi


# NBD doesn't emit uevents when it gets connected, so kick it # NBD doesn't emit uevents when it gets connected, so kick it