proxmox-rdp-autosetup/templates/index.html
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

628 lines
20 KiB
HTML

<!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>