Skip to content

Commit 881319d

Browse files
committed
AppRun.sharun.ovfsProto: fix cleanup
Signed-off-by: xplshn <anto@xplshn.com.ar>
1 parent ff1af32 commit 881319d

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

assets/AppRun.sharun.ovfsProto

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -86,33 +86,38 @@ MOUNT_DIR="$TEMP_DIR/mount_dir"
8686
mkdir -p "$MOUNT_DIR"
8787

8888
# Mount the unionfs
89-
# Note: Using CoW (copy-on-write) and preserving branch for better compatibility
9089
"$UNIONFS_BIN" -o cow,preserve_branch "$PROTO=RO:/=RW" "$MOUNT_DIR"
9190

9291
cleanup() {
92+
FUSERMOUNT="fusermount3"
93+
command -v "fusermount" && FUSERMOUNT="fusermount"
94+
9395
(
9496
# Attempt to unmount
95-
fusermount -u "$MOUNT_DIR" 2>/dev/null
97+
"$FUSERMOUNT" -u "$MOUNT_DIR" 2>/dev/null
9698

9799
# Wait and check if the mount point is unmounted
98-
for i in 1 2 3 4 5; do
99-
if mountpoint -q "$MOUNT_DIR"; then
100-
sleep "$i"
101-
else
102-
break
103-
fi
104-
done
100+
_wait() {
101+
for i in 1 2 3 4 5; do
102+
if mountpoint -q "$MOUNT_DIR"; then
103+
sleep "$i"
104+
else
105+
break
106+
fi
107+
done
108+
}; _wait
105109

106110
# Force unmount if still mounted
107111
if mountpoint -q "$MOUNT_DIR"; then
108-
fusermount -uz "$MOUNT_DIR" 2>/dev/null
112+
"$FUSERMOUNT" -uz "$MOUNT_DIR" 2>/dev/null
109113
fi
110114

115+
_wait
116+
111117
# Safe remove ops
112-
if mountpoint -q "$MOUNT_DIR"; then
113-
rmdir --ignore-fail-on-non-empty "$MOUNT_DIR"
114-
rmdir --ignore-fail-on-non-empty "$TEMP_DIR"
118+
if ! mountpoint -q "$MOUNT_DIR"; then
115119
rmdir --ignore-fail-on-non-empty "$UNIONFS_DIR"
120+
rmdir --ignore-fail-on-non-empty "$TEMP_DIR"
116121
fi
117122
) & # Run cleanup in the background
118123
}
@@ -145,7 +150,7 @@ UID0_GID0="$(is_enabled "UID0_GID0" 0)"
145150

146151
# Initialize the bwrap command
147152
TMPDIR="${TMPDIR:-/tmp}"
148-
bwrap_cmd="$BWRAP_BIN --dev-bind $MOUNT_DIR / --bind-try $TMPDIR /tmp --bind-try /home /home"
153+
bwrap_cmd="$BWRAP_BIN --dev-bind \"$MOUNT_DIR\" / --bind-try \"$TMPDIR\" \"$TMPDIR\" --bind-try \"$HOME\" \"$HOME\""
149154
[ "$UID0_GID0" = "1" ] && bwrap_cmd="$bwrap_cmd --uid 0 --gid 0"
150155
[ "$SHARE_VAR" = "1" ] && bwrap_cmd="$bwrap_cmd --bind-try /var /var"
151156
[ "$SHARE_RUN" = "1" ] && bwrap_cmd="$bwrap_cmd --bind-try /run /run"

0 commit comments

Comments
 (0)