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