The main sweep — ~260 call sites across ~100 files move from string
concatenation on a single root to appDir/storageAppDirs/storageAppConfigs.
On a single-root install the resolved paths are identical, so this is a
no-op until a location is registered.
Enumerators were the interesting half. `for d in "$containers_dir"/*/`
appears in the menus, the registry/artifact scanners and the DNS setup —
and a shell glob cannot list a rootless 751 tree at all, which is the
same bug config_find_file.sh already documents in a comment. Routing them
through storageAppDirs (which enumerates as the owning user) fixes that
alongside the multi-root work.
Three places needed judgement rather than substitution:
db_app_scan.sh deletes database rows and port allocations for apps whose
folder is missing, and reaps "empty" app dirs. With a storage location
unmounted, every app on it looks exactly like that. Each of those
branches now gates on appStorageAvailable first — an app on an unplugged
drive is skipped with a notice, never deleted.
instance_create.sh rewrites cloned hooks so an instance touches its own
directory instead of the base app's. Its sed matched ${containers_dir}<type>,
which this sweep just replaced with $(appDir <type>) — so it would have
silently stopped redirecting, and an instance would have written to the
original's files (the adguard auth adapter case its own comment warns
about). Now matches both appDir forms, verified against bare, quoted,
unrelated-app, legacy and prose cases.
peer_shell/peer_pull streamed and extracted relative to the primary root.
Both now use the app's own root, and peer_shell keeps a single-root
fallback since it runs as a restricted SSH shell with no LibrePortal env.
Also fixes a pre-existing bug found on the way: webui_app_config.sh
tested "$containers_dir/frontend/data/last_update", one level short of the
real tree under the libreportal app dir, so the WebUI refresh trigger
after a config update has never once fired.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
45 lines
1.6 KiB
Bash
45 lines
1.6 KiB
Bash
#!/bin/bash
|
|
|
|
backupVerifySnapshot()
|
|
{
|
|
local idx="$1"
|
|
local snapshot_id="$2"
|
|
local app_name="$3"
|
|
|
|
if [[ -z "$snapshot_id" ]]; then
|
|
isNotice "No snapshot id provided — verification skipped"
|
|
return 0
|
|
fi
|
|
|
|
local scratch
|
|
# Create the scratch dir AS the backup/install user so the engine (which runs
|
|
# as that user) can restore into it and we can read it back — no root chown.
|
|
scratch=$(runFileOp mktemp -d -t libreportal-verify-XXXXXX)
|
|
|
|
isNotice "Verifying ${snapshot_id:0:8} via scratch restore at $scratch"
|
|
|
|
if ! engineRestoreSnapshot "$idx" "$snapshot_id" "$scratch" "$(appDir "$app_name")"; then
|
|
isError "Verify restore FAILED for $app_name on $(resticLocationName "$idx")"
|
|
runFileOp rm -rf "$scratch"
|
|
return 1
|
|
fi
|
|
|
|
# The scratch restore above succeeding is the real proof the snapshot is
|
|
# restorable (restic verifies each blob's hash as it restores). We can't
|
|
# compare against the live app dir any more — the live path deliberately
|
|
# differs from the snapshot (raw DB dirs and private file trees are excluded
|
|
# and replaced by dumps/captures under .lp-backup) — so just sanity-check the
|
|
# restore produced a non-empty tree.
|
|
local restored_count
|
|
restored_count=$(runFileOp find "$scratch$(appDir "$app_name")" -type f 2>/dev/null | wc -l)
|
|
|
|
runFileOp rm -rf "$scratch"
|
|
|
|
if [[ "$restored_count" -lt 1 ]]; then
|
|
isError "Verify FAILED for $app_name — restored snapshot is empty"
|
|
return 1
|
|
fi
|
|
|
|
isSuccessful "Snapshot ${snapshot_id:0:8} verified — restored $restored_count files"
|
|
}
|