]> git.hungrycats.org Git - bees/commitdiff
scripts/beesd: Unshare namespace without systemd
authorKai Krakow <kai@kaishome.de>
Sun, 19 Jan 2025 13:31:14 +0000 (14:31 +0100)
committerZygo Blaxell <bees@furryterror.org>
Mon, 20 Jan 2025 05:05:57 +0000 (00:05 -0500)
If starting the beesd script without systemd, the mount point won't
automatically unmount if the script is cancelled with ctrl+c.

Fixes: https://github.com/Zygo/bees/issues/281
Signed-off-by: Kai Krakow <kai@kaishome.de>
scripts/beesd.in

index 266b9a320cc8caa139914382b1a792d7281da7ef..3d2167753c76576879f95e127f144febb8093543 100755 (executable)
@@ -1,5 +1,13 @@
 #!/bin/bash
 
+# if not called from systemd try to replicate mount unsharing on ctrl+c
+# see: https://github.com/Zygo/bees/issues/281
+if [ -z "${SYSTEMD_EXEC_PID}" -a -z "${UNSHARE_DONE}" ]; then
+        UNSHARE_DONE=true
+        export UNSHARE_DONE
+        exec unshare -m --propagation private -- "$0" "$@"
+fi
+
 ## Helpful functions
 INFO(){ echo "INFO:" "$@"; }
 ERRO(){ echo "ERROR:" "$@"; exit 1; }