forked from mtusi2026/mtusi2026lab3
ЛР 3 — БПИ2302 — Щербацевич — на 5
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
$ErrorActionPreference = "Stop"
|
||||
$Root = Split-Path -Parent $PSScriptRoot
|
||||
if (-not $Root) { $Root = (Resolve-Path (Join-Path $PSScriptRoot "..")).Path }
|
||||
Set-Location $Root
|
||||
New-Item -ItemType Directory -Force -Path "secrets" | Out-Null
|
||||
$passFile = Join-Path $Root "secrets\postgres_password"
|
||||
if (-not (Test-Path $passFile)) {
|
||||
$bytes = New-Object byte[] 24
|
||||
[System.Security.Cryptography.RandomNumberGenerator]::Create().GetBytes($bytes)
|
||||
$password = [Convert]::ToBase64String($bytes).TrimEnd("=").Replace("+","-").Replace("/","_")
|
||||
Set-Content -Path $passFile -Value $password -NoNewline -Encoding ascii
|
||||
}
|
||||
$password = ((Get-Content -Raw $passFile) -replace "`r","" -replace "`n","").Trim()
|
||||
Set-Content -Path (Join-Path $Root "secrets\database_url") -Value "postgresql+asyncpg://messenger:${password}@postgres:5432/messenger" -NoNewline -Encoding ascii
|
||||
Set-Content -Path (Join-Path $Root "secrets\host_database_url") -Value "postgresql+asyncpg://messenger:${password}@127.0.0.1:5433/messenger" -NoNewline -Encoding ascii
|
||||
Set-Content -Path (Join-Path $Root "secrets\cache_url") -Value "redis://redis:6379/0" -NoNewline -Encoding ascii
|
||||
Set-Content -Path (Join-Path $Root "secrets\host_cache_url") -Value "redis://127.0.0.1:6379/0" -NoNewline -Encoding ascii
|
||||
if (-not (Test-Path (Join-Path $Root ".env"))) {
|
||||
Copy-Item (Join-Path $Root ".env.example") (Join-Path $Root ".env")
|
||||
}
|
||||
Write-Output "secrets and .env are ready"
|
||||
Reference in New Issue
Block a user