#!/bin/bash
{ echo "[$(date '+%F %T')] invoked=$0 args=$* caller=[$(ps -o args= -p "$PPID" 2>/dev/null || echo unknown)]" >> "${TRIM_PKGVAR:-/vol1/@appdata/fnwebstack}/flight.log" 2>/dev/null; chmod 644 "${TRIM_PKGVAR:-/vol1/@appdata/fnwebstack}/flight.log" 2>/dev/null || true; } || true
# uninstall_callback —— 卸载完成后：确保服务停止、本应用写入的系统配置已撤销
LOG="${TRIM_TEMP_LOGFILE:-/tmp/fnwebstack-uninstall.log}"
systemctl stop nginx php8.3-fpm mariadb redis-server 2>/dev/null || true
rm -f /etc/nginx/sites-enabled/default /etc/nginx/sites-available/default 2>/dev/null || true
rm -f /etc/nginx/sites-enabled/fnws-*.conf /etc/nginx/sites-available/fnws-*.conf 2>/dev/null || true
rm -f /etc/sudoers.d/fnwebstack /usr/local/bin/fnwsctl 2>/dev/null || true
rm -f /etc/nginx/conf.d/fn-webstack-sites.conf 2>/dev/null || true
echo "fnwebstack uninstalled" >> "$LOG"
exit 0
