You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

56 lines
1.4 KiB

$ErrorActionPreference = "Stop"
$ProjectDirectory = Split-Path -Parent $MyInvocation.MyCommand.Path
$EnvironmentFile = Join-Path $ProjectDirectory ".env"
if (Test-Path $EnvironmentFile) {
Write-Host ".env besteht bereits; es wurde nichts ueberschrieben."
exit 0
}
function New-RandomHex([int]$ByteCount) {
$Bytes = New-Object byte[] $ByteCount
$Generator = [System.Security.Cryptography.RandomNumberGenerator]::Create()
try {
$Generator.GetBytes($Bytes)
}
finally {
$Generator.Dispose()
}
return (($Bytes | ForEach-Object { $_.ToString("x2") }) -join "")
}
$DatabasePassword = New-RandomHex 24
$SecretKeyBase = New-RandomHex 64
$PgHeroPassword = New-RandomHex 16
$Content = @"
DATABASE_PASSWORD=$DatabasePassword
SECRET_KEY_BASE=$SecretKeyBase
API_PORT=13000
FRONTEND_PORT=13131
FRONTEND_ORIGINS=http://localhost:13131
FRONTEND_URL=http://localhost:13131
ADMIN_EMAIL=christoph@marzell.net
MAILER_FROM=praktikum@marzell.net
SMTP_ENABLED=true
SMTP_ADDRESS=smtp.ionos.de
SMTP_PORT=587
SMTP_USERNAME=praktikum@marzell.net
SMTP_PASSWORD=CHANGE_ME
SMTP_DOMAIN=marzell.net
BACKUP_NOTIFY_EMAIL=christoph@marzell.net
TRAINING_WATCH_NOTIFY_EMAIL=christoph@marzell.net
PGHERO_USERNAME=admin
PGHERO_PASSWORD=$PgHeroPassword
"@
[System.IO.File]::WriteAllText(
$EnvironmentFile,
$Content,
[System.Text.UTF8Encoding]::new($false)
)
Write-Host ".env wurde mit zufaelligen Zugangsdaten erstellt."