diff --git a/update_conf_Alloy.ps1 b/update_conf_Alloy.ps1 index e69de29..b582226 100644 --- a/update_conf_Alloy.ps1 +++ b/update_conf_Alloy.ps1 @@ -0,0 +1,41 @@ +# --- Configuración --- +$repoDir = "C:\lab_git\dex" +$repoUrl = "https://git.insidemicro.com/panotuco/dex.git" +$alloyConfigPath = "C:\Program Files\GrafanaLabs\Alloy\config.alloy" +$serviceName = "alloy" + +# --- 1. Gestión del repositorio --- +if (-not (Test-Path $repoDir)) { + New-Item -ItemType Directory -Force -Path $repoDir + git clone $repoUrl $repoDir +} + +cd $repoDir +git fetch origin + +# --- 2. Comprobación de cambios --- +$localHash = git rev-parse HEAD +$remoteHash = git rev-parse origin/main # Verifica si tu rama es 'main' o 'master' + +if ($localHash -ne $remoteHash) { + Write-Host "Nueva configuración detectada en Git..." -ForegroundColor Cyan + + # Descargar cambios + git reset --hard origin/main + + # El archivo en el repo debe llamarse igual o ajusta esta línea: + $sourceFile = Join-Path $repoDir "config.alloy" + + if (Test-Path $sourceFile) { + # --- 3. Sobrescribir archivo en Program Files --- + Copy-Item -Path $sourceFile -Destination $alloyConfigPath -Force + Write-Host "Archivo config.alloy actualizado." -ForegroundColor Green + + # --- 4. Reiniciar servicio --- + Write-Host "Reiniciando servicio Grafana Alloy..." -ForegroundColor Yellow + Restart-Service -Name $serviceName -ErrorAction SilentlyContinue + Write-Host "Proceso finalizado." -ForegroundColor Green + } +} else { + Write-Host "Sin cambios. Alloy está actualizado." +} \ No newline at end of file