Compare commits

...

6 Commits

Author SHA1 Message Date
root
f8f5c6face fix: RDP 제어 스크립트 상태 감지 로직 개선
- X 서버 프로세스 검출 패턴 수정 (Xorg.*tty1 → /usr/lib/xorg/Xorg)
- RDP 연결 상태 검사 개선으로 실제 실행 상태 정확히 반영
- Gitea 리포지토리 설정 가이드 문서 추가

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-10 19:41:09 +09:00
root
afb79d1872 docs: RDP 제어 스크립트 curl 다운로드 방법 추가
- README.md에 rdp-control.sh 직접 다운로드 방법 추가
- curl 명령어로 스크립트 다운로드 후 바로 사용 가능
- 리포지토리 클론 없이도 제어 스크립트 사용 가능

🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-06 01:33:02 +09:00
root
1e238d0867 feat: RDP 제어 스크립트 추가 및 README 업데이트
- rdp-control.sh 추가
  - 명령줄에서 RDP 자동 연결 제어
  - start/stop/status/restart/logs 명령 지원
  - 실시간 상태 모니터링 기능
  - 컬러 출력 및 사용자 친화적 인터페이스
  - 프로세스 추적 및 로그 확인 기능

- README.md 업데이트
  - RDP 제어 스크립트 사용법 추가
  - 주요 기능에 제어 스크립트 설명 추가
  - 권장 명령어로 rdp-control.sh 제시

🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-06 01:03:29 +09:00
root
50bc6f5432 docs: README 업데이트 및 Perfect 버전 스크립트 추가
- proxmox-auto-rdp-perfect.sh 추가 (개선된 버전)
- README.md 대폭 업데이트
  - 웹 제어 패널 설치 방법 추가
  - Perfect 버전 한 줄 설치 명령 추가
  - 서비스 관리 명령어 추가
  - 업데이트 이력 추가 (v1.1)
- 마우스 커서 문제 해결 내용 문서화
- Tailscale 통합 기능 설명 추가

🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-06 00:50:50 +09:00
root
9d0adf6f8b feat: RDP 자동 로그인 웹 제어 패널 추가
- Flask 기반 웹 제어 패널 구현
- 토글 스위치로 RDP 자동 로그인 제어
- Tailscale IP 기반 접속 정보 표시
- Python venv 환경 사용
- systemd 서비스로 자동 실행
- PBS 자동 등록 스크립트 기획서 추가

🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-06 00:33:02 +09:00
root
ddcf41c515 Fix: RDP 마우스 커서 사라짐 문제 해결
- unclutter 자동 숨기기 기능 비활성화
- RDP 연결 시 마우스 커서가 정상적으로 표시되도록 수정

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-05 19:47:43 +09:00
12 changed files with 2511 additions and 9 deletions

147
README.md
View File

@@ -4,26 +4,72 @@ Proxmox VE 호스트가 부팅 시 자동으로 RDP 연결하도록 설정하는
## 🚀 한 줄 설치
### 기본 설치 스크립트
```bash
bash -c "$(curl -fsSL https://git.0bin.in/thug0bin/proxmox-rdp-autosetup/raw/branch/main/proxmox-auto-rdp-setup.sh)"
```
## 📋 기능
### 개선된 설치 스크립트 (Perfect 버전)
```bash
bash -c "$(curl -fsSL https://git.0bin.in/thug0bin/proxmox-rdp-autosetup/raw/branch/main/proxmox-auto-rdp-perfect.sh)"
```
### 웹 제어 패널 설치
```bash
# 리포지토리 클론 후
git clone https://git.0bin.in/thug0bin/proxmox-rdp-autosetup.git
cd proxmox-rdp-autosetup
# 웹 제어 패널 설치
bash install_web_control.sh
```
### RDP 제어 스크립트 다운로드
```bash
# curl로 직접 다운로드
curl -fsSL https://git.0bin.in/thug0bin/proxmox-rdp-autosetup/raw/branch/main/rdp-control.sh -o rdp-control.sh
chmod +x rdp-control.sh
# 사용법
./rdp-control.sh start
./rdp-control.sh status
./rdp-control.sh stop
```
## 📋 주요 기능
### 자동 RDP 설정
- **완전 자동화**: 사용자 입력 후 모든 설정 자동 수행
- **강화된 검증**: 입력값 검증 및 네트워크 연결 테스트
- **에러 처리**: 단계별 실패 처리 및 재시도 로직
- **백업**: 기존 설정 자동 백업
- **사용자 친화적**: 컬러 출력 및 진행 상황 표시
- **마우스 커서 문제 해결**: 최신 버전에서 마우스 커서 사라짐 문제 수정
### 웹 제어 패널 (신규)
- **Flask 기반 웹 인터페이스**: RDP 자동 로그인을 웹에서 제어
- **토글 스위치**: 간단한 ON/OFF 제어
- **Tailscale 통합**: Tailscale IP로 원격 접속 가능
- **실시간 상태 모니터링**: 서비스 상태 실시간 확인
- **로그 뷰어**: 시스템 로그 확인 기능
### RDP 제어 스크립트 (신규)
- **명령줄 제어**: 터미널에서 간편한 RDP 제어
- **상태 모니터링**: 실시간 연결 상태 확인
- **로그 관리**: RDP 연결 로그 확인 기능
- **자동 재시작**: 연결 문제 시 자동 재시작
- **사용자 친화적**: 컬러 출력 및 직관적 명령어
## 🎯 지원 환경
- **OS**: Proxmox VE 8.x 이상 (Debian 기반)
- **권한**: root 권한 필요
- **네트워크**: 인터넷 연결 필요
- **Python**: 3.x (웹 제어 패널용)
## 📖 동작 원리
### RDP 자동 연결
1. **부팅 완료** → systemd가 tty1에서 rdpuser 자동 로그인
2. **로그인** → .bash_profile이 tty1에서 startx 실행
3. **X 시작** → .xinitrc가 실행됨
@@ -31,28 +77,52 @@ bash -c "$(curl -fsSL https://git.0bin.in/thug0bin/proxmox-rdp-autosetup/raw/bra
5. **FreeRDP3 실행** → 풀스크린 RDP 연결
6. **RDP 종료시** → X 세션도 함께 종료
### 웹 제어 패널
1. **Flask 서버** → Gunicorn으로 실행
2. **systemd 서비스** → 부팅 시 자동 시작
3. **REST API** → 상태 조회 및 제어
4. **웹 UI** → 토글 스위치로 간편 제어
## 🔧 설치 과정
### RDP 자동 설정
스크립트 실행 시 다음 정보를 입력하세요:
- **RDP 서버 주소** (예: example.com:3389)
- **RDP 사용자명**
- **RDP 패스워드**
- **로컬 사용자명** (기본값: rdpuser)
### 웹 제어 패널
```bash
# 설치
bash install_web_control.sh
# 접속
http://[서버IP]:5000
http://[Tailscale IP]:5000
# 제거
bash uninstall_web_control.sh
```
## 📝 설정 파일
스크립트가 자동 생성하는 주요 설정 파일들:
### RDP 관련 파일
- `/etc/systemd/system/getty@tty1.service.d/override.conf` - 자동 로그인
- `/home/[사용자]/.bash_profile` - X 자동 시작
- `/home/[사용자]/.xinitrc` - RDP 연결 실행
- `/home/[사용자]/.config/openbox/rc.xml` - 풀스크린 최적화
### 웹 제어 패널 파일
- `/root/proxmox-rdp-autosetup/rdp_control_web.py` - Flask 애플리케이션
- `/root/proxmox-rdp-autosetup/templates/index.html` - 웹 UI
- `/etc/systemd/system/rdp-control-web.service` - systemd 서비스
## 🛡️ 보안 고려사항
- RDP 패스워드가 설정 파일에 평문으로 저장됩니다
- 운영 환경에서는 보안 강화 조치 필요
- 웹 제어 패널은 기본적으로 인증 없이 접근 가능 (필요시 인증 추가)
- 시스템 접근을 위해 Ctrl+Alt+F2로 다른 터미널 사용 가능
## 🔄 문제 해결
@@ -68,12 +138,71 @@ bash -c "$(curl -fsSL https://git.0bin.in/thug0bin/proxmox-rdp-autosetup/raw/bra
- X 서버 로그 확인: `cat /home/rdpuser/.local/share/xorg/Xorg.0.log`
- systemd 로그 확인: `journalctl -u getty@tty1.service -f`
3. **설정 초기화**
3. **마우스 커서 사라짐**
- 최신 버전 스크립트로 재설치
- openbox 설정에 커서 테마 확인
4. **웹 제어 패널 접속 불가**
- 서비스 상태 확인: `systemctl status rdp-control-web`
- 방화벽 설정 확인 (포트 5000)
- 로그 확인: `journalctl -u rdp-control-web -f`
5. **설정 초기화**
- 백업에서 복원: `/root/proxmox-rdp-backup-[날짜시간]/`
## 🔍 서비스 관리 명령어
### RDP 제어 스크립트 (권장)
```bash
# RDP 자동 연결 시작
bash rdp-control.sh start
# RDP 자동 연결 중지
bash rdp-control.sh stop
# RDP 연결 상태 확인
bash rdp-control.sh status
# RDP 자동 연결 재시작
bash rdp-control.sh restart
# RDP 로그 확인
bash rdp-control.sh logs
# 도움말 보기
bash rdp-control.sh help
```
### systemd 서비스 직접 제어
```bash
# 상태 확인
systemctl status getty@tty1.service
# 서비스 재시작
systemctl restart xrdp
systemctl restart xrdp-sesman
# 로그 확인
journalctl -u xrdp -f
journalctl -u getty@tty1.service -f
```
### 웹 제어 패널
```bash
# 상태 확인
systemctl status rdp-control-web
# 재시작
systemctl restart rdp-control-web
# 로그 확인
journalctl -u rdp-control-web -f
```
## 📚 상세 문서
더 자세한 설정 과정과 문제 해결 방법은 [proxmox_auto_rdp_setup_korean.md](./proxmox_auto_rdp_setup_korean.md)를 참고하세요.
- [상세 설정 가이드](./proxmox_auto_rdp_setup_korean.md) - RDP 자동 설정 상세 문서
- [PBS 자동 등록 기획서](./pbs_auto_registration.md) - Proxmox Backup Server 자동 등록 (개발 예정)
## 🤝 기여
@@ -87,7 +216,11 @@ MIT License
**개발**: 시골약사 & Claude Code Assistant
**생성일**: 2025-08-24
**최종 업데이트**: v1.0
**최종 업데이트**: v1.1 (2025-09-06)
### 📌 업데이트 이력
- v1.1 (2025-09-06): 웹 제어 패널 추가, 마우스 커서 문제 해결
- v1.0 (2025-08-24): 최초 릴리즈
🤖 Generated with [Claude Code](https://claude.ai/code)

309
gitea설정.md Normal file
View File

@@ -0,0 +1,309 @@
# Gitea 리포지토리 생성 및 푸시 가이드
## 🏠 서버 정보
- **Gitea 서버**: `git.0bin.in`
- **사용자명**: `thug0bin`
- **이메일**: `thug0bin@gmail.com`
- **액세스 토큰**: `d83f70b219c6028199a498fb94009f4c1debc9a9`
## 🚀 새 리포지토리 생성 및 푸시 과정
### 1. 로컬 Git 리포지토리 초기화
```bash
# 프로젝트 디렉토리로 이동
cd /path/to/your/project
# Git 초기화
git init
# .gitignore 파일 생성 (필요시)
cat > .gitignore << 'EOF'
# Dependencies
node_modules/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Build outputs
dist/
build/
# Environment variables
.env
.env.local
.env.development.local
.env.test.local
.env.production.local
# IDE
.vscode/
.idea/
# OS
.DS_Store
Thumbs.db
# Logs
*.log
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Python
__pycache__/
*.py[cod]
*$py.class
*.so
.Python
env/
venv/
# Database
*.db
*.sqlite
*.sqlite3
EOF
```
### 2. Git 사용자 설정 확인
```bash
# Git 사용자 정보 확인
git config --list | grep -E "user"
# 설정되지 않은 경우 설정
git config --global user.name "시골약사"
git config --global user.email "thug0bin@gmail.com"
```
### 3. 첫 번째 커밋
```bash
# 모든 파일 스테이징
git add .
# 첫 커밋 (상세한 커밋 메시지 예시)
git commit -m "$(cat <<'EOF'
Initial commit: [프로젝트명]
✨ [주요 기능 설명]
- 기능 1
- 기능 2
- 기능 3
🛠️ 기술 스택:
- 사용된 기술들 나열
🔧 주요 구성:
- 프로젝트 구조 설명
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
EOF
)"
```
### 4. 원격 리포지토리 연결 및 푸시
```bash
# 원격 리포지토리 추가 (리포지토리명을 실제 이름으로 변경)
git remote add origin https://thug0bin:d83f70b219c6028199a498fb94009f4c1debc9a9@git.0bin.in/thug0bin/[REPOSITORY_NAME].git
# 브랜치를 main으로 변경
git branch -M main
# 원격 리포지토리로 푸시
git push -u origin main
```
## 📝 리포지토리명 네이밍 규칙
### 권장 네이밍 패턴:
- **프론트엔드 프로젝트**: `project-name-frontend`
- **백엔드 프로젝트**: `project-name-backend`
- **풀스택 프로젝트**: `project-name-fullstack`
- **도구/유틸리티**: `tool-name-utils`
- **문서/가이드**: `project-name-docs`
### 예시:
- `figma-admin-dashboard`
- `anipharm-api-server`
- `inventory-management-system`
- `member-portal-frontend`
## 🔄 기존 리포지토리에 추가 커밋
```bash
# 변경사항 확인
git status
# 변경된 파일 스테이징
git add .
# 또는 특정 파일만 스테이징
git add path/to/specific/file
# 커밋
git commit -m "커밋 메시지"
# 푸시
git push origin main
```
## 🌿 브랜치 작업
```bash
# 새 브랜치 생성 및 전환
git checkout -b feature/new-feature
# 브랜치에서 작업 후 커밋
git add .
git commit -m "Feature: 새로운 기능 추가"
# 브랜치 푸시
git push -u origin feature/new-feature
# main 브랜치로 돌아가기
git checkout main
# 브랜치 병합 (필요시)
git merge feature/new-feature
```
## 🛠️ 자주 사용하는 Git 명령어
```bash
# 현재 상태 확인
git status
# 변경 내역 확인
git diff
# 커밋 히스토리 확인
git log --oneline
# 원격 리포지토리 정보 확인
git remote -v
# 특정 포트 프로세스 종료 (개발 서버 관련)
lsof -ti:PORT_NUMBER | xargs -r kill -9
```
## 🔧 포트 관리 스크립트
```bash
# 특정 포트 종료 함수 추가 (bashrc에 추가 가능)
killport() {
if [ -z "$1" ]; then
echo "Usage: killport <port_number>"
return 1
fi
lsof -ti:$1 | xargs -r kill -9
echo "Killed processes on port $1"
}
# 사용 예시
# killport 7738
# killport 5000
```
## 📋 VS Code 워크스페이스 설정
여러 리포지토리를 동시에 관리하려면 워크스페이스 파일을 생성하세요:
```json
{
"folders": [
{
"name": "Main Repository",
"path": "."
},
{
"name": "New Project",
"path": "./new-project-folder"
}
],
"settings": {
"git.enableSmartCommit": true,
"git.confirmSync": false,
"git.autofetch": true
}
}
```
## 🚨 문제 해결
### 1. 인증 실패
```bash
# 토큰이 만료된 경우, 새 토큰으로 원격 URL 업데이트
git remote set-url origin https://thug0bin:NEW_TOKEN@git.0bin.in/thug0bin/repo-name.git
```
### 2. 푸시 거부
```bash
# 원격 변경사항을 먼저 가져오기
git pull origin main --rebase
# 충돌 해결 후 푸시
git push origin main
```
### 3. 대용량 파일 문제
```bash
# Git LFS 설정 (필요시)
git lfs install
git lfs track "*.zip"
git lfs track "*.gz"
git add .gitattributes
```
## 📊 커밋 메시지 템플릿
### 기본 템플릿:
```
타입: 간단한 설명
상세한 설명 (선택사항)
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
```
### 타입별 예시:
- `✨ feat: 새로운 기능 추가`
- `🐛 fix: 버그 수정`
- `📝 docs: 문서 업데이트`
- `🎨 style: 코드 포맷팅`
- `♻️ refactor: 코드 리팩토링`
- `⚡ perf: 성능 개선`
- `✅ test: 테스트 추가`
- `🔧 chore: 빌드 설정 변경`
## 🔗 유용한 링크
- **Gitea 웹 인터페이스**: https://git.0bin.in/
- **내 리포지토리 목록**: https://git.0bin.in/thug0bin
- **새 리포지토리 생성**: https://git.0bin.in/repo/create
## 💡 팁과 모범 사례
1. **정기적인 커밋**: 작은 단위로 자주 커밋하세요
2. **의미있는 커밋 메시지**: 변경 사항을 명확히 설명하세요
3. **브랜치 활용**: 기능별로 브랜치를 나누어 작업하세요
4. **.gitignore 활용**: 불필요한 파일은 제외하세요
5. **문서화**: README.md와 같은 문서를 항상 업데이트하세요
---
**작성일**: 2025년 7월 29일
**마지막 업데이트**: 토큰 및 서버 정보 최신화
**참고**: 이 가이드는 재사용 가능하도록 작성되었습니다. 새 프로젝트마다 참고하세요.
> 💡 **중요**: 액세스 토큰은 보안이 중요한 정보입니다. 공개 저장소에 업로드하지 마세요!

106
install_web_control.sh Executable file
View File

@@ -0,0 +1,106 @@
#!/bin/bash
# RDP 자동 로그인 웹 제어 패널 설치 스크립트
set -e
echo "========================================="
echo "RDP 자동 로그인 웹 제어 패널 설치"
echo "========================================="
# 색상 정의
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# root 권한 확인
if [ "$EUID" -ne 0 ]; then
echo -e "${RED}이 스크립트는 root 권한으로 실행해야 합니다${NC}"
exit 1
fi
# 작업 디렉토리 설정
WORK_DIR="/root/proxmox-rdp-autosetup"
VENV_DIR="${WORK_DIR}/venv"
# Python3 및 pip 설치 확인
echo -e "${YELLOW}Python3 및 필요한 패키지 설치 중...${NC}"
apt-get update
apt-get install -y python3 python3-pip python3-venv
# 가상 환경 생성
echo -e "${YELLOW}Python 가상 환경 생성 중...${NC}"
cd ${WORK_DIR}
python3 -m venv ${VENV_DIR}
# 가상 환경 활성화 및 패키지 설치
echo -e "${YELLOW}Flask 및 관련 패키지 설치 중...${NC}"
source ${VENV_DIR}/bin/activate
pip install --upgrade pip
pip install -r ${WORK_DIR}/requirements.txt
# systemd 서비스 파일 복사
echo -e "${YELLOW}systemd 서비스 설정 중...${NC}"
cp /root/proxmox-rdp-autosetup/rdp-control-web.service /etc/systemd/system/
# systemd 데몬 리로드
systemctl daemon-reload
# 서비스 활성화 및 시작
echo -e "${YELLOW}웹 서비스 시작 중...${NC}"
systemctl enable rdp-control-web.service
systemctl start rdp-control-web.service
# 서비스 상태 확인
sleep 2
if systemctl is-active --quiet rdp-control-web.service; then
echo -e "${GREEN}✅ 웹 제어 패널이 성공적으로 설치되었습니다!${NC}"
echo ""
echo "========================================="
echo "접속 정보:"
echo "========================================="
# IP 주소 가져오기
IP=$(ip -4 addr show scope global | grep inet | head -1 | awk '{print $2}' | cut -d'/' -f1)
# Tailscale IP 확인
TAILSCALE_IP=""
if command -v tailscale &> /dev/null; then
TAILSCALE_IP=$(tailscale ip -4 2>/dev/null || echo "")
fi
echo "로컬 접속: http://${IP}:5000"
if [ -n "$TAILSCALE_IP" ]; then
echo "Tailscale 접속: http://${TAILSCALE_IP}:5000"
fi
echo ""
echo "========================================="
echo "서비스 관리 명령어:"
echo "========================================="
echo "상태 확인: systemctl status rdp-control-web"
echo "재시작: systemctl restart rdp-control-web"
echo "중지: systemctl stop rdp-control-web"
echo "로그 확인: journalctl -u rdp-control-web -f"
echo ""
else
echo -e "${RED}❌ 서비스 시작 실패${NC}"
echo "로그를 확인하려면 다음 명령어를 실행하세요:"
echo "journalctl -u rdp-control-web -n 50"
exit 1
fi
# 방화벽 설정 (ufw가 설치되어 있는 경우)
if command -v ufw &> /dev/null; then
echo -e "${YELLOW}방화벽 규칙 추가 중...${NC}"
ufw allow 5000/tcp
echo -e "${GREEN}✅ 포트 5000이 방화벽에 허용되었습니다${NC}"
fi
echo ""
echo -e "${GREEN}=========================================${NC}"
echo -e "${GREEN}설치 완료!${NC}"
echo -e "${GREEN}웹 브라우저에서 위 주소로 접속하세요${NC}"
echo -e "${GREEN}=========================================${NC}"

262
pbs_auto_registration.md Normal file
View File

@@ -0,0 +1,262 @@
# Proxmox Backup Server (PBS) 자동 등록 스크립트 기획서
## 📋 프로젝트 개요
### 목적
Proxmox VE 호스트에 PBS(Proxmox Backup Server)를 자동으로 등록하고 백업 작업을 구성하는 스크립트
### 주요 기능
- PBS 서버 자동 감지 및 연결
- 스토리지 구성 자동화
- 백업 작업 스케줄 설정
- 기존 백업 설정 마이그레이션
## 🎯 요구사항
### 필수 요구사항
1. **PBS 서버 정보**
- PBS 서버 IP/호스트명
- PBS 사용자 인증 정보 (username@realm)
- PBS API 토큰 또는 비밀번호
- Datastore 이름
2. **Proxmox VE 요구사항**
- Proxmox VE 6.x 이상
- root 권한
- pvesm 명령어 사용 가능
3. **네트워크 요구사항**
- PBS 서버와 통신 가능 (포트 8007)
- 지문(fingerprint) 자동 획득 가능
## 🔧 기능 상세
### 1. PBS 서버 감지 및 검증
```bash
# PBS 서버 연결 테스트
# API 접근 가능 여부 확인
# 지문(fingerprint) 자동 획득
```
### 2. 스토리지 등록
```bash
# PBS 스토리지를 Proxmox VE에 추가
pvesm add pbs <storage-id> \
--server <pbs-server> \
--datastore <datastore-name> \
--username <username@realm> \
--password <password> \
--fingerprint <fingerprint>
```
### 3. 백업 작업 구성
- 일일 백업 스케줄 설정
- VM/CT 선택적 백업
- 보존 정책 설정
### 4. 암호화 설정 (선택사항)
- 백업 암호화 키 생성
- 키 안전한 저장
## 📝 스크립트 구조
```
pbs_auto_registration.sh
├── 1. 환경 체크
│ ├── Proxmox 버전 확인
│ ├── 필수 도구 확인
│ └── root 권한 확인
├── 2. PBS 정보 수집
│ ├── 대화형 모드
│ ├── 설정 파일 모드
│ └── 환경 변수 모드
├── 3. PBS 연결 검증
│ ├── 네트워크 연결 테스트
│ ├── API 인증 테스트
│ └── Datastore 접근 확인
├── 4. 스토리지 구성
│ ├── 기존 스토리지 확인
│ ├── 새 스토리지 추가
│ └── 권한 설정
├── 5. 백업 작업 설정
│ ├── 백업 대상 선택
│ ├── 스케줄 설정
│ └── 알림 설정
└── 6. 검증 및 완료
├── 설정 테스트
├── 첫 백업 실행 (선택)
└── 로그 출력
```
## 🔐 보안 고려사항
### 인증 방식
1. **API 토큰 (권장)**
- 토큰 ID와 시크릿 사용
- 제한된 권한 부여 가능
2. **패스워드 인증**
- 임시 사용 후 토큰으로 전환 권장
- 설정 파일에 평문 저장 금지
### 암호화
- 전송 중 암호화: HTTPS (포트 8007)
- 저장 시 암호화: 선택적 백업 암호화
## 📦 설정 파일 예시
### `/etc/pve/pbs_config.conf`
```ini
# PBS Server Configuration
PBS_SERVER=192.168.1.100
PBS_PORT=8007
PBS_DATASTORE=backup-store
PBS_USERNAME=backup@pbs
# API Token (recommended)
PBS_TOKEN_ID=backup@pbs!automation
PBS_TOKEN_SECRET=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
# Storage Configuration
STORAGE_ID=pbs-backup
STORAGE_CONTENT=backup
# Backup Schedule
BACKUP_SCHEDULE="0 2 * * *" # 매일 새벽 2시
BACKUP_MODE=snapshot
BACKUP_COMPRESS=zstd
# Retention Policy
KEEP_DAILY=7
KEEP_WEEKLY=4
KEEP_MONTHLY=6
KEEP_YEARLY=1
# Notification
NOTIFY_EMAIL=admin@example.com
NOTIFY_MODE=failure # always|failure
```
## 🚀 사용 방법
### 기본 실행 (대화형)
```bash
bash pbs_auto_registration.sh
```
### 설정 파일 사용
```bash
bash pbs_auto_registration.sh --config /etc/pve/pbs_config.conf
```
### 자동 모드 (프롬프트 없음)
```bash
bash pbs_auto_registration.sh --auto \
--server 192.168.1.100 \
--datastore backup-store \
--username backup@pbs \
--token-secret "xxxx"
```
## 🔄 기존 백업 마이그레이션
### 로컬 백업에서 PBS로 전환
1. 기존 백업 목록 확인
2. PBS로 백업 복사 (선택사항)
3. 백업 작업 재구성
4. 기존 로컬 백업 정리
## 📊 모니터링 및 검증
### 백업 상태 확인
```bash
# PBS 스토리지 상태
pvesm status
# 백업 작업 목록
pvesh get /cluster/backup
# 최근 백업 로그
cat /var/log/pve/tasks/active
```
### 헬스 체크
- PBS 연결 상태
- 스토리지 용량
- 백업 성공률
- 보존 정책 준수
## 🛠️ 문제 해결
### 일반적인 문제
1. **연결 실패**
- 방화벽 규칙 확인
- PBS 서비스 상태 확인
- 인증서/지문 문제
2. **권한 오류**
- PBS 사용자 권한 확인
- Datastore 접근 권한
- API 토큰 권한
3. **백업 실패**
- 스토리지 용량 확인
- 네트워크 안정성
- VM/CT 상태 확인
## 📈 향후 개선 사항
1. **다중 PBS 서버 지원**
- 복제/미러링 설정
- 로드 밸런싱
2. **고급 백업 정책**
- VM별 다른 스케줄
- 조건부 백업
- 증분 백업 최적화
3. **자동 복구**
- 백업 검증 자동화
- 복구 테스트 자동화
- 재해 복구 계획
4. **통합 관리**
- 웹 UI 대시보드
- 중앙 집중식 관리
- 멀티 클러스터 지원
## 📚 참고 자료
- [Proxmox Backup Server Documentation](https://pbs.proxmox.com/docs/)
- [Proxmox VE Storage Documentation](https://pve.proxmox.com/wiki/Storage)
- [PBS API Reference](https://pbs.proxmox.com/docs/api-viewer/)
## 🔍 테스트 시나리오
### 단위 테스트
1. PBS 서버 연결 테스트
2. 인증 테스트
3. 스토리지 추가/제거 테스트
### 통합 테스트
1. 전체 설정 프로세스
2. 백업 실행 테스트
3. 복구 테스트
### 스트레스 테스트
1. 대용량 VM 백업
2. 동시 다중 백업
3. 네트워크 장애 시나리오
## 📄 라이선스
MIT License
## 👥 기여자
- 프로젝트 관리자
- 개발팀
- 테스트팀

507
proxmox-auto-rdp-perfect.sh Normal file
View File

@@ -0,0 +1,507 @@
#!/bin/bash
# Proxmox Auto RDP Setup Script - Fixed Version
# 자동으로 Proxmox 호스트를 RDP VM에 연결하는 설정을 수행합니다
# 원본 스크립트의 깜빡임 문제를 해결한 개선된 버전
set -euo pipefail
# 색상 코드 정의
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
PURPLE='\033[0;35m'
CYAN='\033[0;36m'
NC='\033[0m' # No Color
# 로그 함수들
msg_info() {
echo -e "${BLUE}[INFO]${NC} $1"
}
msg_ok() {
echo -e "${GREEN}[OK]${NC} $1"
}
msg_error() {
echo -e "${RED}[ERROR]${NC} $1"
exit 1
}
msg_warn() {
echo -e "${YELLOW}[WARN]${NC} $1"
}
# 헤더 출력
print_header() {
clear
echo -e "${PURPLE}"
echo "═══════════════════════════════════════════════════════════════════"
echo " Proxmox Auto RDP Setup Script v2.0 (Fixed)"
echo "═══════════════════════════════════════════════════════════════════"
echo -e "${NC}"
echo "이 스크립트는 Proxmox VE 호스트가 부팅 시 자동으로 RDP 연결하도록 설정합니다."
echo "원본 스크립트의 깜빡임 문제를 해결한 개선된 버전입니다."
echo ""
}
# Proxmox 버전 확인
check_proxmox_version() {
msg_info "Proxmox VE 버전 확인 중..."
if [ ! -f /etc/pve/.version ] && ! command -v pveversion > /dev/null 2>&1; then
msg_error "Proxmox VE가 설치되어 있지 않습니다."
fi
local version_info
if command -v pveversion > /dev/null 2>&1; then
version_info=$(pveversion 2>/dev/null | head -n1 | awk '{print $1}' | cut -d'/' -f2 2>/dev/null || echo "unknown")
else
version_info="unknown"
fi
if [[ "$version_info" =~ ^[0-9]+\.[0-9]+ ]]; then
local pve_version=$(echo "$version_info" | cut -d'.' -f1)
if [ "$pve_version" -lt 8 ]; then
msg_error "지원되지 않는 Proxmox VE 버전입니다. 8.x 이상이 필요합니다."
fi
msg_ok "Proxmox VE $pve_version.x 버전 확인됨"
else
msg_warn "Proxmox VE 버전을 확인할 수 없습니다. 계속 진행합니다..."
fi
}
# 루트 권한 확인
check_root() {
if [ "$EUID" -ne 0 ]; then
msg_error "이 스크립트는 root 권한으로 실행해야 합니다. sudo를 사용하세요."
fi
}
# 입력 검증 함수
validate_rdp_server() {
local server="$1"
if [[ ! "$server" =~ ^[a-zA-Z0-9.-]+(:([0-9]{1,5}))?$ ]]; then
return 1
fi
if [[ "$server" =~ :([0-9]+)$ ]]; then
local port="${BASH_REMATCH[1]}"
if [ "$port" -gt 65535 ]; then
return 1
fi
fi
return 0
}
validate_username() {
local username="$1"
if [[ ! "$username" =~ ^[a-zA-Z0-9._-]+$ ]]; then
return 1
fi
return 0
}
# 사용자 입력 받기 (환경변수 또는 대화형)
get_user_input() {
echo -e "${CYAN}RDP 연결 정보를 입력해주세요:${NC}"
echo ""
# 환경변수에서 먼저 확인
if [ -n "${RDP_SERVER:-}" ] && [ -n "${RDP_USER:-}" ] && [ -n "${RDP_PASSWORD:-}" ]; then
RDP_USERNAME="$RDP_USER"
LOCAL_USER="${LOCAL_USER:-rdpuser}"
msg_info "환경변수에서 설정을 읽었습니다."
echo " RDP 서버: $RDP_SERVER"
echo " RDP 사용자: $RDP_USERNAME"
echo " 로컬 사용자: $LOCAL_USER"
return 0
fi
# RDP 서버 주소
while true; do
read -p "RDP 서버 주소 (예: example.com:3389): " RDP_SERVER
if [ -z "$RDP_SERVER" ]; then
msg_warn "RDP 서버 주소는 필수입니다."
elif ! validate_rdp_server "$RDP_SERVER"; then
msg_warn "잘못된 서버 주소 형식입니다."
else
break
fi
done
# RDP 사용자명
while true; do
read -p "RDP 사용자명: " RDP_USERNAME
if [ -z "$RDP_USERNAME" ]; then
msg_warn "RDP 사용자명은 필수입니다."
elif ! validate_username "$RDP_USERNAME"; then
msg_warn "잘못된 사용자명 형식입니다."
else
break
fi
done
# 패스워드 (표준 입력으로 받기)
while true; do
echo -n "RDP 패스워드: "
read -s RDP_PASSWORD
echo ""
if [ -z "$RDP_PASSWORD" ]; then
msg_warn "RDP 패스워드는 필수입니다."
continue
fi
echo -n "패스워드 확인: "
read -s password_confirm
echo ""
if [ "$RDP_PASSWORD" != "$password_confirm" ]; then
msg_warn "패스워드가 일치하지 않습니다."
continue
else
break
fi
done
# 로컬 사용자명
read -p "로컬 사용자명 [rdpuser]: " LOCAL_USER
LOCAL_USER=${LOCAL_USER:-rdpuser}
echo ""
echo -e "${YELLOW}입력된 정보:${NC}"
echo " RDP 서버: $RDP_SERVER"
echo " RDP 사용자: $RDP_USERNAME"
echo " 로컬 사용자: $LOCAL_USER"
echo ""
read -p "설정을 계속하시겠습니까? [y/N]: " confirm
case $confirm in
[yY]|[yY][eE][sS])
return 0
;;
*)
msg_error "설정이 취소되었습니다."
;;
esac
}
# 백업 생성
create_backup() {
msg_info "기존 설정 백업 중..."
local backup_dir="/root/proxmox-rdp-backup-$(date +%Y%m%d-%H%M%S)"
mkdir -p "$backup_dir"
if [ -f /etc/systemd/system/getty@tty1.service.d/override.conf ]; then
cp -r /etc/systemd/system/getty@tty1.service.d "$backup_dir/" 2>/dev/null || true
fi
if id "$LOCAL_USER" &>/dev/null; then
cp -r "/home/$LOCAL_USER" "$backup_dir/home-$LOCAL_USER" 2>/dev/null || true
fi
msg_ok "백업 완료: $backup_dir"
}
# 네트워크 연결 확인
check_network() {
msg_info "네트워크 연결 확인 중..."
if ! ping -c 1 -W 5 8.8.8.8 > /dev/null 2>&1; then
msg_warn "인터넷 연결을 확인할 수 없습니다."
fi
# RDP 서버 연결 가능 여부 확인
local rdp_host=$(echo "$RDP_SERVER" | cut -d: -f1)
local rdp_port=$(echo "$RDP_SERVER" | grep -oE ':[0-9]+' | tr -d ':' || echo "3389")
msg_info "RDP 서버 연결 테스트 ($rdp_host:$rdp_port)..."
if timeout 5 bash -c "echo > /dev/tcp/$rdp_host/$rdp_port" 2>/dev/null; then
msg_ok "RDP 서버에 연결 가능합니다."
else
msg_warn "RDP 서버에 연결할 수 없습니다. 설정 후 연결을 확인하세요."
fi
}
# 필수 패키지 설치
install_packages() {
msg_info "필수 패키지 설치 중..."
# 패키지 목록
local packages=(
"freerdp3-x11"
"openbox"
"xinit"
"xterm"
"xorg"
"dbus-x11"
)
# APT 업데이트
apt-get update > /dev/null 2>&1
# 패키지 설치
for pkg in "${packages[@]}"; do
if ! dpkg -l "$pkg" 2>/dev/null | grep -q "^ii"; then
msg_info "설치 중: $pkg"
DEBIAN_FRONTEND=noninteractive apt-get install -y "$pkg" > /dev/null 2>&1
fi
done
msg_ok "모든 필수 패키지가 설치되었습니다."
}
# 사용자 생성
create_user() {
msg_info "사용자 설정 중..."
if ! id "$LOCAL_USER" &>/dev/null; then
msg_info "새 사용자 생성: $LOCAL_USER"
useradd -m -s /bin/bash "$LOCAL_USER"
echo "$LOCAL_USER:$RDP_PASSWORD" | chpasswd
usermod -aG audio,video "$LOCAL_USER"
msg_ok "사용자 생성 완료: $LOCAL_USER"
else
msg_info "기존 사용자 사용: $LOCAL_USER"
usermod -aG audio,video "$LOCAL_USER" 2>/dev/null || true
fi
}
# 자동 로그인 설정 (개선된 버전)
configure_autologin() {
msg_info "자동 로그인 설정 중..."
# getty@tty1 서비스 중지
systemctl stop getty@tty1.service 2>/dev/null || true
# getty@tty1 서비스 override 디렉토리 생성
mkdir -p /etc/systemd/system/getty@tty1.service.d/
# 자동 로그인 설정 (Type=idle 추가로 재시작 방지)
cat > /etc/systemd/system/getty@tty1.service.d/override.conf << EOF
[Service]
ExecStart=
ExecStart=-/sbin/agetty --autologin $LOCAL_USER --noclear %I \$TERM
Type=idle
RestartSec=0
Restart=no
EOF
# systemd 재로드
systemctl daemon-reload
msg_ok "자동 로그인 설정 완료"
}
# X 세션 설정
configure_x_session() {
msg_info "X 세션 설정 중..."
# .bash_profile 설정 (tty1에서만 X 시작)
cat > "/home/$LOCAL_USER/.bash_profile" << 'EOF'
# Auto-start X on tty1
if [[ -z $DISPLAY ]] && [[ $(tty) = /dev/tty1 ]]; then
exec startx 2>/dev/null
fi
EOF
# .xinitrc 설정 (RDP 연결)
cat > "/home/$LOCAL_USER/.xinitrc" << EOF
#!/bin/sh
# D-Bus 세션 버스 시작
if [ -z "\$DBUS_SESSION_BUS_ADDRESS" ]; then
eval \$(dbus-launch --sh-syntax --exit-with-session)
fi
# Openbox 시작
openbox-session &
# 화면 해상도 설정
xrandr --output Virtual-1 --mode 1920x1080 2>/dev/null || true
# RDP 연결 (재시도 로직 포함)
while true; do
echo "Connecting to RDP server: $RDP_SERVER" >> /home/$LOCAL_USER/rdp.log
xfreerdp3 /v:$RDP_SERVER /u:$RDP_USERNAME /p:'$RDP_PASSWORD' \\
/f /cert:ignore /network:auto /dynamic-resolution \\
/audio-mode:2 +clipboard +home-drive \\
/log-level:ERROR 2>> /home/$LOCAL_USER/rdp-error.log
# 연결 실패 시 5초 대기 후 재시도
echo "RDP connection closed. Retrying in 5 seconds..." >> /home/$LOCAL_USER/rdp.log
sleep 5
done
EOF
chmod +x "/home/$LOCAL_USER/.xinitrc"
msg_ok "X 세션 설정 완료"
}
# Openbox 설정
configure_openbox() {
msg_info "Openbox 설정 중..."
mkdir -p "/home/$LOCAL_USER/.config/openbox"
# Openbox 설정 (풀스크린, 장식 제거)
cat > "/home/$LOCAL_USER/.config/openbox/rc.xml" << 'EOF'
<?xml version="1.0" encoding="UTF-8"?>
<openbox_config xmlns="http://openbox.org/3.4/rc">
<applications>
<application class="*">
<decor>no</decor>
<maximized>yes</maximized>
<fullscreen>yes</fullscreen>
</application>
</applications>
<keyboard>
<keybind key="C-A-Delete">
<action name="Exit"/>
</keybind>
</keyboard>
<mouse>
<doubleClickTime>400</doubleClickTime>
<screenEdgeWarpTime>0</screenEdgeWarpTime>
</mouse>
</openbox_config>
EOF
# autostart 파일 생성
cat > "/home/$LOCAL_USER/.config/openbox/autostart" << 'EOF'
# 화면 보호기 비활성화
xset s off
xset -dpms
xset s noblank
EOF
chmod +x "/home/$LOCAL_USER/.config/openbox/autostart"
msg_ok "Openbox 설정 완료"
}
# 권한 설정
set_permissions() {
msg_info "권한 설정 중..."
chown -R "$LOCAL_USER:$LOCAL_USER" "/home/$LOCAL_USER"
chmod 755 "/home/$LOCAL_USER"
msg_ok "권한 설정 완료"
}
# 서비스 활성화
enable_services() {
msg_info "서비스 활성화 중..."
# getty@tty1 서비스 활성화 (마스킹 해제)
systemctl unmask getty@tty1.service 2>/dev/null || true
systemctl enable getty@tty1.service
# 기본 타겟 확인
if [ "$(systemctl get-default)" != "graphical.target" ]; then
systemctl set-default graphical.target
fi
msg_ok "서비스 활성화 완료"
}
# 설정 검증
verify_configuration() {
msg_info "설정 검증 중..."
local errors=0
# 설정 파일 존재 확인
local required_files=(
"/etc/systemd/system/getty@tty1.service.d/override.conf"
"/home/$LOCAL_USER/.bash_profile"
"/home/$LOCAL_USER/.xinitrc"
"/home/$LOCAL_USER/.config/openbox/rc.xml"
)
for file in "${required_files[@]}"; do
if [ ! -f "$file" ]; then
msg_warn "설정 파일이 없습니다: $file"
((errors++))
fi
done
# 서비스 상태 확인
if ! systemctl is-enabled getty@tty1.service > /dev/null 2>&1; then
msg_warn "getty@tty1 서비스가 활성화되지 않았습니다."
((errors++))
fi
if [ $errors -eq 0 ]; then
msg_ok "모든 설정이 정상적으로 완료되었습니다."
return 0
else
msg_warn "일부 설정에 문제가 있을 수 있습니다."
return 1
fi
}
# 완료 메시지
print_completion() {
echo ""
echo -e "${GREEN}═══════════════════════════════════════════════════════════════════${NC}"
echo -e "${GREEN} 설정이 완료되었습니다!${NC}"
echo -e "${GREEN}═══════════════════════════════════════════════════════════════════${NC}"
echo ""
echo "설정 정보:"
echo " - RDP 서버: $RDP_SERVER"
echo " - RDP 사용자: $RDP_USERNAME"
echo " - 로컬 사용자: $LOCAL_USER"
echo ""
echo "다음 명령으로 즉시 시작할 수 있습니다:"
echo -e " ${CYAN}systemctl restart getty@tty1.service${NC}"
echo ""
echo "또는 시스템을 재부팅하면 자동으로 RDP에 연결됩니다:"
echo -e " ${CYAN}reboot${NC}"
echo ""
echo "문제가 발생하면 다음 로그를 확인하세요:"
echo " - /home/$LOCAL_USER/rdp.log"
echo " - /home/$LOCAL_USER/rdp-error.log"
echo " - journalctl -u getty@tty1.service -f"
echo ""
echo "다른 터미널로 접속하려면 Ctrl+Alt+F2를 사용하세요."
echo ""
}
# 메인 함수
main() {
print_header
check_root
check_proxmox_version
get_user_input
check_network
create_backup
install_packages
create_user
configure_autologin
configure_x_session
configure_openbox
set_permissions
enable_services
verify_configuration
print_completion
}
# 환경변수 지원 (비대화형 설치)
# 사용법: RDP_SERVER="server:port" RDP_USER="username" RDP_PASSWORD="password" ./script.sh
if [ -n "${RDP_SERVER:-}" ] && [ -n "${RDP_USER:-}" ] && [ -n "${RDP_PASSWORD:-}" ]; then
export NON_INTERACTIVE=1
fi
# 스크립트 실행
main "$@"

View File

@@ -429,8 +429,8 @@ xset -dpms
xset s off
xset s noblank
# 마우스 커서 숨기기
unclutter -idle 0.1 -root &
# 마우스 커서 숨기기 (비활성화 - RDP 연결 시 커서 문제 방지)
# unclutter -idle 0.1 -root &
# Openbox 윈도우 매니저 시작
openbox-session &

15
rdp-control-web.service Normal file
View File

@@ -0,0 +1,15 @@
[Unit]
Description=RDP Auto Login Control Web Service
After=network.target
[Service]
Type=simple
User=root
WorkingDirectory=/root/proxmox-rdp-autosetup
Environment="PATH=/root/proxmox-rdp-autosetup/venv/bin:/usr/bin:/usr/local/bin"
ExecStart=/root/proxmox-rdp-autosetup/venv/bin/gunicorn --bind 0.0.0.0:5000 --workers 2 --timeout 120 rdp_control_web:app
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target

259
rdp-control.sh Executable file
View File

@@ -0,0 +1,259 @@
#!/bin/bash
# RDP Auto-Connect Control Script
# RDP 자동 연결을 켜고 끄는 제어 스크립트
set -euo pipefail
# 색상 코드
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
NC='\033[0m'
# RDP 설정 변수
RDP_SERVER="ysleadersos.com:6642"
RDP_USER="doctor-03"
RDP_PASSWORD="@flejtm301"
LOCAL_USER="rdpuser"
# 로그 함수
msg_info() {
echo -e "${BLUE}[INFO]${NC} $1"
}
msg_ok() {
echo -e "${GREEN}[OK]${NC} $1"
}
msg_error() {
echo -e "${RED}[ERROR]${NC} $1"
exit 1
}
msg_warn() {
echo -e "${YELLOW}[WARN]${NC} $1"
}
# 도움말 출력
show_help() {
echo -e "${CYAN}RDP Auto-Connect Control Script${NC}"
echo ""
echo "사용법:"
echo " $0 start - RDP 자동 연결 시작"
echo " $0 stop - RDP 자동 연결 중지"
echo " $0 status - RDP 연결 상태 확인"
echo " $0 restart - RDP 자동 연결 재시작"
echo ""
echo "설정 정보:"
echo " RDP 서버: $RDP_SERVER"
echo " RDP 사용자: $RDP_USER"
echo " 로컬 사용자: $LOCAL_USER"
echo ""
}
# 상태 확인
check_status() {
local rdp_running=false
local x_running=false
local getty_enabled=false
# RDP 프로세스 확인
if pgrep -f "xfreerdp3" >/dev/null 2>&1; then
rdp_running=true
fi
# X 서버 확인
if pgrep -f "/usr/lib/xorg/Xorg" >/dev/null 2>&1 || pgrep -f "Xorg.*vt1" >/dev/null 2>&1; then
x_running=true
fi
# getty 서비스 확인
if systemctl is-enabled getty@tty1.service >/dev/null 2>&1; then
getty_enabled=true
fi
echo -e "${CYAN}=== RDP 자동 연결 상태 ===${NC}"
echo ""
if $getty_enabled; then
echo -e "자동 로그인: ${GREEN}활성화${NC}"
else
echo -e "자동 로그인: ${RED}비활성화${NC}"
fi
if $x_running; then
echo -e "X 서버: ${GREEN}실행 중${NC}"
else
echo -e "X 서버: ${RED}중지됨${NC}"
fi
if $rdp_running; then
echo -e "RDP 연결: ${GREEN}연결됨${NC}"
echo -e "연결 정보: ${YELLOW}$RDP_USER@$RDP_SERVER${NC}"
else
echo -e "RDP 연결: ${RED}연결 안됨${NC}"
fi
echo ""
# 로그 파일 정보
if [ -f "/home/$LOCAL_USER/rdp.log" ]; then
local log_lines=$(wc -l < "/home/$LOCAL_USER/rdp.log" 2>/dev/null || echo "0")
echo "RDP 로그: $log_lines 줄 (/home/$LOCAL_USER/rdp.log)"
fi
if [ -f "/home/$LOCAL_USER/rdp-error.log" ]; then
local error_lines=$(wc -l < "/home/$LOCAL_USER/rdp-error.log" 2>/dev/null || echo "0")
echo "에러 로그: $error_lines 줄 (/home/$LOCAL_USER/rdp-error.log)"
fi
echo ""
# 전체 상태 요약
if $getty_enabled && $rdp_running; then
echo -e "전체 상태: ${GREEN}정상 작동 중${NC}"
elif $getty_enabled && ! $rdp_running; then
echo -e "전체 상태: ${YELLOW}시작 중 또는 연결 실패${NC}"
else
echo -e "전체 상태: ${RED}비활성화됨${NC}"
fi
}
# RDP 자동 연결 시작
start_rdp() {
msg_info "RDP 자동 연결을 시작합니다..."
# 이미 실행 중인지 확인
if systemctl is-active getty@tty1.service >/dev/null 2>&1; then
msg_warn "RDP 자동 연결이 이미 활성화되어 있습니다."
return 0
fi
# getty 서비스 활성화
systemctl unmask getty@tty1.service >/dev/null 2>&1 || true
systemctl enable getty@tty1.service >/dev/null 2>&1
systemctl start getty@tty1.service
msg_ok "RDP 자동 연결이 시작되었습니다."
# 연결 상태 확인 (최대 10초 대기)
msg_info "RDP 연결을 확인하는 중..."
for i in {1..10}; do
sleep 1
if pgrep -f "xfreerdp3.*$RDP_SERVER" >/dev/null 2>&1; then
msg_ok "RDP 연결이 성공적으로 설정되었습니다."
return 0
fi
echo -n "."
done
echo ""
msg_warn "RDP 연결 확인에 시간이 걸리고 있습니다. 로그를 확인하세요:"
echo " tail -f /home/$LOCAL_USER/rdp.log"
echo " tail -f /home/$LOCAL_USER/rdp-error.log"
}
# RDP 자동 연결 중지
stop_rdp() {
msg_info "RDP 자동 연결을 중지합니다..."
# RDP 프로세스 종료
if pgrep -f "xfreerdp3" >/dev/null 2>&1; then
msg_info "RDP 연결을 종료하는 중..."
pkill -f "xfreerdp3" 2>/dev/null || true
sleep 2
fi
# X 서버 종료
if pgrep -f "Xorg.*tty1" >/dev/null 2>&1; then
msg_info "X 서버를 종료하는 중..."
pkill -f "Xorg.*tty1" 2>/dev/null || true
sleep 2
fi
# getty 서비스 중지 및 비활성화
systemctl stop getty@tty1.service 2>/dev/null || true
systemctl disable getty@tty1.service 2>/dev/null || true
msg_ok "RDP 자동 연결이 중지되었습니다."
# 프로세스 확인
if ! pgrep -f "xfreerdp3" >/dev/null 2>&1; then
msg_ok "모든 RDP 프로세스가 정상적으로 종료되었습니다."
else
msg_warn "일부 RDP 프로세스가 아직 실행 중일 수 있습니다."
fi
}
# RDP 자동 연결 재시작
restart_rdp() {
msg_info "RDP 자동 연결을 재시작합니다..."
stop_rdp
sleep 3
start_rdp
}
# 로그 보기
show_logs() {
echo -e "${CYAN}=== RDP 로그 (최근 20줄) ===${NC}"
if [ -f "/home/$LOCAL_USER/rdp.log" ]; then
tail -20 "/home/$LOCAL_USER/rdp.log" 2>/dev/null || echo "로그 파일을 읽을 수 없습니다."
else
echo "로그 파일이 없습니다."
fi
echo ""
echo -e "${CYAN}=== RDP 에러 로그 (최근 10줄) ===${NC}"
if [ -f "/home/$LOCAL_USER/rdp-error.log" ]; then
tail -10 "/home/$LOCAL_USER/rdp-error.log" 2>/dev/null || echo "에러 로그 파일을 읽을 수 없습니다."
else
echo "에러 로그 파일이 없습니다."
fi
}
# 메인 함수
main() {
# root 권한 확인
if [ "$EUID" -ne 0 ]; then
msg_error "이 스크립트는 root 권한으로 실행해야 합니다."
fi
case "${1:-}" in
"start")
start_rdp
echo ""
check_status
;;
"stop")
stop_rdp
echo ""
check_status
;;
"status")
check_status
;;
"restart")
restart_rdp
echo ""
check_status
;;
"logs")
show_logs
;;
"help"|"-h"|"--help")
show_help
;;
*)
echo -e "${RED}잘못된 명령입니다.${NC}"
echo ""
show_help
exit 1
;;
esac
}
# 스크립트 실행
main "$@"

228
rdp_control_web.py Normal file
View File

@@ -0,0 +1,228 @@
#!/usr/bin/env python3
import os
import subprocess
import json
from flask import Flask, render_template, jsonify, request
from flask_cors import CORS
import logging
from pathlib import Path
app = Flask(__name__)
CORS(app)
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
CONFIG_FILE = "/etc/xrdp/auto_login.conf"
SYSTEMD_SERVICE = "xrdp-autologin.service"
def get_auto_login_status():
"""자동 로그인 상태 확인"""
try:
# systemd 서비스 상태 확인
result = subprocess.run(
["systemctl", "is-active", SYSTEMD_SERVICE],
capture_output=True,
text=True
)
service_active = result.stdout.strip() == "active"
# 설정 파일 존재 여부 확인
config_exists = os.path.exists(CONFIG_FILE)
# systemd 서비스 enabled 상태 확인
result = subprocess.run(
["systemctl", "is-enabled", SYSTEMD_SERVICE],
capture_output=True,
text=True
)
service_enabled = result.stdout.strip() == "enabled"
return {
"enabled": service_enabled,
"active": service_active,
"config_exists": config_exists
}
except Exception as e:
logger.error(f"상태 확인 실패: {str(e)}")
return {
"enabled": False,
"active": False,
"config_exists": False,
"error": str(e)
}
def set_auto_login(enabled):
"""자동 로그인 활성화/비활성화"""
try:
if enabled:
# 서비스 활성화 및 시작
subprocess.run(["systemctl", "enable", SYSTEMD_SERVICE], check=True)
subprocess.run(["systemctl", "start", SYSTEMD_SERVICE], check=True)
# xrdp 서비스 재시작
subprocess.run(["systemctl", "restart", "xrdp"], check=True)
subprocess.run(["systemctl", "restart", "xrdp-sesman"], check=True)
logger.info("RDP 자동 로그인 활성화됨")
return True, "RDP 자동 로그인이 활성화되었습니다."
else:
# 서비스 중지 및 비활성화
subprocess.run(["systemctl", "stop", SYSTEMD_SERVICE], check=True)
subprocess.run(["systemctl", "disable", SYSTEMD_SERVICE], check=True)
# 자동 로그인 설정 제거
if os.path.exists(CONFIG_FILE):
backup_file = f"{CONFIG_FILE}.backup"
subprocess.run(["mv", CONFIG_FILE, backup_file], check=True)
# xrdp 서비스 재시작
subprocess.run(["systemctl", "restart", "xrdp"], check=True)
subprocess.run(["systemctl", "restart", "xrdp-sesman"], check=True)
logger.info("RDP 자동 로그인 비활성화됨")
return True, "RDP 자동 로그인이 비활성화되었습니다."
except subprocess.CalledProcessError as e:
logger.error(f"명령 실행 실패: {str(e)}")
return False, f"설정 변경 실패: {str(e)}"
except Exception as e:
logger.error(f"예외 발생: {str(e)}")
return False, f"오류 발생: {str(e)}"
def get_system_info():
"""시스템 정보 가져오기"""
try:
# 호스트명
hostname = subprocess.run(
["hostname"],
capture_output=True,
text=True
).stdout.strip()
# IP 주소
ip_result = subprocess.run(
["ip", "-4", "addr", "show", "scope", "global"],
capture_output=True,
text=True
)
ip_addresses = []
for line in ip_result.stdout.split('\n'):
if 'inet' in line:
ip = line.strip().split()[1].split('/')[0]
ip_addresses.append(ip)
# RDP 포트 확인
rdp_port = "3389"
# Tailscale 상태
tailscale_ip = None
try:
ts_result = subprocess.run(
["tailscale", "ip", "-4"],
capture_output=True,
text=True
)
if ts_result.returncode == 0:
tailscale_ip = ts_result.stdout.strip()
except:
pass
return {
"hostname": hostname,
"ip_addresses": ip_addresses,
"rdp_port": rdp_port,
"tailscale_ip": tailscale_ip
}
except Exception as e:
logger.error(f"시스템 정보 가져오기 실패: {str(e)}")
return {}
@app.route('/')
def index():
"""메인 페이지"""
return render_template('index.html')
@app.route('/api/status', methods=['GET'])
def get_status():
"""현재 상태 조회 API"""
status = get_auto_login_status()
system_info = get_system_info()
return jsonify({
"status": status,
"system": system_info
})
@app.route('/api/toggle', methods=['POST'])
def toggle_auto_login():
"""자동 로그인 토글 API"""
data = request.get_json()
enabled = data.get('enabled', False)
success, message = set_auto_login(enabled)
if success:
return jsonify({
"success": True,
"message": message,
"status": get_auto_login_status()
})
else:
return jsonify({
"success": False,
"message": message,
"status": get_auto_login_status()
}), 500
@app.route('/api/logs', methods=['GET'])
def get_logs():
"""최근 로그 조회 API"""
try:
# xrdp 로그
xrdp_logs = subprocess.run(
["journalctl", "-u", "xrdp", "-n", "20", "--no-pager"],
capture_output=True,
text=True
).stdout
# 자동 로그인 서비스 로그
autologin_logs = subprocess.run(
["journalctl", "-u", SYSTEMD_SERVICE, "-n", "20", "--no-pager"],
capture_output=True,
text=True
).stdout
return jsonify({
"xrdp_logs": xrdp_logs,
"autologin_logs": autologin_logs
})
except Exception as e:
return jsonify({"error": str(e)}), 500
@app.route('/api/restart', methods=['POST'])
def restart_services():
"""서비스 재시작 API"""
try:
subprocess.run(["systemctl", "restart", "xrdp"], check=True)
subprocess.run(["systemctl", "restart", "xrdp-sesman"], check=True)
status = get_auto_login_status()
if status['enabled']:
subprocess.run(["systemctl", "restart", SYSTEMD_SERVICE], check=True)
return jsonify({
"success": True,
"message": "서비스가 재시작되었습니다."
})
except Exception as e:
return jsonify({
"success": False,
"message": f"재시작 실패: {str(e)}"
}), 500
if __name__ == '__main__':
# templates 디렉토리 생성
Path("templates").mkdir(exist_ok=True)
# 개발 서버 실행 (프로덕션에서는 gunicorn 사용 권장)
app.run(host='0.0.0.0', port=5000, debug=False)

3
requirements.txt Normal file
View File

@@ -0,0 +1,3 @@
Flask==2.3.3
Flask-Cors==4.0.0
gunicorn==21.2.0

628
templates/index.html Normal file
View File

@@ -0,0 +1,628 @@
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>RDP 자동 로그인 제어 패널</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
padding: 20px;
}
.container {
background: white;
border-radius: 20px;
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
padding: 40px;
max-width: 600px;
width: 100%;
}
h1 {
color: #333;
text-align: center;
margin-bottom: 30px;
font-size: 28px;
}
.status-card {
background: #f8f9fa;
border-radius: 15px;
padding: 25px;
margin-bottom: 30px;
}
.status-item {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 15px;
padding-bottom: 15px;
border-bottom: 1px solid #e0e0e0;
}
.status-item:last-child {
margin-bottom: 0;
padding-bottom: 0;
border-bottom: none;
}
.status-label {
font-weight: 600;
color: #555;
}
.status-value {
font-weight: 400;
color: #333;
}
.status-indicator {
display: inline-block;
width: 10px;
height: 10px;
border-radius: 50%;
margin-right: 8px;
}
.status-active {
background-color: #4caf50;
}
.status-inactive {
background-color: #f44336;
}
.toggle-container {
display: flex;
justify-content: center;
align-items: center;
margin: 30px 0;
gap: 20px;
}
.toggle-label {
font-size: 18px;
font-weight: 600;
color: #333;
}
.toggle-switch {
position: relative;
width: 80px;
height: 40px;
cursor: pointer;
}
.toggle-switch input {
opacity: 0;
width: 0;
height: 0;
}
.slider {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #ccc;
transition: 0.4s;
border-radius: 40px;
}
.slider:before {
position: absolute;
content: "";
height: 32px;
width: 32px;
left: 4px;
bottom: 4px;
background-color: white;
transition: 0.4s;
border-radius: 50%;
}
input:checked + .slider {
background-color: #667eea;
}
input:checked + .slider:before {
transform: translateX(40px);
}
.button-group {
display: flex;
gap: 15px;
justify-content: center;
margin-top: 30px;
}
.btn {
padding: 12px 30px;
border: none;
border-radius: 10px;
font-size: 16px;
font-weight: 600;
cursor: pointer;
transition: all 0.3s;
}
.btn-primary {
background: #667eea;
color: white;
}
.btn-primary:hover {
background: #5a67d8;
transform: translateY(-2px);
box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}
.btn-secondary {
background: #e0e0e0;
color: #333;
}
.btn-secondary:hover {
background: #d0d0d0;
}
.message {
padding: 15px;
border-radius: 10px;
margin-top: 20px;
text-align: center;
font-weight: 500;
display: none;
}
.message.success {
background: #d4edda;
color: #155724;
border: 1px solid #c3e6cb;
}
.message.error {
background: #f8d7da;
color: #721c24;
border: 1px solid #f5c6cb;
}
.logs-section {
margin-top: 30px;
padding-top: 30px;
border-top: 2px solid #e0e0e0;
}
.logs-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 15px;
}
.logs-title {
font-size: 20px;
font-weight: 600;
color: #333;
}
.logs-content {
background: #f8f9fa;
border-radius: 10px;
padding: 15px;
max-height: 300px;
overflow-y: auto;
font-family: 'Courier New', monospace;
font-size: 12px;
line-height: 1.5;
display: none;
}
.spinner {
border: 3px solid #f3f3f3;
border-top: 3px solid #667eea;
border-radius: 50%;
width: 20px;
height: 20px;
animation: spin 1s linear infinite;
display: none;
margin: 0 auto;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.info-badge {
display: inline-block;
padding: 4px 12px;
background: #e3f2fd;
color: #1565c0;
border-radius: 20px;
font-size: 14px;
}
.access-info {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
border-radius: 15px;
padding: 20px;
margin-bottom: 20px;
color: white;
}
.access-info h3 {
margin-bottom: 15px;
font-size: 18px;
font-weight: 600;
}
.access-urls {
display: flex;
flex-direction: column;
gap: 10px;
}
.access-url-item {
background: rgba(255, 255, 255, 0.2);
backdrop-filter: blur(10px);
border-radius: 10px;
padding: 12px 15px;
display: flex;
justify-content: space-between;
align-items: center;
border: 1px solid rgba(255, 255, 255, 0.3);
transition: all 0.3s;
}
.access-url-item:hover {
background: rgba(255, 255, 255, 0.3);
transform: translateX(5px);
}
.url-type {
font-weight: 600;
font-size: 14px;
opacity: 0.9;
}
.url-link {
color: white;
text-decoration: none;
font-family: 'Courier New', monospace;
font-size: 13px;
padding: 4px 8px;
background: rgba(0, 0, 0, 0.2);
border-radius: 5px;
transition: all 0.2s;
}
.url-link:hover {
background: rgba(0, 0, 0, 0.3);
}
.loading-text {
text-align: center;
opacity: 0.8;
}
</style>
</head>
<body>
<div class="container">
<h1>🖥️ RDP 자동 로그인 제어 패널</h1>
<div class="access-info">
<h3>📡 접속 가능 주소</h3>
<div class="access-urls" id="access-urls">
<div class="loading-text">접속 정보를 불러오는 중...</div>
</div>
</div>
<div class="status-card">
<div class="status-item">
<span class="status-label">호스트명</span>
<span class="status-value" id="hostname">-</span>
</div>
<div class="status-item">
<span class="status-label">IP 주소</span>
<span class="status-value" id="ip-address">-</span>
</div>
<div class="status-item">
<span class="status-label">Tailscale IP</span>
<span class="status-value" id="tailscale-ip">-</span>
</div>
<div class="status-item">
<span class="status-label">RDP 포트</span>
<span class="status-value" id="rdp-port">3389</span>
</div>
<div class="status-item">
<span class="status-label">서비스 상태</span>
<span class="status-value">
<span id="service-status-indicator" class="status-indicator"></span>
<span id="service-status-text">확인 중...</span>
</span>
</div>
</div>
<div class="toggle-container">
<span class="toggle-label">자동 로그인</span>
<label class="toggle-switch">
<input type="checkbox" id="toggle" onchange="toggleAutoLogin()">
<span class="slider"></span>
</label>
<span id="toggle-status" class="info-badge">OFF</span>
</div>
<div class="button-group">
<button class="btn btn-primary" onclick="restartServices()">서비스 재시작</button>
<button class="btn btn-secondary" onclick="refreshStatus()">상태 새로고침</button>
</div>
<div id="message" class="message"></div>
<div class="spinner" id="spinner"></div>
<div class="logs-section">
<div class="logs-header">
<span class="logs-title">📋 서비스 로그</span>
<button class="btn btn-secondary" onclick="toggleLogs()">로그 보기/숨기기</button>
</div>
<div class="logs-content" id="logs-content">
로그를 불러오는 중...
</div>
</div>
</div>
<script>
let currentStatus = null;
async function fetchStatus() {
try {
const response = await fetch('/api/status');
const data = await response.json();
currentStatus = data;
updateUI(data);
} catch (error) {
console.error('상태 조회 실패:', error);
showMessage('상태 조회에 실패했습니다.', 'error');
}
}
function updateUI(data) {
// 접속 가능 URL 업데이트
if (data.system) {
const accessUrlsDiv = document.getElementById('access-urls');
let urlsHtml = '';
// Tailscale RDP 접속 URL
if (data.system.tailscale_ip) {
urlsHtml += `
<div class="access-url-item">
<span class="url-type">🔐 Tailscale RDP</span>
<a href="#" class="url-link" onclick="copyToClipboard('${data.system.tailscale_ip}'); return false;">${data.system.tailscale_ip}:3389</a>
</div>
`;
// Tailscale 웹 패널 접속 URL
urlsHtml += `
<div class="access-url-item">
<span class="url-type">🌐 Tailscale 웹패널</span>
<a href="http://${data.system.tailscale_ip}:5000" target="_blank" class="url-link">http://${data.system.tailscale_ip}:5000</a>
</div>
`;
}
// 로컬 IP RDP 접속 URL
if (data.system.ip_addresses && data.system.ip_addresses.length > 0) {
const primaryIp = data.system.ip_addresses[0];
urlsHtml += `
<div class="access-url-item">
<span class="url-type">🏠 로컬 RDP</span>
<a href="#" class="url-link" onclick="copyToClipboard('${primaryIp}'); return false;">${primaryIp}:3389</a>
</div>
`;
// 로컬 웹 패널 접속 URL
urlsHtml += `
<div class="access-url-item">
<span class="url-type">🖥️ 로컬 웹패널</span>
<a href="http://${primaryIp}:5000" target="_blank" class="url-link">http://${primaryIp}:5000</a>
</div>
`;
}
if (urlsHtml === '') {
urlsHtml = '<div class="loading-text">접속 정보를 찾을 수 없습니다</div>';
}
accessUrlsDiv.innerHTML = urlsHtml;
// 기존 시스템 정보 업데이트
document.getElementById('hostname').textContent = data.system.hostname || '-';
document.getElementById('ip-address').textContent =
data.system.ip_addresses ? data.system.ip_addresses.join(', ') : '-';
document.getElementById('tailscale-ip').textContent = data.system.tailscale_ip || '연결 안됨';
document.getElementById('rdp-port').textContent = data.system.rdp_port || '3389';
}
// 서비스 상태 업데이트
if (data.status) {
const isActive = data.status.active;
const isEnabled = data.status.enabled;
const statusIndicator = document.getElementById('service-status-indicator');
const statusText = document.getElementById('service-status-text');
const toggleSwitch = document.getElementById('toggle');
const toggleStatus = document.getElementById('toggle-status');
if (isActive) {
statusIndicator.className = 'status-indicator status-active';
statusText.textContent = '실행 중';
} else {
statusIndicator.className = 'status-indicator status-inactive';
statusText.textContent = '중지됨';
}
toggleSwitch.checked = isEnabled;
toggleStatus.textContent = isEnabled ? 'ON' : 'OFF';
toggleStatus.style.background = isEnabled ? '#d4edda' : '#f8d7da';
toggleStatus.style.color = isEnabled ? '#155724' : '#721c24';
}
}
async function toggleAutoLogin() {
const toggle = document.getElementById('toggle');
const enabled = toggle.checked;
showSpinner(true);
hideMessage();
try {
const response = await fetch('/api/toggle', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ enabled })
});
const data = await response.json();
if (data.success) {
showMessage(data.message, 'success');
updateUI({ status: data.status, system: currentStatus?.system });
} else {
showMessage(data.message, 'error');
toggle.checked = !enabled; // 실패 시 원래 상태로 복원
}
} catch (error) {
console.error('토글 실패:', error);
showMessage('설정 변경에 실패했습니다.', 'error');
toggle.checked = !enabled; // 실패 시 원래 상태로 복원
} finally {
showSpinner(false);
}
}
async function restartServices() {
if (!confirm('서비스를 재시작하시겠습니까?')) {
return;
}
showSpinner(true);
hideMessage();
try {
const response = await fetch('/api/restart', {
method: 'POST'
});
const data = await response.json();
if (data.success) {
showMessage(data.message, 'success');
setTimeout(fetchStatus, 2000); // 2초 후 상태 갱신
} else {
showMessage(data.message, 'error');
}
} catch (error) {
console.error('재시작 실패:', error);
showMessage('서비스 재시작에 실패했습니다.', 'error');
} finally {
showSpinner(false);
}
}
async function fetchLogs() {
try {
const response = await fetch('/api/logs');
const data = await response.json();
const logsContent = document.getElementById('logs-content');
if (data.xrdp_logs || data.autologin_logs) {
let content = '';
if (data.autologin_logs) {
content += '=== 자동 로그인 서비스 로그 ===\n';
content += data.autologin_logs + '\n\n';
}
if (data.xrdp_logs) {
content += '=== XRDP 서비스 로그 ===\n';
content += data.xrdp_logs;
}
logsContent.textContent = content || '로그가 없습니다.';
} else {
logsContent.textContent = '로그를 불러올 수 없습니다.';
}
} catch (error) {
console.error('로그 조회 실패:', error);
document.getElementById('logs-content').textContent = '로그 조회에 실패했습니다.';
}
}
function toggleLogs() {
const logsContent = document.getElementById('logs-content');
if (logsContent.style.display === 'none' || logsContent.style.display === '') {
logsContent.style.display = 'block';
fetchLogs();
} else {
logsContent.style.display = 'none';
}
}
function refreshStatus() {
showSpinner(true);
fetchStatus().finally(() => showSpinner(false));
}
function showMessage(text, type) {
const messageDiv = document.getElementById('message');
messageDiv.textContent = text;
messageDiv.className = `message ${type}`;
messageDiv.style.display = 'block';
setTimeout(() => {
messageDiv.style.display = 'none';
}, 5000);
}
function hideMessage() {
const messageDiv = document.getElementById('message');
messageDiv.style.display = 'none';
}
function showSpinner(show) {
const spinner = document.getElementById('spinner');
spinner.style.display = show ? 'block' : 'none';
}
function copyToClipboard(text) {
navigator.clipboard.writeText(text).then(() => {
showMessage(`${text} 클립보드에 복사되었습니다`, 'success');
}).catch(() => {
showMessage('클립보드 복사 실패', 'error');
});
}
// 페이지 로드 시 초기 상태 조회
document.addEventListener('DOMContentLoaded', () => {
fetchStatus();
// 30초마다 자동 갱신
setInterval(fetchStatus, 30000);
});
</script>
</body>
</html>

52
uninstall_web_control.sh Executable file
View File

@@ -0,0 +1,52 @@
#!/bin/bash
# RDP 자동 로그인 웹 제어 패널 제거 스크립트
set -e
echo "========================================="
echo "RDP 자동 로그인 웹 제어 패널 제거"
echo "========================================="
# 색상 정의
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# root 권한 확인
if [ "$EUID" -ne 0 ]; then
echo -e "${RED}이 스크립트는 root 권한으로 실행해야 합니다${NC}"
exit 1
fi
# 서비스 중지 및 비활성화
echo -e "${YELLOW}웹 서비스 중지 중...${NC}"
systemctl stop rdp-control-web.service 2>/dev/null || true
systemctl disable rdp-control-web.service 2>/dev/null || true
# systemd 서비스 파일 제거
echo -e "${YELLOW}systemd 서비스 제거 중...${NC}"
rm -f /etc/systemd/system/rdp-control-web.service
systemctl daemon-reload
# Python 가상 환경 제거
echo -e "${YELLOW}Python 가상 환경 제거 중...${NC}"
rm -rf /root/proxmox-rdp-autosetup/venv
# 방화벽 규칙 제거 (ufw가 설치되어 있는 경우)
if command -v ufw &> /dev/null; then
echo -e "${YELLOW}방화벽 규칙 제거 중...${NC}"
ufw delete allow 5000/tcp 2>/dev/null || true
echo -e "${GREEN}✅ 포트 5000 방화벽 규칙이 제거되었습니다${NC}"
fi
echo ""
echo -e "${GREEN}=========================================${NC}"
echo -e "${GREEN}웹 제어 패널이 제거되었습니다${NC}"
echo -e "${GREEN}=========================================${NC}"
echo ""
echo "참고: 다음 파일들은 수동으로 삭제해야 합니다:"
echo " - /root/proxmox-rdp-autosetup/rdp_control_web.py"
echo " - /root/proxmox-rdp-autosetup/templates/"
echo " - /root/proxmox-rdp-autosetup/requirements.txt"