Add rerun detection and toggle menu to all-in-one RDP installer

When script is rerun on already-installed system:
- Detect existing RDP setup (API + getty config)
- Show menu with 3 options:
  1) RDP toggle menu - Interactive RDP/Shell switching
  2) Reinstall - Overwrite existing setup
  3) Exit

Toggle menu features:
- Switch between RDP and Shell modes
- Check current status
- Loop until user exits
- Uses same API as standalone installer

This turns the installer into a convenient RDP control tool on rerun.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Claude 2025-11-17 03:05:29 +00:00
parent e7d5dd02d2
commit d02883256f

View File

@ -655,14 +655,121 @@ print_completion() {
esac
}
# RDP 토글 테스트 메뉴
show_rdp_toggle_menu() {
while true; do
echo ""
echo "=========================================="
echo "RDP 제어 메뉴"
echo " 1) RDP 모드로 전환"
echo " 2) Shell 모드로 전환"
echo " 3) 현재 상태 확인"
echo " 4) 종료"
echo ""
echo -n "선택 [1/2/3/4]: "
read -r choice </dev/tty
case "$choice" in
1)
echo ""
msg_info "RDP 모드로 전환 중..."
if curl -s -X POST http://localhost:8090/toggle \
-H 'Content-Type: application/json' \
-d '{"mode":"rdp"}' > /dev/null 2>&1; then
msg_ok "RDP 모드로 전환 완료!"
echo ""
echo "현재 상태:"
curl -s http://localhost:8090/status | python3 -m json.tool 2>/dev/null || curl -s http://localhost:8090/status
else
msg_error "RDP 모드 전환 실패. 서비스 상태를 확인하세요: systemctl status rdp-toggle-api"
fi
;;
2)
echo ""
msg_info "Shell 모드로 전환 중..."
if curl -s -X POST http://localhost:8090/toggle \
-H 'Content-Type: application/json' \
-d '{"mode":"shell"}' > /dev/null 2>&1; then
msg_ok "Shell 모드로 전환 완료!"
echo ""
echo "현재 상태:"
curl -s http://localhost:8090/status | python3 -m json.tool 2>/dev/null || curl -s http://localhost:8090/status
else
msg_error "Shell 모드 전환 실패. 서비스 상태를 확인하세요: systemctl status rdp-toggle-api"
fi
;;
3)
echo ""
msg_info "현재 상태 확인 중..."
curl -s http://localhost:8090/status | python3 -m json.tool 2>/dev/null || curl -s http://localhost:8090/status
;;
4)
echo ""
msg_ok "종료합니다."
return 0
;;
*)
echo ""
msg_warn "잘못된 선택입니다."
;;
esac
echo ""
done
}
# 메인 함수
main() {
print_header
# 사전 검사
check_root
check_proxmox_version
# 이미 설치되어 있는지 확인
if systemctl is-active --quiet rdp-toggle-api.service && \
[ -f "/opt/rdp-toggle-api/rdp-toggle-api.py" ] && \
[ -f "/etc/systemd/system/getty@tty1.service.d/override.conf" ]; then
echo ""
echo -e "${GREEN}=========================================="
echo "✅ RDP 자동화 시스템이 이미 설치되어 있습니다!"
echo -e "==========================================${NC}"
echo ""
echo -e "${CYAN}📍 API 서버: http://$(get_primary_ip):8090${NC}"
echo ""
echo "다음 중 선택하세요:"
echo " 1) RDP 토글 메뉴 (RDP ↔ Shell 전환)"
echo " 2) 재설치 (기존 설정 삭제 후 새로 설치)"
echo " 3) 종료"
echo ""
echo -n "선택 [1/2/3]: "
read -r reinstall_choice </dev/tty
case "$reinstall_choice" in
1)
# RDP 토글 메뉴 실행
show_rdp_toggle_menu
exit 0
;;
2)
echo ""
msg_warn "기존 설정을 삭제하고 재설치를 시작합니다..."
# 기존 설정 삭제는 하지 않고 덮어쓰기로 진행
echo ""
;;
3)
echo ""
msg_ok "종료합니다."
exit 0
;;
*)
echo ""
msg_warn "잘못된 선택입니다. 종료합니다."
exit 1
;;
esac
fi
# 사용자 입력
get_user_input