#!/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