Перенес основы lab3 в lab4

This commit is contained in:
Daria0w0
2026-11-06 14:44:30 +03:00
parent ec540a1a72
commit 9197e151ba
59 changed files with 4761 additions and 3 deletions
+35
View File
@@ -0,0 +1,35 @@
$ErrorActionPreference = 'Stop'
$repoRoot = Split-Path -Parent $PSScriptRoot
$envPath = Join-Path $repoRoot '.env'
if (-not (Test-Path -LiteralPath $envPath)) {
Copy-Item -LiteralPath (Join-Path $repoRoot '.env.example') -Destination $envPath
Write-Output 'Local .env created (non-secret session TTL).'
} else {
Write-Output 'Existing .env preserved.'
}
$secretsDirectory = Join-Path $repoRoot 'secrets'
$passwordPath = Join-Path $secretsDirectory 'postgres_password.txt'
New-Item -ItemType Directory -Path $secretsDirectory -Force | Out-Null
if (Test-Path -LiteralPath $passwordPath) {
if ((Get-Item -LiteralPath $passwordPath).Length -eq 0) {
throw 'Existing password file is empty. Supply a local password before starting PostgreSQL.'
}
Write-Output 'Existing PostgreSQL password preserved.'
exit 0
}
$randomBytes = New-Object byte[] 32
$generator = [System.Security.Cryptography.RandomNumberGenerator]::Create()
try {
$generator.GetBytes($randomBytes)
} finally {
$generator.Dispose()
}
$password = [Convert]::ToBase64String($randomBytes)
[System.IO.File]::WriteAllText($passwordPath, $password, [System.Text.Encoding]::ASCII)
Write-Output 'Local PostgreSQL password created in secrets/ (value not printed).'