2) Healthcheck improvements. Fixes: merge_recently_viewed for UserViewSet
45 lines
926 B
PowerShell
45 lines
926 B
PowerShell
#!/usr/bin/env pwsh
|
|
Set-StrictMode -Version Latest
|
|
$ErrorActionPreference = 'Stop'
|
|
|
|
$envFile = '.env'
|
|
|
|
if (-not (Test-Path $envFile))
|
|
{
|
|
Write-Error ".env file not found in the current directory."
|
|
exit 1
|
|
}
|
|
|
|
Get-Content $envFile | ForEach-Object {
|
|
$line = $_.Trim()
|
|
if ($line -eq '' -or $line.StartsWith('#'))
|
|
{
|
|
return
|
|
}
|
|
|
|
if ($line -notmatch '=')
|
|
{
|
|
return
|
|
}
|
|
|
|
$m = [Regex]::Match($line, '^\s*([^=]+?)\s*=\s*(.*)$')
|
|
if (-not $m.Success)
|
|
{
|
|
return
|
|
}
|
|
|
|
$key = $m.Groups[1].Value
|
|
$value = $m.Groups[2].Value
|
|
|
|
if (( $value.StartsWith('"') -and $value.EndsWith('"')) -or
|
|
( $value.StartsWith("'") -and $value.EndsWith("'")))
|
|
{
|
|
$value = $value.Substring(1, $value.Length - 2)
|
|
}
|
|
|
|
New-Item -Path Env:\$key -Value $value
|
|
|
|
Write-Host "Set environment variable: $key"
|
|
}
|
|
|
|
Write-Host "All variables loaded from $envFile."
|