Skip to content

Commit 6fb1112

Browse files
committed
[+] add PowerShell installation script, resolves #8
1 parent 3262a4f commit 6fb1112

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

src/install.ps1

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Write-Host "--- Installing Python runtime ---" -ForegroundColor blue
2+
.\python-install.exe /quiet InstallAllUsers=1 PrependPath=1 Include_test=0 Include_launcher=0
3+
python.exe -m pip install --upgrade pip
4+
Write-Host "--- Python runtime installed ---`n" -ForegroundColor green
5+
6+
# Update Path variable with installed Python
7+
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
8+
9+
Write-Host "--- Installing Patroni packages ---" -ForegroundColor blue
10+
Set-Location 'patroni'
11+
pip3.exe install --no-index --find-links .patroni-packages -r requirements.txt
12+
pip3.exe install --no-index --find-links .patroni-packages psycopg2-binary
13+
Set-Location '..'
14+
Write-Host "--- Patroni packages installed ---`n" -ForegroundColor green
15+
16+
Write-Host "--- Adding local user 'pes' for patroni service ---" -ForegroundColor blue
17+
$Password = -join ((65..90) + (97..122) | Get-Random -Count 8 | % {[char]$_})
18+
$SecurePassword = ConvertTo-SecureString $Password -AsPlainText -Force
19+
New-LocalUser "pes" -Password $SecurePassword -Description "Patroni service account"
20+
$ConfFile = 'patroni\patroni_service.xml'
21+
(Get-Content $ConfFile) -replace '12345', $Password | Out-File -encoding ASCII $ConfFile
22+
Write-Host "User password: $Password"
23+
Write-Host "--- Patroni user added ---`n" -ForegroundColor green
24+
25+
Write-Host "--- Installation sucessfully finished ---" -ForegroundColor green

src/patroni_service.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<log mode="roll"></log>
99
<logpath>%BASE%\log</logpath>
1010
<serviceaccount>
11-
<user>postgres</user>
11+
<user>pes</user>
1212
<password>12345</password>
1313
<allowservicelogon>true</allowservicelogon>
1414
</serviceaccount>

0 commit comments

Comments
 (0)