uninstall: say what was left behind on other storage locations

A full uninstall removes the primary containers root and everything in it, but
app data on an ADDITIONAL storage location survives — along with each location's
.libreportal-storage marker and directories owned by a uid that stops mapping to
a user once the container account is removed.

Either policy is defensible on its own. Deleting someone's data off a separate
disk unasked is worse than leaving it, so leaving it is right. But doing one
silently and the other silently is the single option nobody can predict, and the
teardown gives no hint that the data is still there.

List them, with a note that nothing there was deleted and that a reinstall can
adopt the location again.

Found tearing the test install down: /libreportal-containers went, while two
app directories on one test disk and one on another stayed, unmentioned.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
librelad 2026-08-28 08:09:34 +01:00
parent 78bc20b8ac
commit b92134316f

31
init.sh
View File

@ -2316,6 +2316,37 @@ runFullUninstall()
isHeader "LibrePortal uninstalled" isHeader "LibrePortal uninstalled"
isNotice "Left in place: docker engine, docker-compose, apt deps, SSH config." isNotice "Left in place: docker engine, docker-compose, apt deps, SSH config."
# App data on an ADDITIONAL storage location is not removed, while the data
# on the primary root went with that root. Both are defensible on their own —
# deleting a user's data off a separate disk unasked is worse than leaving it
# — but doing one silently and the other silently is the one option nobody
# can predict. So say exactly what is still there.
#
# It also stops being obvious: the directories are owned by a uid that no
# longer maps to a user once the container account is gone, and each location
# keeps its .libreportal-storage marker, which a later install will recognise
# and adopt.
local _reg="/usr/local/lib/libreportal/storage.roots"
[[ -r "$_reg" ]] || _reg="${lp_lib_dir:-/usr/local/lib/libreportal}/storage.roots"
if [[ -r "$_reg" ]]; then
local _id _path _rest _left=0
while IFS=$'\t' read -r _id _path _rest || [[ -n "$_id" ]]; do
[[ -z "$_path" || "$_id" == \#* ]] && continue
[[ -d "$_path" ]] || continue
local _n; _n=$(find "$_path" -mindepth 1 -maxdepth 1 -type d 2>/dev/null | wc -l)
(( _n > 0 )) || continue
(( _left == 0 )) && { echo ""; isNotice "App data left on these storage locations — nothing here was deleted:"; }
printf ' %-40s %s app director%s\n' "$_path" "$_n" "$( (( _n == 1 )) && echo y || echo ies )"
_left=1
done < "$_reg"
if (( _left )); then
echo ""
printf ' %s\n' "Remove them by hand if you meant to, or leave them — a reinstall can adopt"
printf ' %s\n' "the location again and the apps restore back onto it."
echo ""
fi
fi
} }
# Only run the installer entrypoint (root check + init flow) when init.sh is # Only run the installer entrypoint (root check + init flow) when init.sh is