Add Docker uninstall script

This commit is contained in:
cyph3rasi
2026-03-07 17:16:25 -08:00
parent afa732503c
commit 0a54a3229a
3 changed files with 128 additions and 0 deletions
+5
View File
@@ -30,6 +30,11 @@ Database migrations run automatically on startup and during updates.
docker compose pull && docker compose up -d docker compose pull && docker compose up -d
``` ```
**Full uninstall:**
```bash
curl -fsSL https://synapsis.social/uninstall.sh | bash
```
For detailed Docker setup, see [docker/README.md](docker/README.md). For detailed Docker setup, see [docker/README.md](docker/README.md).
--- ---
+10
View File
@@ -56,6 +56,16 @@ cd /opt/synapsis
docker compose pull && docker compose up -d docker compose pull && docker compose up -d
``` ```
## 🗑️ Full Uninstall
To remove Synapsis completely from a host and start over:
```bash
curl -fsSL https://synapsis.social/uninstall.sh | bash
```
The uninstaller destroys the Synapsis containers, volumes, network, cached Synapsis images, and `/opt/synapsis`. It requires typing `DELETE` unless you set `FORCE=1`.
--- ---
## 🛠️ Common Commands ## 🛠️ Common Commands
+113
View File
@@ -0,0 +1,113 @@
#!/bin/sh
set -eu
INSTALL_DIR="${1:-${INSTALL_DIR:-/opt/synapsis}}"
PROJECT_NAME="${PROJECT_NAME:-synapsis}"
IMAGE_REPO="${IMAGE_REPO:-ghcr.io/gnosyslabs/synapsis}"
require_command() {
if ! command -v "$1" >/dev/null 2>&1; then
echo "❌ Required command not found: $1" >&2
exit 1
fi
}
confirm_uninstall() {
if [ "${FORCE:-0}" = "1" ] || [ "${YES:-0}" = "1" ]; then
return
fi
echo "========================================"
echo " Synapsis Docker Uninstaller"
echo "========================================"
echo " Install dir: ${INSTALL_DIR}"
echo " Project name: ${PROJECT_NAME}"
echo ""
echo "This will permanently remove:"
echo " - Synapsis containers"
echo " - Synapsis Docker volumes and network"
echo " - Synapsis images pulled from GHCR/local cache"
echo " - ${INSTALL_DIR}"
echo ""
printf "Type DELETE to continue: "
read -r confirmation
if [ "$confirmation" != "DELETE" ]; then
echo "Aborted."
exit 1
fi
}
cleanup_with_compose() {
if [ -f "${INSTALL_DIR}/docker-compose.yml" ]; then
echo "🧹 Stopping Synapsis compose stack"
if [ -f "${INSTALL_DIR}/.env" ]; then
docker compose --env-file "${INSTALL_DIR}/.env" -f "${INSTALL_DIR}/docker-compose.yml" down --volumes --remove-orphans || true
else
docker compose -f "${INSTALL_DIR}/docker-compose.yml" down --volumes --remove-orphans || true
fi
fi
}
cleanup_named_resources() {
for container in synapsis-caddy synapsis-app synapsis-db; do
if docker ps -aq --filter "name=^${container}$" | grep -q .; then
echo "🗑️ Removing container ${container}"
docker rm -f "${container}" >/dev/null 2>&1 || true
fi
done
for volume in \
synapsis_postgres_data \
synapsis_uploads_data \
synapsis_port_data \
synapsis_caddy_data \
synapsis_caddy_config
do
if docker volume inspect "${volume}" >/dev/null 2>&1; then
echo "🗑️ Removing volume ${volume}"
docker volume rm -f "${volume}" >/dev/null 2>&1 || true
fi
done
if docker network inspect synapsis_synapsis-network >/dev/null 2>&1; then
echo "🗑️ Removing network synapsis_synapsis-network"
docker network rm synapsis_synapsis-network >/dev/null 2>&1 || true
fi
}
cleanup_images() {
docker images --format '{{.Repository}}:{{.Tag}}' | while IFS= read -r image; do
case "$image" in
"${IMAGE_REPO}:"*|synapsis:*)
echo "🗑️ Removing image ${image}"
docker rmi -f "$image" >/dev/null 2>&1 || true
;;
esac
done
}
remove_install_dir() {
if [ -d "${INSTALL_DIR}" ]; then
echo "🗑️ Removing ${INSTALL_DIR}"
rm -rf "${INSTALL_DIR}"
fi
}
require_command docker
require_command rm
if [ "$(id -u)" -ne 0 ]; then
echo "❌ Run this uninstaller as root or with sudo." >&2
exit 1
fi
confirm_uninstall
cleanup_with_compose
cleanup_named_resources
cleanup_images
remove_install_dir
echo ""
echo "✅ Synapsis has been removed from this host."