Improve RDP API installer with rerun detection
Changes: - Detect if RDP Toggle API is already installed and running - Show test menu immediately on rerun (no reinstallation) - Add option 3 (status check) and option 4 (exit) to test menu - Extract test menu to reusable function show_test_menu() - Both fresh install and rerun show same interactive test menu Now users can easily test RDP toggle by simply rerunning the installer script. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
1977d21a9b
commit
e7d5dd02d2
@ -5,8 +5,6 @@
|
||||
|
||||
set -e
|
||||
|
||||
echo "RDP Toggle API 설치 시작..."
|
||||
|
||||
# IP 주소 가져오기 (Headscale 우선, 없으면 로컬 IP)
|
||||
get_primary_ip() {
|
||||
# Headscale VPN IP 확인 (100.64.x.x 대역)
|
||||
@ -29,11 +27,98 @@ get_primary_ip() {
|
||||
echo "127.0.0.1"
|
||||
}
|
||||
|
||||
# 테스트 메뉴 함수
|
||||
show_test_menu() {
|
||||
echo ""
|
||||
echo "=========================================="
|
||||
echo "RDP API를 테스트하시겠습니까?"
|
||||
echo " 1) RDP 모드로 전환 테스트"
|
||||
echo " 2) Shell 모드로 전환 테스트"
|
||||
echo " 3) 현재 상태 확인"
|
||||
echo " 4) 종료"
|
||||
echo ""
|
||||
echo -n "선택 [1/2/3/4]: "
|
||||
read -r test_choice </dev/tty
|
||||
|
||||
case "$test_choice" in
|
||||
1)
|
||||
echo ""
|
||||
echo "RDP 모드로 전환 중..."
|
||||
if curl -s -X POST http://localhost:8090/toggle \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{"mode":"rdp"}' > /dev/null 2>&1; then
|
||||
echo "✅ RDP 모드로 전환 완료!"
|
||||
echo ""
|
||||
echo "현재 상태:"
|
||||
curl -s http://localhost:8090/status | python3 -m json.tool 2>/dev/null || curl -s http://localhost:8090/status
|
||||
else
|
||||
echo "❌ RDP 모드 전환 실패. 서비스 상태를 확인하세요:"
|
||||
echo " systemctl status rdp-toggle-api"
|
||||
fi
|
||||
;;
|
||||
2)
|
||||
echo ""
|
||||
echo "Shell 모드로 전환 중..."
|
||||
if curl -s -X POST http://localhost:8090/toggle \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{"mode":"shell"}' > /dev/null 2>&1; then
|
||||
echo "✅ Shell 모드로 전환 완료!"
|
||||
echo ""
|
||||
echo "현재 상태:"
|
||||
curl -s http://localhost:8090/status | python3 -m json.tool 2>/dev/null || curl -s http://localhost:8090/status
|
||||
else
|
||||
echo "❌ Shell 모드 전환 실패. 서비스 상태를 확인하세요:"
|
||||
echo " systemctl status rdp-toggle-api"
|
||||
fi
|
||||
;;
|
||||
3)
|
||||
echo ""
|
||||
echo "현재 상태 확인 중..."
|
||||
curl -s http://localhost:8090/status | python3 -m json.tool 2>/dev/null || curl -s http://localhost:8090/status
|
||||
;;
|
||||
4)
|
||||
echo ""
|
||||
echo "종료합니다."
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
echo ""
|
||||
echo "잘못된 선택입니다."
|
||||
;;
|
||||
esac
|
||||
|
||||
echo ""
|
||||
}
|
||||
|
||||
# 설치 디렉토리 설정
|
||||
INSTALL_DIR="/opt/rdp-toggle-api"
|
||||
VENV_DIR="$INSTALL_DIR/venv"
|
||||
GITEA_BASE_URL="https://git.0bin.in/thug0bin/pve9-repo-fix/raw/branch/main/RDP"
|
||||
|
||||
# 이미 설치되어 있는지 확인
|
||||
if systemctl is-active --quiet rdp-toggle-api.service && [ -f "$INSTALL_DIR/rdp-toggle-api.py" ]; then
|
||||
echo ""
|
||||
echo "=========================================="
|
||||
echo "✅ RDP Toggle API가 이미 설치되어 실행 중입니다!"
|
||||
echo "=========================================="
|
||||
echo ""
|
||||
echo "📍 API 서버: http://$(get_primary_ip):8090"
|
||||
echo "📁 설치 위치: $INSTALL_DIR"
|
||||
echo ""
|
||||
|
||||
# 바로 테스트 메뉴 보여주기
|
||||
show_test_menu
|
||||
|
||||
echo ""
|
||||
echo "=========================================="
|
||||
echo "완료!"
|
||||
echo "=========================================="
|
||||
echo ""
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "RDP Toggle API 설치 시작..."
|
||||
|
||||
# Python 및 venv 설치
|
||||
echo "Python 및 필수 패키지 설치 중..."
|
||||
apt update
|
||||
@ -92,76 +177,9 @@ echo ""
|
||||
echo "📍 API 서버: http://$(get_primary_ip):8090"
|
||||
echo "📁 설치 위치: $INSTALL_DIR"
|
||||
echo ""
|
||||
echo "✅ 사용 방법:"
|
||||
echo " 상태 확인:"
|
||||
echo " curl http://localhost:8090/status"
|
||||
echo ""
|
||||
echo " RDP 모드 활성화:"
|
||||
echo " curl -X POST http://localhost:8090/toggle \\"
|
||||
echo " -H 'Content-Type: application/json' \\"
|
||||
echo " -d '{\"mode\":\"rdp\"}'"
|
||||
echo ""
|
||||
echo " Shell 모드 전환:"
|
||||
echo " curl -X POST http://localhost:8090/toggle \\"
|
||||
echo " -H 'Content-Type: application/json' \\"
|
||||
echo " -d '{\"mode\":\"shell\"}'"
|
||||
echo ""
|
||||
echo "🔧 서비스 관리:"
|
||||
echo " systemctl status rdp-toggle-api"
|
||||
echo " systemctl restart rdp-toggle-api"
|
||||
echo " systemctl stop rdp-toggle-api"
|
||||
echo ""
|
||||
|
||||
# 테스트 메뉴 제공
|
||||
echo "=========================================="
|
||||
echo "RDP API를 테스트하시겠습니까?"
|
||||
echo " 1) RDP 모드로 전환 테스트"
|
||||
echo " 2) Shell 모드로 전환 테스트"
|
||||
echo " 3) 건너뛰기"
|
||||
echo ""
|
||||
echo -n "선택 [1/2/3]: "
|
||||
read -r test_choice </dev/tty
|
||||
|
||||
case "$test_choice" in
|
||||
1)
|
||||
echo ""
|
||||
echo "RDP 모드로 전환 중..."
|
||||
if curl -s -X POST http://localhost:8090/toggle \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{"mode":"rdp"}' > /dev/null 2>&1; then
|
||||
echo "✅ RDP 모드로 전환 완료!"
|
||||
echo ""
|
||||
echo "현재 상태:"
|
||||
curl -s http://localhost:8090/status | python3 -m json.tool 2>/dev/null || curl -s http://localhost:8090/status
|
||||
else
|
||||
echo "❌ RDP 모드 전환 실패. 서비스 상태를 확인하세요:"
|
||||
echo " systemctl status rdp-toggle-api"
|
||||
fi
|
||||
;;
|
||||
2)
|
||||
echo ""
|
||||
echo "Shell 모드로 전환 중..."
|
||||
if curl -s -X POST http://localhost:8090/toggle \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{"mode":"shell"}' > /dev/null 2>&1; then
|
||||
echo "✅ Shell 모드로 전환 완료!"
|
||||
echo ""
|
||||
echo "현재 상태:"
|
||||
curl -s http://localhost:8090/status | python3 -m json.tool 2>/dev/null || curl -s http://localhost:8090/status
|
||||
else
|
||||
echo "❌ Shell 모드 전환 실패. 서비스 상태를 확인하세요:"
|
||||
echo " systemctl status rdp-toggle-api"
|
||||
fi
|
||||
;;
|
||||
3)
|
||||
echo ""
|
||||
echo "테스트를 건너뜁니다."
|
||||
;;
|
||||
*)
|
||||
echo ""
|
||||
echo "잘못된 선택입니다. 테스트를 건너뜁니다."
|
||||
;;
|
||||
esac
|
||||
# 테스트 메뉴 보여주기
|
||||
show_test_menu
|
||||
|
||||
echo ""
|
||||
echo "=========================================="
|
||||
|
||||
Loading…
Reference in New Issue
Block a user