From f2c2b0485a5e903e98e5cfb600b7852133835901 Mon Sep 17 00:00:00 2001 From: librelad Date: Mon, 25 May 2026 18:59:38 +0100 Subject: [PATCH] refactor(uninstall): drop repo uninstall.sh; init.sh generates the command MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove the redundant repo-root uninstall.sh (it duplicated libreportal-uninstall). init.sh now GENERATES the libreportal-uninstall launcher into the fixed footprint (/usr/local/lib/libreportal/uninstall.sh + the /usr/local/bin symlink) — same pattern as the CLI wrapper, so the on-box command survives without a separate repo file. The launcher just runs the engine's uninstall ($script_dir/init.sh baked in, /root/init.sh fallback). This resolves the install/uninstall asymmetry: a bootstrap (install.sh) exists only because install faces a bare box with no code yet; uninstall always runs the engine that's already installed, so it needs no bootstrap — just a generated door into init.sh. Repo root install/uninstall surface is now init.sh + install.sh. Co-Authored-By: Claude Opus 4.7 Signed-off-by: librelad --- init.sh | 23 ++++++++++++++++------- uninstall.sh | 35 ----------------------------------- 2 files changed, 16 insertions(+), 42 deletions(-) delete mode 100644 uninstall.sh diff --git a/init.sh b/init.sh index 7415ae2..4fbd077 100755 --- a/init.sh +++ b/init.sh @@ -1468,13 +1468,22 @@ EOF # Put it on $PATH via a symlink (replaces any older real file at this path). sudo ln -sfn "$command_script" "$command_symlink" - # Install the uninstaller at the fixed footprint + put it on $PATH as - # `libreportal-uninstall` — a location-agnostic command (it resolves the real - # data roots from the systemd unit at run time), so users never type a data path. - if [[ -f "$script_dir/uninstall.sh" ]]; then - sudo install -m 0755 -o root -g root "$script_dir/uninstall.sh" "$lp_lib_dir/uninstall.sh" - sudo ln -sfn "$lp_lib_dir/uninstall.sh" /usr/local/bin/libreportal-uninstall - fi + # Generate the uninstall command at the fixed footprint + put it on $PATH as + # `libreportal-uninstall` (same idea as the CLI wrapper above — generated by + # init.sh, not a separate repo file). It just runs the engine's uninstall, so + # users never type a data path. $script_dir is baked in; /root/init.sh is a + # fallback if the install tree is already gone. + sudo tee "$lp_lib_dir/uninstall.sh" >/dev/null <&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