forked from NSPG13/agent-bounties
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpowershell.ps1
More file actions
36 lines (31 loc) · 949 Bytes
/
Copy pathpowershell.ps1
File metadata and controls
36 lines (31 loc) · 949 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
function Invoke-Checked {
param(
[Parameter(Mandatory = $true)]
[scriptblock] $Command
)
$global:LASTEXITCODE = 0
& $Command
$commandSucceeded = $?
$exitCode = $global:LASTEXITCODE
if (-not $commandSucceeded -or $exitCode -ne 0) {
throw "Command failed with exit code $exitCode`: $Command"
}
$global:LASTEXITCODE = 0
}
function Start-AgentBountiesPostgres {
Invoke-Checked { docker compose up -d postgres }
for ($i = 0; $i -lt 30; $i++) {
docker compose exec -T postgres pg_isready -U agent_bounties | Out-Null
if ($LASTEXITCODE -eq 0) {
return
}
Start-Sleep -Seconds 2
}
throw "Postgres did not become ready within 60 seconds"
}
function Get-AgentBountiesDatabaseUrl {
if ($env:DATABASE_URL) {
return $env:DATABASE_URL
}
return "postgres://agent_bounties:agent_bounties@localhost:5432/agent_bounties"
}