diff --git a/deployment/windows/scripts/menu.ps1 b/deployment/windows/scripts/menu.ps1 index 4df9501..b0bbaf9 100644 --- a/deployment/windows/scripts/menu.ps1 +++ b/deployment/windows/scripts/menu.ps1 @@ -58,6 +58,9 @@ function Show-MainMenu { Write-Host " [R] Run Scraper (Manual)" -ForegroundColor Cyan Write-Host " [T] Run Telegram Bot (Manual)" -ForegroundColor Cyan Write-Host "" + Write-Host " Maintenance:" -ForegroundColor DarkCyan + Write-Host " [G] Git Pull & Restart Service" -ForegroundColor Cyan + Write-Host "" Write-Host " [A] Open Deployment README" -ForegroundColor Gray Write-Host " [B] Open Quick Start Guide" -ForegroundColor Gray Write-Host " [C] Open Project in Explorer" -ForegroundColor Gray @@ -270,6 +273,49 @@ function Invoke-UpdateBrowsers { Read-Host "`nApasa Enter pentru a reveni la meniu" } +function Invoke-GitPullRestart { + Clear-Host + Write-Host "" + Write-Host ("=" * 80) -ForegroundColor Cyan + Write-Host "GIT PULL & RESTART SERVICE" -ForegroundColor Yellow + Write-Host ("=" * 80) -ForegroundColor Cyan + Write-Host "" + + # Git pull + Write-Host "[INFO] Actualizare proiect din Git..." -ForegroundColor Cyan + Write-Host "" + + Push-Location $ProjectDir + try { + git pull + $gitExitCode = $LASTEXITCODE + Write-Host "" + + if ($gitExitCode -eq 0) { + Write-Host "[SUCCES] Proiect actualizat!" -ForegroundColor Green + Write-Host "" + + # Restart service if installed + $service = Get-Service -Name $ServiceName -ErrorAction SilentlyContinue + if ($service) { + Write-Host "[INFO] Restart serviciu..." -ForegroundColor Cyan + & "$ScriptDir\restart_service.ps1" + } else { + Write-Host "[INFO] Serviciul nu este instalat, restart nu este necesar" -ForegroundColor Yellow + } + } else { + Write-Host "[EROARE] Git pull a esuat cu codul $gitExitCode" -ForegroundColor Red + } + } catch { + Write-Host "[EROARE] Eroare la git pull: $_" -ForegroundColor Red + } finally { + Pop-Location + } + + Write-Host "" + Read-Host "Apasa Enter pentru a reveni la meniu" +} + # Main loop do { Show-MainMenu @@ -301,6 +347,8 @@ do { "t" { Invoke-RunTelegramBotManual } "U" { Invoke-UpdateBrowsers } "u" { Invoke-UpdateBrowsers } + "G" { Invoke-GitPullRestart } + "g" { Invoke-GitPullRestart } "0" { Write-Host "" Write-Host "Goodbye!" -ForegroundColor Green