From: Kai Krakow Date: Sun, 19 Jan 2025 13:31:14 +0000 (+0100) Subject: scripts/beesd: Unshare namespace without systemd X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=360ce7e1254a61af360f935d3240ab720abb08e2;p=bees scripts/beesd: Unshare namespace without systemd 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 --- diff --git a/scripts/beesd.in b/scripts/beesd.in index 266b9a32..3d216775 100755 --- a/scripts/beesd.in +++ b/scripts/beesd.in @@ -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; }