Unmount WSD2L840 after sync, but only if this run mounted it
Previously the pull script mounted the Unassigned Device and left it mounted indefinitely. Now tracks whether it was already mounted before this run and only unmounts at the end if it wasn't - never disturbs a mount already in place for some other reason. Handled via an EXIT trap so it fires on any exit path, not just success. Found and fixed a real bug testing this: the script cd's into the mounted directory and never leaves, so the unmount was failing with "target is busy" (the shell's own cwd still being on the device) until the cleanup function explicitly cd's out first. Verified both directions live: already-mounted stays mounted after; not-mounted gets mounted, used, and cleanly unmounted again. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -481,6 +481,18 @@ The SSH keypair needed no special handling: Unraid already auto-mirrors
|
||||
verifies the result is a real mountpoint (`mountpoint -q`) before writing
|
||||
anything — refuses to run rather than risk silently dumping backups onto
|
||||
the array if the disk is unplugged or fails to mount.
|
||||
- **Unmounts it again when done — but only if this run is the one that
|
||||
mounted it.** Checks the mount state *before* mounting and remembers it;
|
||||
if the disk was already mounted for some other reason, this script
|
||||
leaves it mounted afterward rather than pulling it out from under
|
||||
whatever else was using it. Handled via an `EXIT` trap so it fires
|
||||
reliably on any exit path, not just success. One gotcha found while
|
||||
testing this: the script itself `cd`s into the mounted directory, so
|
||||
without explicitly `cd`ing back out first, the unmount would fail with
|
||||
"target is busy" (the shell's own working directory still being on the
|
||||
device it's trying to unmount). Verified both directions: already
|
||||
mounted → stays mounted after; not mounted → gets mounted, used, and
|
||||
unmounted again, with no "busy" error.
|
||||
|
||||
**Restore path, if ever needed**: manual and deliberate — stop the target
|
||||
Gitea container, unpack the chosen dump's DB/repos/etc. into `/data` per
|
||||
|
||||
Reference in New Issue
Block a user