#!/bin/bash set -euo pipefail echo "=== Zlattea - Teardown ===" echo "" SITE_DOMAIN="${SITE_DOMAIN:-zlattea.com}" # services for svc in zlattea-api zlattea-web; do if systemctl is-enabled --quiet "$svc" 2>/dev/null; then echo "stopping and disabling $svc..." systemctl stop "$svc" 2>/dev/null || true systemctl disable "$svc" 2>/dev/null || true rm -f "/etc/systemd/system/$svc.service" fi done systemctl daemon-reload # caddy site config only (not the main Caddyfile) if [ -f "/etc/caddy/conf.d/${SITE_DOMAIN}.caddy" ]; then echo "removing caddy site config..." rm -f "/etc/caddy/conf.d/${SITE_DOMAIN}.caddy" systemctl reload caddy 2>/dev/null || true fi # remove project if [ -d /opt/zlattea ]; then echo "removing /opt/zlattea..." rm -rf /opt/zlattea fi # data dirs for d in /var/lib/zlattea /var/log/zlattea; do if [ -d "$d" ]; then echo "removing $d..." rm -rf "$d" fi done # user if id zlattea &>/dev/null; then echo "removing zlattea user..." userdel -r zlattea 2>/dev/null || true fi echo "" echo "=== Done. Zlattea has been removed from this system. ==="