gitea-backup-pull: skip unmount (no error) if another process is busy on WSD2L840
rc.unassigned umount always does a lazy unmount and reports success unconditionally, even with an open cwd on the mountpoint - it never actually refuses on its own. Check with fuser -m first instead, and just leave the disk mounted if anything is using it.
This commit is contained in:
@@ -56,11 +56,26 @@ DEL_BATCH=$(mktemp)
|
||||
cleanup() {
|
||||
rm -f "$GET_BATCH" "$DEL_BATCH"
|
||||
if [ "$UD_ALREADY_MOUNTED" = false ]; then
|
||||
# cd out first - if the shell's own cwd is still on the device
|
||||
# (it is, after the "cd $LOCAL_DIR" below), umount fails with
|
||||
# "target is busy"
|
||||
# cd out first - our own cwd on the device would otherwise
|
||||
# make the fuser check below always find "something" using it
|
||||
cd / || true
|
||||
/usr/local/sbin/rc.unassigned umount "$UD_DEV" >/dev/null 2>&1
|
||||
|
||||
# rc.unassigned's umount always does a lazy (-l) unmount and
|
||||
# reports "success" no matter what - it does NOT refuse or
|
||||
# error out just because another process still has the
|
||||
# mountpoint open (verified live: a process with its cwd on
|
||||
# the device does not stop it, and does not get killed
|
||||
# either, unless this were a forced "stop array"-style
|
||||
# unmount, which a single-device call never is). So the only
|
||||
# way to actually detect and respect another user of the
|
||||
# disk is to check first, ourselves, and simply not attempt
|
||||
# the unmount at all if anything is found - no ERROR, just
|
||||
# leave it mounted for next time.
|
||||
if fuser -m "$UD_MOUNTPOINT" >/dev/null 2>&1; then
|
||||
echo "$(date -Is) $UD_MOUNTPOINT still in use by another process - leaving it mounted"
|
||||
else
|
||||
/usr/local/sbin/rc.unassigned umount "$UD_DEV" >/dev/null 2>&1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
Reference in New Issue
Block a user