fix: 卸载时删除安装锁文件以支持重新安装 (#39)
- 卸载时自动删除 .installed 安装锁文件 - 新增 --purge 参数支持完全清理(包括配置目录) - 交互模式下增加是否删除配置目录的确认提示 - 支持中英文消息
This commit is contained in:
committed by
GitHub
parent
2d89f36687
commit
12252c6005
@@ -122,6 +122,10 @@ declare -A MSG_ZH=(
|
|||||||
["removing_user"]="正在移除用户..."
|
["removing_user"]="正在移除用户..."
|
||||||
["config_not_removed"]="配置目录未被移除"
|
["config_not_removed"]="配置目录未被移除"
|
||||||
["remove_manually"]="如不再需要,请手动删除"
|
["remove_manually"]="如不再需要,请手动删除"
|
||||||
|
["removing_install_lock"]="正在移除安装锁文件..."
|
||||||
|
["install_lock_removed"]="安装锁文件已移除,重新安装时将进入设置向导"
|
||||||
|
["purge_prompt"]="是否同时删除配置目录?这将清除所有配置和数据 [y/N]: "
|
||||||
|
["removing_config_dir"]="正在移除配置目录..."
|
||||||
["uninstall_complete"]="Sub2API 已卸载"
|
["uninstall_complete"]="Sub2API 已卸载"
|
||||||
|
|
||||||
# Help
|
# Help
|
||||||
@@ -243,6 +247,10 @@ declare -A MSG_EN=(
|
|||||||
["removing_user"]="Removing user..."
|
["removing_user"]="Removing user..."
|
||||||
["config_not_removed"]="Config directory was NOT removed."
|
["config_not_removed"]="Config directory was NOT removed."
|
||||||
["remove_manually"]="Remove it manually if you no longer need it."
|
["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"
|
["uninstall_complete"]="Sub2API has been uninstalled"
|
||||||
|
|
||||||
# Help
|
# Help
|
||||||
@@ -926,8 +934,31 @@ uninstall() {
|
|||||||
print_info "$(msg 'removing_user')"
|
print_info "$(msg 'removing_user')"
|
||||||
userdel "$SERVICE_USER" 2>/dev/null || true
|
userdel "$SERVICE_USER" 2>/dev/null || true
|
||||||
|
|
||||||
print_warning "$(msg 'config_not_removed'): $CONFIG_DIR"
|
# Remove install lock file (.installed) to allow fresh setup on reinstall
|
||||||
print_warning "$(msg 'remove_manually')"
|
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')"
|
print_success "$(msg 'uninstall_complete')"
|
||||||
}
|
}
|
||||||
@@ -944,6 +975,10 @@ main() {
|
|||||||
FORCE_YES="true"
|
FORCE_YES="true"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
--purge)
|
||||||
|
PURGE="true"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
-v|--version)
|
-v|--version)
|
||||||
if [ -n "${2:-}" ] && [[ ! "$2" =~ ^- ]]; then
|
if [ -n "${2:-}" ] && [[ ! "$2" =~ ^- ]]; then
|
||||||
target_version="$2"
|
target_version="$2"
|
||||||
|
|||||||
Reference in New Issue
Block a user