diff --git a/hermes/deploy.ps1 b/hermes/deploy.ps1 index f73b58f..cffe780 100644 --- a/hermes/deploy.ps1 +++ b/hermes/deploy.ps1 @@ -15,8 +15,10 @@ param( $ErrorActionPreference = 'Stop' -$Green = "`e[32m"; $Cyan = "`e[36m"; $Yellow = "`e[33m"; $Red = "`e[31m"; $Bold = "`e[1m"; $NC = "`e[0m" -if ($env:NO_COLOR -or -not $PSStyle) { +# Escape ANSI via [char]27 (compatible con Windows PowerShell 5.1 y PS 7+) +$Esc = [char]27 +$Green = "$Esc[32m"; $Cyan = "$Esc[36m"; $Yellow = "$Esc[33m"; $Red = "$Esc[31m"; $Bold = "$Esc[1m"; $NC = "$Esc[0m" +if ($env:NO_COLOR) { $Green = $Cyan = $Yellow = $Red = $Bold = $NC = '' } diff --git a/openclaw/deploy.ps1 b/openclaw/deploy.ps1 index 55a055f..809efe0 100644 --- a/openclaw/deploy.ps1 +++ b/openclaw/deploy.ps1 @@ -15,8 +15,10 @@ param( $ErrorActionPreference = 'Stop' -$Green = "`e[32m"; $Cyan = "`e[36m"; $Yellow = "`e[33m"; $Red = "`e[31m"; $Bold = "`e[1m"; $NC = "`e[0m" -if ($env:NO_COLOR -or -not $PSStyle) { +# Escape ANSI via [char]27 (compatible con Windows PowerShell 5.1 y PS 7+) +$Esc = [char]27 +$Green = "$Esc[32m"; $Cyan = "$Esc[36m"; $Yellow = "$Esc[33m"; $Red = "$Esc[31m"; $Bold = "$Esc[1m"; $NC = "$Esc[0m" +if ($env:NO_COLOR) { $Green = $Cyan = $Yellow = $Red = $Bold = $NC = '' } diff --git a/openwebui/deploy.ps1 b/openwebui/deploy.ps1 index 2e0bd08..0e9854f 100644 --- a/openwebui/deploy.ps1 +++ b/openwebui/deploy.ps1 @@ -15,8 +15,10 @@ param( $ErrorActionPreference = 'Stop' -$Green = "`e[32m"; $Cyan = "`e[36m"; $Yellow = "`e[33m"; $Red = "`e[31m"; $Bold = "`e[1m"; $NC = "`e[0m" -if ($env:NO_COLOR -or -not $PSStyle) { +# Escape ANSI via [char]27 (compatible con Windows PowerShell 5.1 y PS 7+) +$Esc = [char]27 +$Green = "$Esc[32m"; $Cyan = "$Esc[36m"; $Yellow = "$Esc[33m"; $Red = "$Esc[31m"; $Bold = "$Esc[1m"; $NC = "$Esc[0m" +if ($env:NO_COLOR) { $Green = $Cyan = $Yellow = $Red = $Bold = $NC = '' } diff --git a/wordpress/deploy.ps1 b/wordpress/deploy.ps1 index b10a17e..2ab7d4c 100644 --- a/wordpress/deploy.ps1 +++ b/wordpress/deploy.ps1 @@ -15,8 +15,10 @@ param( $ErrorActionPreference = 'Stop' -$Green = "`e[32m"; $Cyan = "`e[36m"; $Yellow = "`e[33m"; $Red = "`e[31m"; $Bold = "`e[1m"; $NC = "`e[0m" -if ($env:NO_COLOR -or -not $PSStyle) { +# Escape ANSI via [char]27 (compatible con Windows PowerShell 5.1 y PS 7+) +$Esc = [char]27 +$Green = "$Esc[32m"; $Cyan = "$Esc[36m"; $Yellow = "$Esc[33m"; $Red = "$Esc[31m"; $Bold = "$Esc[1m"; $NC = "$Esc[0m" +if ($env:NO_COLOR) { $Green = $Cyan = $Yellow = $Red = $Bold = $NC = '' } @@ -92,11 +94,22 @@ if (-not (Test-Path $EnvFile)) { $rng.GetBytes($Bytes); $WpPass = ($Bytes | ForEach-Object { $_.ToString('x2') }) -join '' $rng.Dispose() - # La 1a coincidencia es MYSQL_ROOT_PASSWORD, la 2a MYSQL_PASSWORD (orden del .env.example) - $Content = Get-Content $EnvFile -Raw - $Content = $Content -replace 'change-me-to-a-strong-password', $RootPass, 1 - $Content = $Content -replace 'change-me-to-a-strong-password', $WpPass, 1 - Set-Content $EnvFile -Value $Content -NoNewline + # 1a coincidencia en el fichero = MYSQL_ROOT_PASSWORD, 2a = MYSQL_PASSWORD. + # -replace no acepta tercer operando (count) en ninguna version de PS, + # asi que se recorre linea a linea. + $Lines = Get-Content $EnvFile + $Replaced = 0 + for ($i = 0; $i -lt $Lines.Count; $i++) { + if ($Lines[$i] -like '*change-me-to-a-strong-password*') { + if ($Replaced -eq 0) { + $Lines[$i] = $Lines[$i] -replace 'change-me-to-a-strong-password', $RootPass + } else { + $Lines[$i] = $Lines[$i] -replace 'change-me-to-a-strong-password', $WpPass + } + $Replaced++ + } + } + Set-Content $EnvFile -Value $Lines Info "Contrasenas generadas en $EnvFile" }