From 12252c6005ca3a88050265de22c188d31e03297a Mon Sep 17 00:00:00 2001 From: September999999999 <32701871+September999999999@users.noreply.github.com> Date: Fri, 26 Dec 2025 21:32:22 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=8D=B8=E8=BD=BD=E6=97=B6=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E5=AE=89=E8=A3=85=E9=94=81=E6=96=87=E4=BB=B6=E4=BB=A5?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E9=87=8D=E6=96=B0=E5=AE=89=E8=A3=85=20(#39)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 卸载时自动删除 .installed 安装锁文件 - 新增 --purge 参数支持完全清理(包括配置目录) - 交互模式下增加是否删除配置目录的确认提示 - 支持中英文消息 --- deploy/install.sh | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/deploy/install.sh b/deploy/install.sh index 819cfc0c..4f4f9161 100644 --- a/deploy/install.sh +++ b/deploy/install.sh @@ -122,6 +122,10 @@ declare -A MSG_ZH=( ["removing_user"]="正在移除用户..." ["config_not_removed"]="配置目录未被移除" ["remove_manually"]="如不再需要,请手动删除" + ["removing_install_lock"]="正在移除安装锁文件..." + ["install_lock_removed"]="安装锁文件已移除,重新安装时将进入设置向导" + ["purge_prompt"]="是否同时删除配置目录?这将清除所有配置和数据 [y/N]: " + ["removing_config_dir"]="正在移除配置目录..." ["uninstall_complete"]="Sub2API 已卸载" # Help @@ -243,6 +247,10 @@ declare -A MSG_EN=( ["removing_user"]="Removing user..." ["config_not_removed"]="Config directory was NOT removed." ["remove_manually"]="Remove it manually if you no longer need it." + ["removing_install_lock"]="Removing install lock file..." + ["install_lock_removed"]="Install lock removed. Setup wizard will appear on next install." + ["purge_prompt"]="Also remove config directory? This will delete all config and data [y/N]: " + ["removing_config_dir"]="Removing config directory..." ["uninstall_complete"]="Sub2API has been uninstalled" # Help @@ -926,8 +934,31 @@ uninstall() { print_info "$(msg 'removing_user')" userdel "$SERVICE_USER" 2>/dev/null || true - print_warning "$(msg 'config_not_removed'): $CONFIG_DIR" - print_warning "$(msg 'remove_manually')" + # Remove install lock file (.installed) to allow fresh setup on reinstall + print_info "$(msg 'removing_install_lock')" + rm -f "$CONFIG_DIR/.installed" 2>/dev/null || true + rm -f "$INSTALL_DIR/.installed" 2>/dev/null || true + print_success "$(msg 'install_lock_removed')" + + # Ask about config directory removal (interactive mode only) + local remove_config=false + if [ "${PURGE:-}" = "true" ]; then + remove_config=true + elif is_interactive; then + read -p "$(msg 'purge_prompt')" -n 1 -r < /dev/tty + echo + if [[ $REPLY =~ ^[Yy]$ ]]; then + remove_config=true + fi + fi + + if [ "$remove_config" = true ]; then + print_info "$(msg 'removing_config_dir')" + rm -rf "$CONFIG_DIR" + else + print_warning "$(msg 'config_not_removed'): $CONFIG_DIR" + print_warning "$(msg 'remove_manually')" + fi print_success "$(msg 'uninstall_complete')" } @@ -944,6 +975,10 @@ main() { FORCE_YES="true" shift ;; + --purge) + PURGE="true" + shift + ;; -v|--version) if [ -n "${2:-}" ] && [[ ! "$2" =~ ^- ]]; then target_version="$2"