#!/bin/sh
# One-click uninstall: container + Postgres cluster are removed in preuninst
# (via the setuid kv-helper, since the cluster dir is owned by the postgres
# UID and @appstore is already gone by the time this runs). Here we only
# clean config; the rm -rf below is a best-effort fallback for clusters the
# preuninst wipe could not reach.
PKG_NAME="kvtube"
PORT_CONFIG_FILE="/var/packages/${PKG_NAME}/etc/port_config"
PKGVAR_DIR="${SYNOPKG_PKGVAR:-/var/packages/${PKG_NAME}/var}"

if [ "${SYNOPKG_PKG_STATUS}" = "UNINSTALL" ]; then
    rm -f "${PORT_CONFIG_FILE}"
    rm -rf "${PKGVAR_DIR}/data/invidious/db" 2>/dev/null || true
fi
exit 0