From ffa10f91711d344b20848cab4d8b7cdb78ffb407 Mon Sep 17 00:00:00 2001 From: amir-climy Date: Tue, 19 May 2026 19:11:35 +0800 Subject: [PATCH] feat(get.sh): add --uninstall flag for one-liner uninstall curl -fsSL .../get.sh | sudo bash -s -- --uninstall curl -fsSL .../get.sh | sudo bash -s -- --uninstall --purge-data Detects --uninstall early, resolves INSTALL_DIR from platform, and execs the on-disk uninstall.sh (passing --purge-data through). Fails fast with a clear message if Triton is not installed. Co-Authored-By: Claude Sonnet 4.6 --- get.sh | 46 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/get.sh b/get.sh index 14d8217..a6f6c25 100644 --- a/get.sh +++ b/get.sh @@ -11,6 +11,14 @@ # Pass flags through to install.sh: # curl -fsSL https://raw.githubusercontent.com/primatekuntech/triton-install/main/get.sh \ # | sudo bash -s -- --gateway-hostname manage.example.com --manage-host-ip 10.0.0.5 +# +# Uninstall (stop containers, keep data): +# curl -fsSL https://raw.githubusercontent.com/primatekuntech/triton-install/main/get.sh \ +# | sudo bash -s -- --uninstall +# +# Uninstall and delete all data (irreversible): +# curl -fsSL https://raw.githubusercontent.com/primatekuntech/triton-install/main/get.sh \ +# | sudo bash -s -- --uninstall --purge-data set -euo pipefail @@ -26,6 +34,16 @@ warn() { printf "${YELLOW} !${RESET} %s\n" "$*"; } die() { printf "\n${RED} ✗ error:${RESET} %s\n\n" "$*" >&2; exit 1; } banner() { printf "\n${BOLD}%s${RESET}\n\n" "$*"; } +# ── arg pre-scan (before any output) ───────────────────────────────────── +UNINSTALL=0 +PASSTHROUGH=() +for arg in "$@"; do + case "$arg" in + --uninstall) UNINSTALL=1 ;; + *) PASSTHROUGH+=("$arg") ;; + esac +done + # ── OS detection ────────────────────────────────────────────────────────── case "$(uname -s)" in Linux) PLATFORM=linux ;; @@ -33,6 +51,25 @@ case "$(uname -s)" in *) die "unsupported OS: $(uname -s)" ;; esac +# ── install directory ───────────────────────────────────────────────────── +if [[ "$PLATFORM" == "linux" ]]; then + INSTALL_DIR="/opt/triton-manage-server" +else + INSTALL_DIR="${HOME}/.local/share/triton-manage-server" +fi + +# ── uninstall shortcut ──────────────────────────────────────────────────── +if [[ $UNINSTALL -eq 1 ]]; then + banner "▶ Triton Manage Server — Uninstaller" + info "platform: $PLATFORM" + if [[ "$PLATFORM" == "linux" && $EUID -ne 0 ]]; then + die "run as root on Linux:\n\n curl -fsSL https://raw.githubusercontent.com/primatekuntech/triton-install/main/get.sh | sudo bash -s -- --uninstall" + fi + [[ -f "${INSTALL_DIR}/uninstall.sh" ]] \ + || die "Triton Manage Server does not appear to be installed (${INSTALL_DIR} not found)" + exec bash "${INSTALL_DIR}/uninstall.sh" "${PASSTHROUGH[@]}" +fi + banner "▶ Triton Manage Server — Installer" info "platform: $PLATFORM" @@ -41,13 +78,6 @@ if [[ "$PLATFORM" == "linux" && $EUID -ne 0 ]]; then die "run as root on Linux:\n\n curl -fsSL https://raw.githubusercontent.com/primatekuntech/triton-install/main/get.sh | sudo bash" fi -# ── install directory ───────────────────────────────────────────────────── -if [[ "$PLATFORM" == "linux" ]]; then - INSTALL_DIR="/opt/triton-manage-server" -else - INSTALL_DIR="${HOME}/.local/share/triton-manage-server" -fi - # ── runtime detection ───────────────────────────────────────────────────── has_podman() { command -v podman >/dev/null 2>&1; } has_docker() { command -v docker >/dev/null 2>&1; } @@ -154,4 +184,4 @@ ok "installer files saved to ${INSTALL_DIR}" # ── hand off ───────────────────────────────────────────────────────────── echo "" -exec bash "${INSTALL_DIR}/install.sh" "$@" +exec bash "${INSTALL_DIR}/install.sh" "${PASSTHROUGH[@]}"