feat: update manage dashboard flows
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
사용 파일
|
||||
- start_ptc_share.bat : 공유용 실행 파일. 관리자 권한으로 다시 실행되어 WSL 서버 시작, IP 공유 설정, 방화벽 허용, 공유 주소 복사까지 처리합니다.
|
||||
- install_ptc_share_autostart.bat : Windows 로그인 시 자동으로 공유가 시작되도록 작업 스케줄러에 등록합니다.
|
||||
- remove_ptc_share_autostart.bat : 자동 실행 등록을 해제합니다.
|
||||
- set_ptc_source.bat : 사용할 PTC 원본 `.xlsx` 파일을 선택하고 저장한 뒤 서버를 다시 시작합니다.
|
||||
- stop_ptc_share.bat : 공유 중지
|
||||
- check_ptc_share.bat : 현재 공유 상태 확인
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
@echo off
|
||||
setlocal EnableExtensions
|
||||
set "HOST_IP="
|
||||
|
||||
for /f "usebackq delims=" %%i in (`powershell -NoProfile -Command "$ip = Get-NetIPAddress -AddressFamily IPv4 ^| Where-Object { $_.IPAddress -notlike '127.*' -and $_.IPAddress -notlike '169.254.*' -and $_.PrefixOrigin -ne 'WellKnown' } ^| Sort-Object InterfaceMetric, SkipAsSource ^| Select-Object -ExpandProperty IPAddress -First 1; if ($ip) { $ip }"`) do (
|
||||
set "HOST_IP=%%i"
|
||||
)
|
||||
|
||||
if "%HOST_IP%"=="" set "HOST_IP=localhost"
|
||||
set "HOST_IP=172.16.40.36"
|
||||
|
||||
echo [Windows portproxy]
|
||||
netsh interface portproxy show v4tov4
|
||||
@@ -15,10 +9,13 @@ echo [WSL api]
|
||||
wsl.exe bash -lc "curl -s http://127.0.0.1:4000/api/health"
|
||||
echo.
|
||||
echo [WSL web]
|
||||
wsl.exe bash -lc "curl -I -s http://127.0.0.1:4000/PTC/ | head -n 1"
|
||||
wsl.exe bash -lc "curl -I -s http://127.0.0.1:4000/PTC-lab/ | head -n 1"
|
||||
echo.
|
||||
echo [WSL manage web]
|
||||
wsl.exe bash -lc "curl -I -s http://127.0.0.1:4000/PTC-lab-manage/ | head -n 1"
|
||||
echo.
|
||||
echo [Office LAN web]
|
||||
powershell -NoProfile -Command "try { (Invoke-WebRequest -Uri 'http://%HOST_IP%:4000/PTC/' -UseBasicParsing -TimeoutSec 5).StatusCode } catch { $_.Exception.Message }"
|
||||
powershell -NoProfile -Command "try { (Invoke-WebRequest -Uri 'http://%HOST_IP%:4000/PTC-lab-manage/' -UseBasicParsing -TimeoutSec 5).StatusCode } catch { $_.Exception.Message }"
|
||||
echo.
|
||||
echo [Office LAN api]
|
||||
powershell -NoProfile -Command "try { (Invoke-WebRequest -Uri 'http://%HOST_IP%:4000/api/health' -UseBasicParsing -TimeoutSec 5).Content } catch { $_.Exception.Message }"
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
param(
|
||||
[switch]$NoBrowser,
|
||||
[switch]$NoPause
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
function Test-IsAdmin {
|
||||
@@ -7,17 +12,22 @@ function Test-IsAdmin {
|
||||
}
|
||||
|
||||
if (-not (Test-IsAdmin)) {
|
||||
Start-Process -FilePath "powershell.exe" -Verb RunAs -ArgumentList @(
|
||||
$childArgs = @(
|
||||
"-NoProfile",
|
||||
"-ExecutionPolicy", "Bypass",
|
||||
"-File", "`"$PSCommandPath`""
|
||||
)
|
||||
if ($NoBrowser) { $childArgs += "-NoBrowser" }
|
||||
if ($NoPause) { $childArgs += "-NoPause" }
|
||||
Start-Process -FilePath "powershell.exe" -Verb RunAs -ArgumentList @(
|
||||
$childArgs
|
||||
)
|
||||
exit 0
|
||||
}
|
||||
|
||||
$projectDir = "/home/hyein/project"
|
||||
$apiPort = 4000
|
||||
$localUrl = "http://localhost:$apiPort/PTC/"
|
||||
$localUrl = "http://localhost:$apiPort/PTC-lab-manage/"
|
||||
$preferredLanIp = "172.16.40.36"
|
||||
$defaultSource = "/home/hyein/project/PTC(2023-2026.02).xlsx"
|
||||
$sourceConfigPath = "/home/hyein/project/server/ptc_source_path.txt"
|
||||
@@ -43,30 +53,39 @@ Write-Host "Source file: $currentSource"
|
||||
$startResult = Invoke-WslBash "pkill -f '/home/hyein/project/server/ptc_api_server.py' >/dev/null 2>&1 || true; nohup python3 /home/hyein/project/server/ptc_api_server.py >/tmp/ptc_api.log 2>&1 & sleep 3"
|
||||
if ($startResult.ExitCode -ne 0) {
|
||||
Write-Host "Failed to start the server in WSL." -ForegroundColor Red
|
||||
Read-Host "Press Enter to exit"
|
||||
if (-not $NoPause) {
|
||||
Read-Host "Press Enter to exit"
|
||||
}
|
||||
exit 1
|
||||
}
|
||||
|
||||
$healthResult = Invoke-WslBash "curl -fsS http://127.0.0.1:$apiPort/api/health >/tmp/ptc_api_health.json && curl -fsSI http://127.0.0.1:$apiPort/PTC/ >/tmp/ptc_web_health.txt"
|
||||
$healthResult = Invoke-WslBash "curl -fsS http://127.0.0.1:$apiPort/api/health >/tmp/ptc_api_health.json && curl -fsSI http://127.0.0.1:$apiPort/PTC-lab/ >/tmp/ptc_web_health.txt && curl -fsSI http://127.0.0.1:$apiPort/PTC-lab-manage/ >/tmp/ptc_manage_web_health.txt"
|
||||
if ($healthResult.ExitCode -ne 0) {
|
||||
Write-Host "Local server check failed. Recent server log:" -ForegroundColor Red
|
||||
$logResult = Invoke-WslBash "tail -n 80 /tmp/ptc_api.log"
|
||||
$logResult.Output | ForEach-Object { Write-Host $_ }
|
||||
Read-Host "Press Enter to exit"
|
||||
if (-not $NoPause) {
|
||||
Read-Host "Press Enter to exit"
|
||||
}
|
||||
exit 1
|
||||
}
|
||||
|
||||
Start-Process $localUrl
|
||||
if (-not $NoBrowser) {
|
||||
Start-Process $localUrl
|
||||
}
|
||||
Write-Host ""
|
||||
Write-Host "Local URL: $localUrl"
|
||||
|
||||
$lanIp = Get-NetIPAddress -AddressFamily IPv4 |
|
||||
$lanIps = @(Get-NetIPAddress -AddressFamily IPv4 |
|
||||
Where-Object {
|
||||
$_.IPAddress -notlike '127.*' -and
|
||||
$_.IPAddress -notlike '169.254.*' -and
|
||||
$_.PrefixOrigin -ne 'WellKnown'
|
||||
} |
|
||||
Select-Object -ExpandProperty IPAddress -First 1
|
||||
Sort-Object InterfaceMetric, SkipAsSource |
|
||||
Select-Object -ExpandProperty IPAddress)
|
||||
|
||||
$lanIp = $lanIps | Select-Object -First 1
|
||||
|
||||
$wslIpResult = Invoke-WslBash "hostname -I | awk '{print \$1}'"
|
||||
$wslIp = ($wslIpResult.Output | Select-Object -First 1).Trim()
|
||||
@@ -78,14 +97,39 @@ if (-not [string]::IsNullOrWhiteSpace($lanIp) -and -not [string]::IsNullOrWhiteS
|
||||
& netsh advfirewall firewall delete rule name="PTC 4000" | Out-Null
|
||||
& netsh advfirewall firewall add rule name="PTC 4000" dir=in action=allow protocol=TCP localport=$apiPort | Out-Null
|
||||
|
||||
$shareIp = if ([string]::IsNullOrWhiteSpace($preferredLanIp)) { $lanIp } else { $preferredLanIp }
|
||||
$shareUrl = "http://$shareIp:$apiPort/PTC/"
|
||||
if (-not ($lanIps -contains $preferredLanIp)) {
|
||||
Write-Host "Preferred share IP $preferredLanIp is not assigned on this PC." -ForegroundColor Red
|
||||
Write-Host "Detected Windows IPs: $($lanIps -join ', ')" -ForegroundColor Yellow
|
||||
if (-not $NoPause) {
|
||||
Read-Host "Press Enter to exit"
|
||||
}
|
||||
exit 1
|
||||
}
|
||||
|
||||
$shareIp = $preferredLanIp
|
||||
$shareUrl = "http://$shareIp:$apiPort/PTC-lab-manage/"
|
||||
Write-Host "Windows IP: $lanIp"
|
||||
Write-Host "Preferred share IP in use: $shareIp"
|
||||
Write-Host "WSL IP: $wslIp"
|
||||
Write-Host "LAN URL: $shareUrl"
|
||||
Set-Clipboard -Value $shareUrl
|
||||
Write-Host "The share URL has been copied to the clipboard."
|
||||
|
||||
try {
|
||||
$lanWebStatus = (Invoke-WebRequest -Uri $shareUrl -UseBasicParsing -TimeoutSec 5).StatusCode
|
||||
$lanApiStatus = (Invoke-WebRequest -Uri "http://$shareIp:$apiPort/api/health" -UseBasicParsing -TimeoutSec 5).StatusCode
|
||||
Write-Host "LAN web check: $lanWebStatus"
|
||||
Write-Host "LAN api check: $lanApiStatus"
|
||||
}
|
||||
catch {
|
||||
Write-Host "LAN check failed for $shareIp:$apiPort" -ForegroundColor Red
|
||||
Write-Host $_.Exception.Message -ForegroundColor Yellow
|
||||
}
|
||||
}
|
||||
else {
|
||||
Write-Host "LAN sharing was skipped because Windows IP or WSL IP could not be detected."
|
||||
}
|
||||
|
||||
Read-Host "Press Enter to close"
|
||||
if (-not $NoPause) {
|
||||
Read-Host "Press Enter to close"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user