Files
gomag-vending/update.ps1
2026-03-16 15:07:13 +00:00

36 lines
1.1 KiB
PowerShell

# GoMag Vending - Update Script
# Ruleaza ca Administrator: .\update.ps1
$RepoPath = "C:\gomag-vending"
$TokenFile = Join-Path $RepoPath ".gittoken"
# Citire token
if (-not (Test-Path $TokenFile)) {
Write-Host "EROARE: $TokenFile nu exista!" -ForegroundColor Red
exit 1
}
$token = (Get-Content $TokenFile -Raw).Trim()
# Git pull
Write-Host "==> Git pull..." -ForegroundColor Cyan
Set-Location $RepoPath
git -c credential.helper="" pull "https://gomag-vending:$token@gitea.romfast.ro/romfast/gomag-vending.git"
if ($LASTEXITCODE -ne 0) {
Write-Host "EROARE: git pull esuat!" -ForegroundColor Red
exit 1
}
# Pip install (daca s-au schimbat dependintele)
Write-Host "==> Verificare dependinte..." -ForegroundColor Cyan
& "$RepoPath\venv\Scripts\pip.exe" install -r "$RepoPath\api\requirements.txt" --quiet
# Restart serviciu
Write-Host "==> Restart GoMagVending..." -ForegroundColor Cyan
nssm restart GoMagVending
Start-Sleep -Seconds 3
$status = nssm status GoMagVending 2>&1
Write-Host "Serviciu: $status" -ForegroundColor Green
Write-Host ""
Write-Host "Update complet! Acces: http://localhost/gomag/" -ForegroundColor Green