netgescon-master/docs/03-scripts-automazione/run-vm-setup.ps1

68 lines
2.6 KiB
PowerShell

# 🚀 NETGESCON - ESEGUI SETUP VM MASTER
# Script PowerShell per Windows - Esegue setup completo su VM Linux
param(
[string]$VMUser = "michele",
[string]$VMHost = "192.168.0.200",
[switch]$SkipTransfer
)
Write-Host "🚀 === NETGESCON - SETUP VM MASTER ===" -ForegroundColor Green
Write-Host "📅 $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')" -ForegroundColor Gray
Write-Host ""
$ScriptPath = "u:\home\michele\netgescon\docs\03-scripts-automazione"
$SetupScript = "$ScriptPath\setup-vm-master-nginx.sh"
# Verifica che lo script esista
if (-not (Test-Path $SetupScript)) {
Write-Host "❌ Script di setup non trovato: $SetupScript" -ForegroundColor Red
exit 1
}
Write-Host "📋 Configurazione:" -ForegroundColor Yellow
Write-Host " VM Target: $VMUser@$VMHost"
Write-Host " Script Setup: setup-vm-master-nginx.sh"
Write-Host ""
if (-not $SkipTransfer) {
# 1. Trasferisce lo script sulla VM
Write-Host "📤 1. Trasferimento script sulla VM..." -ForegroundColor Cyan
$scpCmd = "scp `"$SetupScript`" $VMUser@${VMHost}:/home/michele/"
Write-Host " Comando: $scpCmd" -ForegroundColor Gray
Invoke-Expression $scpCmd
if ($LASTEXITCODE -ne 0) {
Write-Host "❌ Errore nel trasferimento file" -ForegroundColor Red
exit 1
}
Write-Host " ✅ Script trasferito" -ForegroundColor Green
}
# 2. Esegue lo script sulla VM
Write-Host ""
Write-Host "🔧 2. Esecuzione setup su VM..." -ForegroundColor Cyan
Write-Host " ATTENZIONE: Lo script richiederà sudo password sulla VM" -ForegroundColor Yellow
Write-Host ""
# Comando SSH per eseguire il setup
$sshCmd = "ssh $VMUser@$VMHost `"chmod +x setup-vm-master-nginx.sh && sudo ./setup-vm-master-nginx.sh`""
Write-Host " Comando: $sshCmd" -ForegroundColor Gray
Invoke-Expression $sshCmd
if ($LASTEXITCODE -eq 0) {
Write-Host ""
Write-Host "🎉 === SETUP COMPLETATO ===" -ForegroundColor Green
Write-Host "🌐 NetGescon dovrebbe essere accessibile su: http://$VMHost" -ForegroundColor Cyan
Write-Host "🐙 Gitea dovrebbe essere accessibile su: http://$VMHost:3000" -ForegroundColor Cyan
Write-Host ""
Write-Host "📋 Prossimi passi:" -ForegroundColor Yellow
Write-Host " 1. Testa accesso NetGescon: http://$VMHost"
Write-Host " 2. Configura Gitea: http://$VMHost:3000"
Write-Host " 3. Crea repository Git su Gitea"
Write-Host " 4. Push del progetto NetGescon"
} else {
Write-Host ""
Write-Host "❌ Errore durante l'esecuzione del setup" -ForegroundColor Red
Write-Host " Controlla i log sulla VM per dettagli" -ForegroundColor Yellow
}