File tree Expand file tree Collapse file tree 1 file changed +16
-7
lines changed Expand file tree Collapse file tree 1 file changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -13,12 +13,21 @@ pip3.exe install --no-index --find-links .patroni-packages psycopg2-binary
1313Set-Location ' ..'
1414Write-Host " --- Patroni packages installed ---`n " - ForegroundColor green
1515
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 " --- Patroni user added ---`n " - ForegroundColor green
16+ $userName = " pes"
17+ $out = Get-LocalUser - Name $userName - ErrorAction SilentlyContinue
18+ if ($out -eq $null )
19+ {
20+ Write-Host " --- Adding local user '$userName ' for patroni service ---" - ForegroundColor blue
21+ $Password = -join ((65 .. 90 ) + (97 .. 122 ) | Get-Random - Count 8 | % {[char ]$_ })
22+ $SecurePassword = ConvertTo-SecureString $Password - AsPlainText - Force
23+ New-LocalUser $userName - Password $SecurePassword - Description " Patroni service account"
24+ $ConfFile = ' patroni\patroni_service.xml'
25+ (Get-Content $ConfFile ) -replace ' 12345' , $Password | Out-File - encoding ASCII $ConfFile
26+ Write-Host " --- Patroni user '$userName ' added ---`n " - ForegroundColor green
27+ }
28+ else
29+ {
30+ Write-Host " --- Patroni user '$userName ' already exists ---`n " - ForegroundColor green
31+ }
2332
2433Write-Host " --- Installation sucessfully finished ---" - ForegroundColor green
You can’t perform that action at this time.
0 commit comments