#!/bin/bash
# 卸载清理完成后执行：按卸载向导的选择决定是否删除本地数据。
# - keep（默认）：保留 @appdata 与 @appconf，重装后自动恢复登录态与配置；
# - delete：清空运行数据（含可写运行副本、登录态、映射、日志）与配置（端口、锁密码）。
set -e

if [ "${wizard_purge_data:-keep}" = "delete" ]; then
    for d in "$TRIM_PKGVAR" "$TRIM_PKGETC"; do
        if [ -n "$d" ] && [ -d "$d" ]; then
            # 只清空目录内容，保留 fnOS 管理的目录本身。
            find "$d" -mindepth 1 -delete 2>/dev/null || true
        fi
    done
fi

exit 0
