This repository was archived by the owner on May 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate-source.ps1
More file actions
33 lines (33 loc) · 1.39 KB
/
generate-source.ps1
File metadata and controls
33 lines (33 loc) · 1.39 KB
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
cls
$baseCmd = "docker run -it --rm postgres psql -P pager=off -P footer=off -U guest -d certwatch --host crt.sh -c `"select name_value from certificate_and_identities where name_type='san:dNSName' and right(name_value, 3) = '.lu' offset __OFFSET__ limit __CHUNCK__`""
$content = ""
$chunk = 100
for($offset = 0; $offset -le 10000; $offset += $chunk) {
if($offset -eq 0){
$cmd = $baseCmd.replace("__OFFSET__", 1).replace("__CHUNCK__",$chunk)
}else{
$cmd = $baseCmd.replace("__OFFSET__", $offset).replace("__CHUNCK__",$chunk)
}
write-host ">>>> $cmd"
$output = Invoke-Expression $cmd | Out-String
write-host "<< $output"
while($output -notlike "*name_value*"){
write-host "[RETRY]>>>> $cmd"
$output = Invoke-Expression $cmd | Out-String
write-host "[RETRY]<< $output"
if($output -like "*max_client_conn*"){
write-host "[WAIT] 120 sec - release all connections..."
Start-Sleep -Seconds 120
}
if($output -like "*conflict with recovery*"){
write-host "[WAIT] 20 sec - data conflicts..."
Start-Sleep -Seconds 20
}
if($output -like "*connection to server was lost*"){
write-host "[WAIT] 10 sec - let server breathe..."
Start-Sleep -Seconds 10
}
}
$content += $output
Set-Content -Path '.\data.txt' -Value $content
}