Bug: runFullUninstall used the derived $docker_dir/$containers_dir/$backup_dir, but a bare 'init.sh uninstall' on a CUSTOM-location install has no LP_*_DIR in scope and no /docker marker — so it defaulted to /libreportal-* and would MISS the real data (e.g. /mnt/ssd), leaving it behind. Fix: libreportalReadBakedRoots reads the authoritative baked record from the systemd unit (Environment=LP_SYSTEM_DIR/CONTAINERS_DIR/BACKUPS_DIR + User=<manager>) and runFullUninstall re-derives from it before removing anything. Legacy units (no LP_*_DIR) fall through to the derive defaults + /docker compat shim. Add top-level uninstall.sh: a root-only convenience that finds the installed init.sh (via the unit's system root, then common locations) and runs it — 'sudo ./uninstall.sh [--skip-docker-images]'. Verified the unit parsing extracts custom roots/manager and the discovery picks the right init.sh (without running the destructive teardown). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> Signed-off-by: librelad <librelad@digitalangels.vip>
36 lines
1.3 KiB
Bash
36 lines
1.3 KiB
Bash
#!/usr/bin/env bash
|
|
#
|
|
# LibrePortal uninstaller — convenience launcher.
|
|
#
|
|
# sudo ./uninstall.sh # remove everything
|
|
# sudo ./uninstall.sh --skip-docker-images # keep the rootless docker layer
|
|
#
|
|
# The real teardown lives in init.sh (runFullUninstall), which self-resolves the
|
|
# install's actual roots/manager from the baked systemd unit — so this just finds
|
|
# the installed init.sh and runs it. Works regardless of where LibrePortal was
|
|
# installed (custom --system-dir, etc.).
|
|
set -euo pipefail
|
|
|
|
[[ $EUID -eq 0 ]] || { echo "uninstall.sh must run as root (try: sudo)" >&2; exit 1; }
|
|
|
|
# Prefer the system root baked into the systemd unit; then common defaults; then
|
|
# the bootstrap copy in /root; then a sibling init.sh next to this script.
|
|
unit=/etc/systemd/system/libreportal.service
|
|
sysdir=""
|
|
[[ -f "$unit" ]] && sysdir=$(grep -oE 'LP_SYSTEM_DIR=\S+' "$unit" | head -1 | cut -d= -f2)
|
|
|
|
init=""
|
|
for cand in \
|
|
${sysdir:+"$sysdir/install/init.sh"} \
|
|
/libreportal-system/install/init.sh \
|
|
/docker/install/init.sh \
|
|
/root/init.sh \
|
|
"$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/init.sh"; do
|
|
[[ -n "$cand" && -f "$cand" ]] && { init="$cand"; break; }
|
|
done
|
|
|
|
[[ -n "$init" ]] || { echo "uninstall.sh: could not find init.sh to run the uninstall." >&2; exit 1; }
|
|
|
|
echo "Running uninstall via $init ..."
|
|
exec bash "$init" "$@" uninstall
|