fix(uninstall): delete installer directory on --purge-data

--purge-data now removes /opt/triton-manage-server entirely (volumes,
.env, and installer files). Without --purge-data the directory is kept
so secrets in .env survive a reinstall.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
amir-climy 2026-05-21 09:36:24 +08:00
parent 9d0a608c19
commit a8dcbe9b31

View file

@ -1,12 +1,13 @@
#!/usr/bin/env bash
# uninstall.sh — stop and remove Manage Server containers.
#
# By default, KEEPS the PostgreSQL volume (scan history, hosts, users).
# Pass --purge-data to delete the volumes as well — irreversible.
# By default, KEEPS the PostgreSQL volume (scan history, hosts, users)
# and the installer directory (preserves .env secrets for reinstall).
# Pass --purge-data to delete volumes + installer directory — irreversible.
#
# Usage:
# sudo bash uninstall.sh # stop + remove containers, keep DB
# sudo bash uninstall.sh --purge-data # also delete DB + binaries volume
# sudo bash uninstall.sh # stop + remove containers, keep DB + .env
# sudo bash uninstall.sh --purge-data # also delete DB, volumes, and /opt/triton-manage-server
set -euo pipefail
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
@ -48,9 +49,12 @@ if [[ $PURGE -eq 1 ]]; then
|| true
done
info " volumes removed"
info " .env still on disk at $SCRIPT_DIR/.env — delete manually if desired"
info " removing installer directory $SCRIPT_DIR..."
rm -rf "$SCRIPT_DIR"
info " installer directory removed"
else
info "DB + bins volumes retained (run with --purge-data to delete)"
info ".env preserved at $SCRIPT_DIR/.env — secrets reused on reinstall"
fi
info "uninstall complete"