From 8064611f7fb8280d9d9300d0214af864dcdbe9a7 Mon Sep 17 00:00:00 2001 From: "Dariy.Nurgaleev" Date: Sat, 28 Mar 2020 00:58:31 +0700 Subject: [PATCH 01/26] added windows installation script for postgresql --- .../scripts/Installers/Install-PostgreSQL.ps1 | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 images/win/scripts/Installers/Install-PostgreSQL.ps1 diff --git a/images/win/scripts/Installers/Install-PostgreSQL.ps1 b/images/win/scripts/Installers/Install-PostgreSQL.ps1 new file mode 100644 index 000000000000..bcf8bf4b2870 --- /dev/null +++ b/images/win/scripts/Installers/Install-PostgreSQL.ps1 @@ -0,0 +1,68 @@ +function Install-PostgreSQL { + $installPath= choco install postgresql | Select-String "Installed to" + return $installPath.Line.split("'")[1] +} + +function Start-PostgreSQL { + param( + [String]$PostgresPath + ) + $pgbin=Join-path $PostgresPath "bin" + $pgdata=Join-path $PostgresPath "data" + $startPostgres=Join-path $pgbin "pg_ctl.exe" + $process = Start-Process -FilePath $startPostgres -ArgumentList ("-D", "$pgdata", "start") + $exitCode = $process.ExitCode + if ($exitCode -eq 0) + { + Write-Host -Object "PostgreSQL has been successfully started." + } + else + { + Write-Host -Object "PostgreSQL cannot be started. Exitcode: $exitCode" + exit $exitCode + } +} + +function Ready-PostgreSQL { + param( + [String]$PostgresPath + ) + $pgbin=Join-path $PostgresPath "bin" + $pgisreadypath=Join-path $pgbin "pg_isready.exe" + $pgready = Start-Process -FilePath $pgisreadypath -Wait -PassThru + $exitCode = $pgready.ExitCode + if ($exitCode -eq 0) + { + Write-Host -Object "PostgreSQL has been successfully installed." + } + else + { + Write-Host -Object "PostgreSQL is not ready. Exitcode: $exitCode" + exit $exitCode + } +} + +function Version-PostgreSQL { + param( + [String]$PostgresPath + ) + $pgbin=Join-path $PostgresPath "bin" + $pgconfig=Join-path $pgbin "pg_config.exe" + $psqlversion=Start-Process -FilePath $pgconfig -ArgumentList ("--version")-Wait -PassThru + return $psqlversion +} + +$psqlDir=Install-PostgreSQL +$psqlVersion=Version-PostgreSQL -PostgresPath $psqlDir +Start-PostgreSQL -PostgresPath $psqlDir +Ready-PostgreSQL -PostgresPath $psqlDir + + +# Adding description of the software to Markdown +$SoftwareName = "PostgreSQL" +$Description = @" +_Version:_ $psqlVersion
+_Default Path:_ $psqlDir +"@ + +Add-SoftwareDetailsToMarkdown -SoftwareName $SoftwareName -DescriptionMarkdown $Description \ No newline at end of file From 88a0923cab5b19223480c58b9e33a7f75c584197 Mon Sep 17 00:00:00 2001 From: "Dariy.Nurgaleev" Date: Sat, 28 Mar 2020 01:43:42 +0700 Subject: [PATCH 02/26] removed if from Start-PostreSQL --- .../win/scripts/Installers/Install-PostgreSQL.ps1 | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/images/win/scripts/Installers/Install-PostgreSQL.ps1 b/images/win/scripts/Installers/Install-PostgreSQL.ps1 index bcf8bf4b2870..9515a845864d 100644 --- a/images/win/scripts/Installers/Install-PostgreSQL.ps1 +++ b/images/win/scripts/Installers/Install-PostgreSQL.ps1 @@ -10,17 +10,8 @@ function Start-PostgreSQL { $pgbin=Join-path $PostgresPath "bin" $pgdata=Join-path $PostgresPath "data" $startPostgres=Join-path $pgbin "pg_ctl.exe" - $process = Start-Process -FilePath $startPostgres -ArgumentList ("-D", "$pgdata", "start") - $exitCode = $process.ExitCode - if ($exitCode -eq 0) - { - Write-Host -Object "PostgreSQL has been successfully started." - } - else - { - Write-Host -Object "PostgreSQL cannot be started. Exitcode: $exitCode" - exit $exitCode - } + Start-Process -FilePath $startPostgres -ArgumentList ("-D", "$pgdata", "start") + Write-Host "PostgreSQL has been successfully started." } function Ready-PostgreSQL { From 91f9f18cde13b7f0914748c16f063d99a65dae7a Mon Sep 17 00:00:00 2001 From: "Dariy.Nurgaleev" Date: Sat, 28 Mar 2020 02:10:11 +0700 Subject: [PATCH 03/26] added script to packar template. --- images/win/Windows2016-Azure.json | 6 ++++++ images/win/Windows2019-Azure.json | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/images/win/Windows2016-Azure.json b/images/win/Windows2016-Azure.json index e0bf37f50370..9f455aae866c 100644 --- a/images/win/Windows2016-Azure.json +++ b/images/win/Windows2016-Azure.json @@ -303,6 +303,12 @@ "scripts":[ "{{ template_dir }}/scripts/Installers/Install-7zip.ps1" ] + }, + { + "type": "powershell", + "scripts":[ + "{{ template_dir }}/scripts/Installers/Install-PostgreSQL.ps1" + ] }, { "type": "powershell", diff --git a/images/win/Windows2019-Azure.json b/images/win/Windows2019-Azure.json index c93f79e75642..e32840cfdcb3 100644 --- a/images/win/Windows2019-Azure.json +++ b/images/win/Windows2019-Azure.json @@ -553,6 +553,12 @@ "{{ template_dir }}/scripts/Installers/Install-Vcpkg.ps1" ] }, + { + "type": "powershell", + "scripts":[ + "{{ template_dir }}/scripts/Installers/Install-PostgreSQL.ps1" + ] + }, { "type": "powershell", "scripts":[ From 1cce8a77368a3ac957da0ce957eb2966c35d29b8 Mon Sep 17 00:00:00 2001 From: "Dariy.Nurgaleev" Date: Sat, 28 Mar 2020 02:16:00 +0700 Subject: [PATCH 04/26] changed postgresql.sh for ubuntu. --- images/linux/scripts/installers/postgresql.sh | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/images/linux/scripts/installers/postgresql.sh b/images/linux/scripts/installers/postgresql.sh index 9f2988a84920..d3ef11ff1dba 100644 --- a/images/linux/scripts/installers/postgresql.sh +++ b/images/linux/scripts/installers/postgresql.sh @@ -7,10 +7,22 @@ # Source the helpers for use with the script source $HELPER_SCRIPTS/document.sh +#Preparing repo for PostgreSQL 12. +wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - +echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" | tee /etc/apt/sources.list.d/pgdg.list + +echo "Install PostgreSQL" +apt update +apt install postgresql postgresql-client + echo "Install libpq-dev" apt-get install libpq-dev -echo "Install Postgresql Client" -apt-get install postgresql-client +#Verify that PostgreSQL is ready for accept incoming connections. +# exit codes: +# ready - 0 +# reject - 1 +# connection timeout - 2 +pg_isready DocumentInstalledItem "$(psql -V 2>&1 | cut -d ' ' -f 1,2,3)" \ No newline at end of file From 519d071d311866676b70cadf8d8b49a5ec09e53b Mon Sep 17 00:00:00 2001 From: "Dariy.Nurgaleev" Date: Mon, 30 Mar 2020 20:38:11 +0700 Subject: [PATCH 05/26] postgresql stop and disalbe services. --- images/linux/scripts/installers/postgresql.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/images/linux/scripts/installers/postgresql.sh b/images/linux/scripts/installers/postgresql.sh index d3ef11ff1dba..7c1c89cc007d 100644 --- a/images/linux/scripts/installers/postgresql.sh +++ b/images/linux/scripts/installers/postgresql.sh @@ -25,4 +25,8 @@ apt-get install libpq-dev # connection timeout - 2 pg_isready -DocumentInstalledItem "$(psql -V 2>&1 | cut -d ' ' -f 1,2,3)" \ No newline at end of file +DocumentInstalledItem "$(psql -V 2>&1 | cut -d ' ' -f 1,2,3)" + +# Disable postgresql.service +systemctl is-active --quiet postgresql.service && systemctl stop postgresql.service +systemctl disable postgresql.service \ No newline at end of file From c9a3f89d91abfb9e9b442e8100c063116470535c Mon Sep 17 00:00:00 2001 From: "Dariy.Nurgaleev" Date: Mon, 30 Mar 2020 20:39:39 +0700 Subject: [PATCH 06/26] change name of the functions --- images/win/scripts/Installers/Install-PostgreSQL.ps1 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/images/win/scripts/Installers/Install-PostgreSQL.ps1 b/images/win/scripts/Installers/Install-PostgreSQL.ps1 index 9515a845864d..c2fbc4a69655 100644 --- a/images/win/scripts/Installers/Install-PostgreSQL.ps1 +++ b/images/win/scripts/Installers/Install-PostgreSQL.ps1 @@ -14,7 +14,7 @@ function Start-PostgreSQL { Write-Host "PostgreSQL has been successfully started." } -function Ready-PostgreSQL { +function Validate-PostgreSQL { param( [String]$PostgresPath ) @@ -33,7 +33,7 @@ function Ready-PostgreSQL { } } -function Version-PostgreSQL { +function Get-PostgreSQLVersion { param( [String]$PostgresPath ) @@ -44,9 +44,9 @@ function Version-PostgreSQL { } $psqlDir=Install-PostgreSQL -$psqlVersion=Version-PostgreSQL -PostgresPath $psqlDir +$psqlVersion=Get-PostgreSQLVersion -PostgresPath $psqlDir Start-PostgreSQL -PostgresPath $psqlDir -Ready-PostgreSQL -PostgresPath $psqlDir +Validate-PostgreSQL -PostgresPath $psqlDir # Adding description of the software to Markdown From 53c2cad18f4aa915d783116255c13012e078256d Mon Sep 17 00:00:00 2001 From: "Dariy.Nurgaleev" Date: Mon, 30 Mar 2020 20:49:45 +0700 Subject: [PATCH 07/26] Stop postgreSQL after validation instead of start. --- images/win/scripts/Installers/Install-PostgreSQL.ps1 | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/images/win/scripts/Installers/Install-PostgreSQL.ps1 b/images/win/scripts/Installers/Install-PostgreSQL.ps1 index c2fbc4a69655..47a317831c27 100644 --- a/images/win/scripts/Installers/Install-PostgreSQL.ps1 +++ b/images/win/scripts/Installers/Install-PostgreSQL.ps1 @@ -10,7 +10,7 @@ function Start-PostgreSQL { $pgbin=Join-path $PostgresPath "bin" $pgdata=Join-path $PostgresPath "data" $startPostgres=Join-path $pgbin "pg_ctl.exe" - Start-Process -FilePath $startPostgres -ArgumentList ("-D", "$pgdata", "start") + Start-Process -FilePath $startPostgres -ArgumentList ("-D", "$pgdata", "stop") Write-Host "PostgreSQL has been successfully started." } @@ -45,9 +45,8 @@ function Get-PostgreSQLVersion { $psqlDir=Install-PostgreSQL $psqlVersion=Get-PostgreSQLVersion -PostgresPath $psqlDir -Start-PostgreSQL -PostgresPath $psqlDir Validate-PostgreSQL -PostgresPath $psqlDir - +Stop-PostgreSQL -PostgresPath $psqlDir # Adding description of the software to Markdown $SoftwareName = "PostgreSQL" From 5d0961fc97edf9e0def59428b233b410989b9fc0 Mon Sep 17 00:00:00 2001 From: "Dariy.Nurgaleev" Date: Tue, 31 Mar 2020 14:43:48 +0700 Subject: [PATCH 08/26] added validation and re-work installation prcoedur --- .../scripts/Installers/Install-PostgreSQL.ps1 | 62 +++---------------- .../Installers/Validate-PostgreSQL.ps1 | 56 +++++++++++++++++ 2 files changed, 63 insertions(+), 55 deletions(-) create mode 100644 images/win/scripts/Installers/Validate-PostgreSQL.ps1 diff --git a/images/win/scripts/Installers/Install-PostgreSQL.ps1 b/images/win/scripts/Installers/Install-PostgreSQL.ps1 index 47a317831c27..1224cbe4c202 100644 --- a/images/win/scripts/Installers/Install-PostgreSQL.ps1 +++ b/images/win/scripts/Installers/Install-PostgreSQL.ps1 @@ -1,58 +1,10 @@ -function Install-PostgreSQL { - $installPath= choco install postgresql | Select-String "Installed to" - return $installPath.Line.split("'")[1] -} +$ErrorActionPreference = "Stop" -function Start-PostgreSQL { - param( - [String]$PostgresPath - ) - $pgbin=Join-path $PostgresPath "bin" - $pgdata=Join-path $PostgresPath "data" - $startPostgres=Join-path $pgbin "pg_ctl.exe" - Start-Process -FilePath $startPostgres -ArgumentList ("-D", "$pgdata", "stop") - Write-Host "PostgreSQL has been successfully started." -} +Import-Module -Name ImageHelpers -function Validate-PostgreSQL { - param( - [String]$PostgresPath - ) - $pgbin=Join-path $PostgresPath "bin" - $pgisreadypath=Join-path $pgbin "pg_isready.exe" - $pgready = Start-Process -FilePath $pgisreadypath -Wait -PassThru - $exitCode = $pgready.ExitCode - if ($exitCode -eq 0) - { - Write-Host -Object "PostgreSQL has been successfully installed." - } - else - { - Write-Host -Object "PostgreSQL is not ready. Exitcode: $exitCode" - exit $exitCode - } -} +choco install postgresql -function Get-PostgreSQLVersion { - param( - [String]$PostgresPath - ) - $pgbin=Join-path $PostgresPath "bin" - $pgconfig=Join-path $pgbin "pg_config.exe" - $psqlversion=Start-Process -FilePath $pgconfig -ArgumentList ("--version")-Wait -PassThru - return $psqlversion -} - -$psqlDir=Install-PostgreSQL -$psqlVersion=Get-PostgreSQLVersion -PostgresPath $psqlDir -Validate-PostgreSQL -PostgresPath $psqlDir -Stop-PostgreSQL -PostgresPath $psqlDir - -# Adding description of the software to Markdown -$SoftwareName = "PostgreSQL" -$Description = @" -_Version:_ $psqlVersion
-_Default Path:_ $psqlDir -"@ - -Add-SoftwareDetailsToMarkdown -SoftwareName $SoftwareName -DescriptionMarkdown $Description \ No newline at end of file +$paths=(Get-CimInstance Win32_Service -Filter "Name LIKE 'postgresql-%'").PathName +$pgbin=$paths.split('"')[1].replace("\pg_ctl.exe", "") +Add-MachinePathItem $pgbin +$env:Path = Get-MachinePath diff --git a/images/win/scripts/Installers/Validate-PostgreSQL.ps1 b/images/win/scripts/Installers/Validate-PostgreSQL.ps1 new file mode 100644 index 000000000000..65720ea13809 --- /dev/null +++ b/images/win/scripts/Installers/Validate-PostgreSQL.ps1 @@ -0,0 +1,56 @@ +function Stop-PostgreSQL { + param( + [String]$PostgresPath + ) + $pgbin=Join-path $PostgresPath "bin" + $pgdata=Join-path $PostgresPath "data" + $startPostgres=Join-path $pgbin "pg_ctl.exe" + Start-Process -FilePath $startPostgres -ArgumentList ("-D", "$pgdata", "stop") + Write-Host "PostgreSQL has been successfully started." +} + +function Validate-PostgreSQL { + param( + [String]$PostgresPath + ) + $pgbin=Join-path $PostgresPath "bin" + $pgisreadypath=Join-path $pgbin "pg_isready.exe" + $pgready = Start-Process -FilePath $pgisreadypath -Wait -PassThru + $exitCode = $pgready.ExitCode + if ($exitCode -eq 0) + { + Write-Host -Object "PostgreSQL has been successfully installed." + } + else + { + Write-Host -Object "PostgreSQL is not ready. Exitcode: $exitCode" + exit $exitCode + } +} + +function Get-PostgreSQLVersion { + param( + [String]$PostgresPath + ) + $pgbin=Join-path $PostgresPath "bin" + $pgconfig=Join-path $pgbin "pg_config.exe" + $psqlversion=Start-Process -FilePath $pgconfig -ArgumentList ("--version")-Wait -PassThru + return $psqlversion +} + +$paths=(Get-CimInstance Win32_Service -Filter "Name LIKE 'postgresql-%'").PathName +$pgroot=$paths.split('"')[1].replace("\bin\pg_ctl.exe", "") +$psqlVersion=Get-PostgreSQLVersion -PostgresPath $pgroot +Validate-PostgreSQL -PostgresPath $pgroot + +# Adding description of the software to Markdown +$SoftwareName = "PostgreSQL" +$Description = @" +_Version:_ $psqlVersion
+_Default Path:_ $pgroot +"@ + +Add-SoftwareDetailsToMarkdown -SoftwareName $SoftwareName -DescriptionMarkdown $Description + +#Stop PostgreSQL service +Stop-PostgreSQL -PostgresPath $pgroot \ No newline at end of file From 46bf4384fd0354d61152374cc089795fcbe72edc Mon Sep 17 00:00:00 2001 From: "Dariy.Nurgaleev" Date: Tue, 31 Mar 2020 21:42:49 +0700 Subject: [PATCH 09/26] remove redundunt code from psql --- .../scripts/Installers/Install-PostgreSQL.ps1 | 2 +- .../Installers/Validate-PostgreSQL.ps1 | 32 ++++++------------- 2 files changed, 10 insertions(+), 24 deletions(-) diff --git a/images/win/scripts/Installers/Install-PostgreSQL.ps1 b/images/win/scripts/Installers/Install-PostgreSQL.ps1 index 1224cbe4c202..7a1289559bab 100644 --- a/images/win/scripts/Installers/Install-PostgreSQL.ps1 +++ b/images/win/scripts/Installers/Install-PostgreSQL.ps1 @@ -7,4 +7,4 @@ choco install postgresql $paths=(Get-CimInstance Win32_Service -Filter "Name LIKE 'postgresql-%'").PathName $pgbin=$paths.split('"')[1].replace("\pg_ctl.exe", "") Add-MachinePathItem $pgbin -$env:Path = Get-MachinePath +$env:Path = Get-MachinePath \ No newline at end of file diff --git a/images/win/scripts/Installers/Validate-PostgreSQL.ps1 b/images/win/scripts/Installers/Validate-PostgreSQL.ps1 index 65720ea13809..c3f37d8a7c9b 100644 --- a/images/win/scripts/Installers/Validate-PostgreSQL.ps1 +++ b/images/win/scripts/Installers/Validate-PostgreSQL.ps1 @@ -2,20 +2,12 @@ function Stop-PostgreSQL { param( [String]$PostgresPath ) - $pgbin=Join-path $PostgresPath "bin" $pgdata=Join-path $PostgresPath "data" - $startPostgres=Join-path $pgbin "pg_ctl.exe" - Start-Process -FilePath $startPostgres -ArgumentList ("-D", "$pgdata", "stop") + Start-Process -FilePath pg_ctl -ArgumentList ("-D", "$pgdata", "stop") Write-Host "PostgreSQL has been successfully started." } - function Validate-PostgreSQL { - param( - [String]$PostgresPath - ) - $pgbin=Join-path $PostgresPath "bin" - $pgisreadypath=Join-path $pgbin "pg_isready.exe" - $pgready = Start-Process -FilePath $pgisreadypath -Wait -PassThru + $pgready = Start-Process -FilePath pg_isready -Wait -PassThru $exitCode = $pgready.ExitCode if ($exitCode -eq 0) { @@ -28,19 +20,12 @@ function Validate-PostgreSQL { } } -function Get-PostgreSQLVersion { - param( - [String]$PostgresPath - ) - $pgbin=Join-path $PostgresPath "bin" - $pgconfig=Join-path $pgbin "pg_config.exe" - $psqlversion=Start-Process -FilePath $pgconfig -ArgumentList ("--version")-Wait -PassThru - return $psqlversion -} - $paths=(Get-CimInstance Win32_Service -Filter "Name LIKE 'postgresql-%'").PathName +$pgservice=(Get-CimInstance Win32_Service -Filter "Name LIKE 'postgresql-%'").Name +$pgbin=$paths.split('"')[1].replace("\pg_ctl.exe", "") +$env:Path +=";$pgbin" $pgroot=$paths.split('"')[1].replace("\bin\pg_ctl.exe", "") -$psqlVersion=Get-PostgreSQLVersion -PostgresPath $pgroot +$psqlVersion=pg_config --version | Out-String Validate-PostgreSQL -PostgresPath $pgroot # Adding description of the software to Markdown @@ -52,5 +37,6 @@ _Default Path:_ $pgroot Add-SoftwareDetailsToMarkdown -SoftwareName $SoftwareName -DescriptionMarkdown $Description -#Stop PostgreSQL service -Stop-PostgreSQL -PostgresPath $pgroot \ No newline at end of file +#Stop and disable PostgreSQL service +Stop-PostgreSQL -PostgresPath $pgroot +Set-Service $pgservice -StartupType Disabled \ No newline at end of file From d7b6fb4f5e468ae336480a4a261a5346e8bdb9a2 Mon Sep 17 00:00:00 2001 From: "Dariy.Nurgaleev" Date: Tue, 31 Mar 2020 21:44:23 +0700 Subject: [PATCH 10/26] correct intendation --- .../scripts/Installers/Validate-PostgreSQL.ps1 | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/images/win/scripts/Installers/Validate-PostgreSQL.ps1 b/images/win/scripts/Installers/Validate-PostgreSQL.ps1 index c3f37d8a7c9b..0533dc35d6bb 100644 --- a/images/win/scripts/Installers/Validate-PostgreSQL.ps1 +++ b/images/win/scripts/Installers/Validate-PostgreSQL.ps1 @@ -9,15 +9,15 @@ function Stop-PostgreSQL { function Validate-PostgreSQL { $pgready = Start-Process -FilePath pg_isready -Wait -PassThru $exitCode = $pgready.ExitCode - if ($exitCode -eq 0) - { - Write-Host -Object "PostgreSQL has been successfully installed." - } - else - { - Write-Host -Object "PostgreSQL is not ready. Exitcode: $exitCode" - exit $exitCode - } + if ($exitCode -eq 0) + { + Write-Host -Object "PostgreSQL has been successfully installed." + } + else + { + Write-Host -Object "PostgreSQL is not ready. Exitcode: $exitCode" + exit $exitCode + } } $paths=(Get-CimInstance Win32_Service -Filter "Name LIKE 'postgresql-%'").PathName From 210b56a9593ecbc422a9353273592d0b88cd0927 Mon Sep 17 00:00:00 2001 From: "Dariy.Nurgaleev" Date: Tue, 31 Mar 2020 21:45:31 +0700 Subject: [PATCH 11/26] path to Path --- images/win/scripts/Installers/Validate-PostgreSQL.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/images/win/scripts/Installers/Validate-PostgreSQL.ps1 b/images/win/scripts/Installers/Validate-PostgreSQL.ps1 index 0533dc35d6bb..5194c49dbb9a 100644 --- a/images/win/scripts/Installers/Validate-PostgreSQL.ps1 +++ b/images/win/scripts/Installers/Validate-PostgreSQL.ps1 @@ -2,7 +2,7 @@ function Stop-PostgreSQL { param( [String]$PostgresPath ) - $pgdata=Join-path $PostgresPath "data" + $pgdata=Join-Path $PostgresPath "data" Start-Process -FilePath pg_ctl -ArgumentList ("-D", "$pgdata", "stop") Write-Host "PostgreSQL has been successfully started." } From c2ed09da163ab4bdac6bd5fb2423ab175147793a Mon Sep 17 00:00:00 2001 From: "Dariy.Nurgaleev" Date: Tue, 31 Mar 2020 21:50:49 +0700 Subject: [PATCH 12/26] added PostgreSQL validation procedure. --- images/win/Windows2016-Azure.json | 6 ++++++ images/win/Windows2019-Azure.json | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/images/win/Windows2016-Azure.json b/images/win/Windows2016-Azure.json index 9f455aae866c..a771ea30b0b5 100644 --- a/images/win/Windows2016-Azure.json +++ b/images/win/Windows2016-Azure.json @@ -469,6 +469,12 @@ "{{ template_dir }}/scripts/Installers/Install-MysqlCli.ps1" ] }, + { + "type": "powershell", + "scripts":[ + "{{ template_dir }}/scripts/Installers/Validate-PostgreSQL.ps1" + ] + }, { "type": "powershell", "scripts":[ diff --git a/images/win/Windows2019-Azure.json b/images/win/Windows2019-Azure.json index e32840cfdcb3..b2d2485a5909 100644 --- a/images/win/Windows2019-Azure.json +++ b/images/win/Windows2019-Azure.json @@ -741,6 +741,12 @@ "{{ template_dir }}/scripts/Installers/Validate-MysqlCli.ps1" ] }, + { + "type": "powershell", + "scripts":[ + "{{ template_dir }}/scripts/Installers/Validate-PostgreSQL.ps1" + ] + }, { "type": "powershell", "scripts":[ From 430a51e1613fab6be86e25ada122cec60109b6e1 Mon Sep 17 00:00:00 2001 From: "Dariy.Nurgaleev" Date: Tue, 31 Mar 2020 22:07:12 +0700 Subject: [PATCH 13/26] Removed useless last line. --- images/win/scripts/Installers/Install-PostgreSQL.ps1 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/images/win/scripts/Installers/Install-PostgreSQL.ps1 b/images/win/scripts/Installers/Install-PostgreSQL.ps1 index 7a1289559bab..7be3cded8dcb 100644 --- a/images/win/scripts/Installers/Install-PostgreSQL.ps1 +++ b/images/win/scripts/Installers/Install-PostgreSQL.ps1 @@ -2,9 +2,12 @@ $ErrorActionPreference = "Stop" Import-Module -Name ImageHelpers +#Install latest PostgreSQL choco install postgresql +#Get Path to pg_ctl.exe $paths=(Get-CimInstance Win32_Service -Filter "Name LIKE 'postgresql-%'").PathName +#Parse output of command above to obtain pure path $pgbin=$paths.split('"')[1].replace("\pg_ctl.exe", "") -Add-MachinePathItem $pgbin -$env:Path = Get-MachinePath \ No newline at end of file +#Added PostgreSQL bin path into PATH variable. +Add-MachinePathItem $pgbin \ No newline at end of file From fbeafca5e44964002cb1c29771abf46c76e4ce37 Mon Sep 17 00:00:00 2001 From: "Dariy.Nurgaleev" Date: Tue, 31 Mar 2020 22:21:41 +0700 Subject: [PATCH 14/26] redundunt parameter passed in function call. --- images/win/scripts/Installers/Validate-PostgreSQL.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/images/win/scripts/Installers/Validate-PostgreSQL.ps1 b/images/win/scripts/Installers/Validate-PostgreSQL.ps1 index 5194c49dbb9a..5ff192886f0e 100644 --- a/images/win/scripts/Installers/Validate-PostgreSQL.ps1 +++ b/images/win/scripts/Installers/Validate-PostgreSQL.ps1 @@ -26,7 +26,7 @@ $pgbin=$paths.split('"')[1].replace("\pg_ctl.exe", "") $env:Path +=";$pgbin" $pgroot=$paths.split('"')[1].replace("\bin\pg_ctl.exe", "") $psqlVersion=pg_config --version | Out-String -Validate-PostgreSQL -PostgresPath $pgroot +Validate-PostgreSQL # Adding description of the software to Markdown $SoftwareName = "PostgreSQL" From 501bf0d3ca69ce31f1890578617f722b5abd8d63 Mon Sep 17 00:00:00 2001 From: "Dariy.Nurgaleev" Date: Tue, 31 Mar 2020 22:23:43 +0700 Subject: [PATCH 15/26] removed repeated part of code. --- images/win/scripts/Installers/Validate-PostgreSQL.ps1 | 2 -- 1 file changed, 2 deletions(-) diff --git a/images/win/scripts/Installers/Validate-PostgreSQL.ps1 b/images/win/scripts/Installers/Validate-PostgreSQL.ps1 index 5ff192886f0e..a6bd00b82ad5 100644 --- a/images/win/scripts/Installers/Validate-PostgreSQL.ps1 +++ b/images/win/scripts/Installers/Validate-PostgreSQL.ps1 @@ -22,8 +22,6 @@ function Validate-PostgreSQL { $paths=(Get-CimInstance Win32_Service -Filter "Name LIKE 'postgresql-%'").PathName $pgservice=(Get-CimInstance Win32_Service -Filter "Name LIKE 'postgresql-%'").Name -$pgbin=$paths.split('"')[1].replace("\pg_ctl.exe", "") -$env:Path +=";$pgbin" $pgroot=$paths.split('"')[1].replace("\bin\pg_ctl.exe", "") $psqlVersion=pg_config --version | Out-String Validate-PostgreSQL From 4b7b0d10b5b0c9a31b57e0124fff4f24d3b2dda0 Mon Sep 17 00:00:00 2001 From: "Dariy.Nurgaleev" Date: Tue, 31 Mar 2020 22:39:54 +0700 Subject: [PATCH 16/26] removed Stop function since it was useless. --- images/win/scripts/Installers/Validate-PostgreSQL.ps1 | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/images/win/scripts/Installers/Validate-PostgreSQL.ps1 b/images/win/scripts/Installers/Validate-PostgreSQL.ps1 index a6bd00b82ad5..83864f3cf64d 100644 --- a/images/win/scripts/Installers/Validate-PostgreSQL.ps1 +++ b/images/win/scripts/Installers/Validate-PostgreSQL.ps1 @@ -1,11 +1,3 @@ -function Stop-PostgreSQL { - param( - [String]$PostgresPath - ) - $pgdata=Join-Path $PostgresPath "data" - Start-Process -FilePath pg_ctl -ArgumentList ("-D", "$pgdata", "stop") - Write-Host "PostgreSQL has been successfully started." -} function Validate-PostgreSQL { $pgready = Start-Process -FilePath pg_isready -Wait -PassThru $exitCode = $pgready.ExitCode @@ -36,5 +28,5 @@ _Default Path:_ $pgroot Add-SoftwareDetailsToMarkdown -SoftwareName $SoftwareName -DescriptionMarkdown $Description #Stop and disable PostgreSQL service -Stop-PostgreSQL -PostgresPath $pgroot +Stop-Service -Name $pgservice Set-Service $pgservice -StartupType Disabled \ No newline at end of file From ec8752f3125ca8c52e9383aff5c6776986286b4c Mon Sep 17 00:00:00 2001 From: Dariy Nurgaleev <50947177+Darleev@users.noreply.github.com> Date: Fri, 10 Apr 2020 15:49:42 +0700 Subject: [PATCH 17/26] spaces --- images/win/scripts/Installers/Install-PostgreSQL.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/images/win/scripts/Installers/Install-PostgreSQL.ps1 b/images/win/scripts/Installers/Install-PostgreSQL.ps1 index 7be3cded8dcb..95ab975cc5b2 100644 --- a/images/win/scripts/Installers/Install-PostgreSQL.ps1 +++ b/images/win/scripts/Installers/Install-PostgreSQL.ps1 @@ -6,8 +6,8 @@ Import-Module -Name ImageHelpers choco install postgresql #Get Path to pg_ctl.exe -$paths=(Get-CimInstance Win32_Service -Filter "Name LIKE 'postgresql-%'").PathName +$paths = (Get-CimInstance Win32_Service -Filter "Name LIKE 'postgresql-%'").PathName #Parse output of command above to obtain pure path -$pgbin=$paths.split('"')[1].replace("\pg_ctl.exe", "") +$pgbin = $paths.split('"')[1].replace("\pg_ctl.exe", "") #Added PostgreSQL bin path into PATH variable. -Add-MachinePathItem $pgbin \ No newline at end of file +Add-MachinePathItem $pgbin From f7658558b485933a23c1e351d645126a1a458006 Mon Sep 17 00:00:00 2001 From: Dariy Nurgaleev <50947177+Darleev@users.noreply.github.com> Date: Fri, 10 Apr 2020 15:50:24 +0700 Subject: [PATCH 18/26] spaces = --- images/win/scripts/Installers/Validate-PostgreSQL.ps1 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/images/win/scripts/Installers/Validate-PostgreSQL.ps1 b/images/win/scripts/Installers/Validate-PostgreSQL.ps1 index 83864f3cf64d..985594197ec0 100644 --- a/images/win/scripts/Installers/Validate-PostgreSQL.ps1 +++ b/images/win/scripts/Installers/Validate-PostgreSQL.ps1 @@ -12,10 +12,10 @@ function Validate-PostgreSQL { } } -$paths=(Get-CimInstance Win32_Service -Filter "Name LIKE 'postgresql-%'").PathName -$pgservice=(Get-CimInstance Win32_Service -Filter "Name LIKE 'postgresql-%'").Name -$pgroot=$paths.split('"')[1].replace("\bin\pg_ctl.exe", "") -$psqlVersion=pg_config --version | Out-String +$paths = (Get-CimInstance Win32_Service -Filter "Name LIKE 'postgresql-%'").PathName +$pgservice = (Get-CimInstance Win32_Service -Filter "Name LIKE 'postgresql-%'").Name +$pgroot = $paths.split('"')[1].replace("\bin\pg_ctl.exe", "") +$psqlVersion = pg_config --version | Out-String Validate-PostgreSQL # Adding description of the software to Markdown @@ -29,4 +29,4 @@ Add-SoftwareDetailsToMarkdown -SoftwareName $SoftwareName -DescriptionMarkdown $ #Stop and disable PostgreSQL service Stop-Service -Name $pgservice -Set-Service $pgservice -StartupType Disabled \ No newline at end of file +Set-Service $pgservice -StartupType Disabled From 32eac626612669269ec545133be5dba330e640d5 Mon Sep 17 00:00:00 2001 From: Dariy Nurgaleev <50947177+Darleev@users.noreply.github.com> Date: Thu, 16 Apr 2020 04:42:39 +0700 Subject: [PATCH 19/26] Update Windows2019-Azure.json --- images/win/Windows2019-Azure.json | 39 +++++++++++++++++-------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/images/win/Windows2019-Azure.json b/images/win/Windows2019-Azure.json index 913dc1762df2..cfb8b5cd8d1c 100644 --- a/images/win/Windows2019-Azure.json +++ b/images/win/Windows2019-Azure.json @@ -14,7 +14,7 @@ "virtual_network_resource_group_name": "{{env `VNET_RESOURCE_GROUP`}}", "virtual_network_subnet_name": "{{env `VNET_SUBNET`}}", "private_virtual_network_with_public_ip": "{{env `PRIVATE_VIRTUAL_NETWORK_WITH_PUBLIC_IP`}}", - "vm_size": "Standard_DS4_v2", + "vm_size": "Standard_D4_v2", "run_scan_antivirus": "false", "root_folder": "C:", @@ -219,7 +219,8 @@ "type": "powershell", "scripts":[ "{{ template_dir }}/scripts/Installers/Install-ServiceFabricSDK.ps1" - ] + ], + "execution_policy": "remotesigned" }, { "type": "windows-restart", @@ -450,14 +451,6 @@ "{{ template_dir }}/scripts/Installers/Install-MysqlCli.ps1" ] }, - { - "type": "powershell", - "elevated_user": "SYSTEM", - "elevated_password": "", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Install-SQLExpress.ps1" - ] - }, { "type": "powershell", "scripts":[ @@ -591,6 +584,18 @@ "{{ template_dir }}/scripts/Installers/Install-Bazel.ps1" ] }, + { + "type": "powershell", + "scripts":[ + "{{ template_dir }}/scripts/Installers/Install-AliyunCli.ps1" + ] + }, + { + "type": "powershell", + "scripts":[ + "{{ template_dir }}/scripts/Installers/Install-RootCA.ps1" + ] + }, { "type": "windows-restart", "restart_timeout": "10m" @@ -761,12 +766,6 @@ "{{ template_dir }}/scripts/Installers/Validate-PostgreSQL.ps1" ] }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-SQLExpress.ps1" - ] - }, { "type": "powershell", "scripts":[ @@ -881,6 +880,12 @@ "{{ template_dir }}/scripts/Installers/Validate-Bazel.ps1" ] }, + { + "type": "powershell", + "scripts":[ + "{{ template_dir }}/scripts/Installers/Validate-AliyunCli.ps1" + ] + }, { "type": "file", "source": "C:\\InstalledSoftware.md", @@ -921,4 +926,4 @@ ] } ] -} \ No newline at end of file +} From 1a6efd367d7127e99003ffff160382f0788995c1 Mon Sep 17 00:00:00 2001 From: "Dariy.Nurgaleev" Date: Thu, 16 Apr 2020 05:08:59 +0700 Subject: [PATCH 20/26] resolve confictls --- images/win/Windows2019-Azure.json | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/images/win/Windows2019-Azure.json b/images/win/Windows2019-Azure.json index cfb8b5cd8d1c..e66147fca01c 100644 --- a/images/win/Windows2019-Azure.json +++ b/images/win/Windows2019-Azure.json @@ -560,12 +560,6 @@ "{{ template_dir }}/scripts/Installers/Install-Vcpkg.ps1" ] }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Install-PostgreSQL.ps1" - ] - }, { "type": "powershell", "scripts":[ @@ -760,12 +754,6 @@ "{{ template_dir }}/scripts/Installers/Validate-MysqlCli.ps1" ] }, - { - "type": "powershell", - "scripts":[ - "{{ template_dir }}/scripts/Installers/Validate-PostgreSQL.ps1" - ] - }, { "type": "powershell", "scripts":[ @@ -926,4 +914,4 @@ ] } ] -} +} \ No newline at end of file From 32981cdc0fb4e666d04fbacc6e44fccf96d1a199 Mon Sep 17 00:00:00 2001 From: "Dariy.Nurgaleev" Date: Thu, 16 Apr 2020 05:11:11 +0700 Subject: [PATCH 21/26] added validate and install postgresql --- images/win/Windows2019-Azure.json | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/images/win/Windows2019-Azure.json b/images/win/Windows2019-Azure.json index e66147fca01c..de2b4cffd87b 100644 --- a/images/win/Windows2019-Azure.json +++ b/images/win/Windows2019-Azure.json @@ -560,6 +560,12 @@ "{{ template_dir }}/scripts/Installers/Install-Vcpkg.ps1" ] }, + { + "type": "powershell", + "scripts":[ + "{{ template_dir }}/scripts/Installers/Install-PostgreSQL.ps1" + ] + }, { "type": "powershell", "scripts":[ @@ -844,6 +850,12 @@ "{{ template_dir }}/scripts/Installers/Validate-Vcpkg.ps1" ] }, + { + "type": "powershell", + "scripts":[ + "{{ template_dir }}/scripts/Installers/Validate-PostgreSQL.ps1" + ] + }, { "type": "powershell", "scripts":[ From 79561ecc5f3895e8980e6e654aff52c64a2380b3 Mon Sep 17 00:00:00 2001 From: "Dariy.Nurgaleev" Date: Fri, 17 Apr 2020 00:12:04 +0700 Subject: [PATCH 22/26] added password to choco install and variables. --- images/win/scripts/Installers/Install-PostgreSQL.ps1 | 8 +++++++- images/win/scripts/Installers/Validate-PostgreSQL.ps1 | 5 ++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/images/win/scripts/Installers/Install-PostgreSQL.ps1 b/images/win/scripts/Installers/Install-PostgreSQL.ps1 index 95ab975cc5b2..cf7d6ee92b03 100644 --- a/images/win/scripts/Installers/Install-PostgreSQL.ps1 +++ b/images/win/scripts/Installers/Install-PostgreSQL.ps1 @@ -2,8 +2,14 @@ $ErrorActionPreference = "Stop" Import-Module -Name ImageHelpers +$PGUSER="postgres" +$PGPASSWORD="root" +[Environment]::SetEnvironmentVariable + ($PGPASSWORD, $env:PGPASSWORD, [System.EnvironmentVariableTarget]::Machine) +[Environment]::SetEnvironmentVariable + ($PGUSER, $env:PGUSER, [System.EnvironmentVariableTarget]::Machine) #Install latest PostgreSQL -choco install postgresql +choco install postgresql /Password $PGPASSWORD #Get Path to pg_ctl.exe $paths = (Get-CimInstance Win32_Service -Filter "Name LIKE 'postgresql-%'").PathName diff --git a/images/win/scripts/Installers/Validate-PostgreSQL.ps1 b/images/win/scripts/Installers/Validate-PostgreSQL.ps1 index 985594197ec0..bfd2f0f057dd 100644 --- a/images/win/scripts/Installers/Validate-PostgreSQL.ps1 +++ b/images/win/scripts/Installers/Validate-PostgreSQL.ps1 @@ -1,3 +1,4 @@ +$PGUSER="postgres" function Validate-PostgreSQL { $pgready = Start-Process -FilePath pg_isready -Wait -PassThru $exitCode = $pgready.ExitCode @@ -22,7 +23,9 @@ Validate-PostgreSQL $SoftwareName = "PostgreSQL" $Description = @" _Version:_ $psqlVersion
-_Default Path:_ $pgroot +_Default Path:_ $pgroot
+_User:_ $env:PGUSER
+_Password:_ $env:PGPASSWORD "@ Add-SoftwareDetailsToMarkdown -SoftwareName $SoftwareName -DescriptionMarkdown $Description From e393e3411b99fc129b1fd1942611872700cca4f0 Mon Sep 17 00:00:00 2001 From: "Dariy.Nurgaleev" Date: Tue, 21 Apr 2020 01:27:09 +0700 Subject: [PATCH 23/26] add new system variables. --- .../scripts/Installers/Install-PostgreSQL.ps1 | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/images/win/scripts/Installers/Install-PostgreSQL.ps1 b/images/win/scripts/Installers/Install-PostgreSQL.ps1 index cf7d6ee92b03..801670a0120a 100644 --- a/images/win/scripts/Installers/Install-PostgreSQL.ps1 +++ b/images/win/scripts/Installers/Install-PostgreSQL.ps1 @@ -2,14 +2,16 @@ $ErrorActionPreference = "Stop" Import-Module -Name ImageHelpers -$PGUSER="postgres" -$PGPASSWORD="root" -[Environment]::SetEnvironmentVariable - ($PGPASSWORD, $env:PGPASSWORD, [System.EnvironmentVariableTarget]::Machine) -[Environment]::SetEnvironmentVariable - ($PGUSER, $env:PGUSER, [System.EnvironmentVariableTarget]::Machine) +#Define user and password for PostgreSQL database +$postgresusr="postgres" +$postgrespwd="root" + +#Prepare environment variable for validation +Set-SystemVariable -SystemVariable PGUSER -Value $postgresusr +Set-SystemVariable -SystemVariable PGPASSWORD -Value $postgrespwd #Install latest PostgreSQL -choco install postgresql /Password $PGPASSWORD + +choco install postgresql /Password $postgrespwd #Get Path to pg_ctl.exe $paths = (Get-CimInstance Win32_Service -Filter "Name LIKE 'postgresql-%'").PathName From f3193cc675ac681b154480573adefaa65358bf61 Mon Sep 17 00:00:00 2001 From: Darii Nurgaleev Date: Tue, 21 Apr 2020 15:04:17 +0700 Subject: [PATCH 24/26] added --params flag --- images/win/scripts/Installers/Install-PostgreSQL.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/images/win/scripts/Installers/Install-PostgreSQL.ps1 b/images/win/scripts/Installers/Install-PostgreSQL.ps1 index 801670a0120a..1b4c8928018b 100644 --- a/images/win/scripts/Installers/Install-PostgreSQL.ps1 +++ b/images/win/scripts/Installers/Install-PostgreSQL.ps1 @@ -11,7 +11,7 @@ Set-SystemVariable -SystemVariable PGUSER -Value $postgresusr Set-SystemVariable -SystemVariable PGPASSWORD -Value $postgrespwd #Install latest PostgreSQL -choco install postgresql /Password $postgrespwd +choco install postgresql --params '/Password:$postgrespwd' #Get Path to pg_ctl.exe $paths = (Get-CimInstance Win32_Service -Filter "Name LIKE 'postgresql-%'").PathName From 73b520f371095f801a63cf2c31e154d7da9cbea3 Mon Sep 17 00:00:00 2001 From: Darii Nurgaleev Date: Wed, 22 Apr 2020 16:34:55 +0700 Subject: [PATCH 25/26] added correct quotas --- images/win/scripts/Installers/Install-PostgreSQL.ps1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/images/win/scripts/Installers/Install-PostgreSQL.ps1 b/images/win/scripts/Installers/Install-PostgreSQL.ps1 index 1b4c8928018b..320c1d3869f3 100644 --- a/images/win/scripts/Installers/Install-PostgreSQL.ps1 +++ b/images/win/scripts/Installers/Install-PostgreSQL.ps1 @@ -11,7 +11,7 @@ Set-SystemVariable -SystemVariable PGUSER -Value $postgresusr Set-SystemVariable -SystemVariable PGPASSWORD -Value $postgrespwd #Install latest PostgreSQL -choco install postgresql --params '/Password:$postgrespwd' +cinst postgresql --params "/Password:$env:PGPASSWORD" --params-global #Get Path to pg_ctl.exe $paths = (Get-CimInstance Win32_Service -Filter "Name LIKE 'postgresql-%'").PathName @@ -19,3 +19,4 @@ $paths = (Get-CimInstance Win32_Service -Filter "Name LIKE 'postgresql-%'").Path $pgbin = $paths.split('"')[1].replace("\pg_ctl.exe", "") #Added PostgreSQL bin path into PATH variable. Add-MachinePathItem $pgbin + From 344a76c9fc1038834a9ac046decb68cc0d0f95b1 Mon Sep 17 00:00:00 2001 From: Darii Nurgaleev Date: Wed, 22 Apr 2020 16:36:05 +0700 Subject: [PATCH 26/26] added logging for PostgreSQL install --- images/win/scripts/Installers/Install-PostgreSQL.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/images/win/scripts/Installers/Install-PostgreSQL.ps1 b/images/win/scripts/Installers/Install-PostgreSQL.ps1 index 320c1d3869f3..2e6bc373d78c 100644 --- a/images/win/scripts/Installers/Install-PostgreSQL.ps1 +++ b/images/win/scripts/Installers/Install-PostgreSQL.ps1 @@ -11,7 +11,7 @@ Set-SystemVariable -SystemVariable PGUSER -Value $postgresusr Set-SystemVariable -SystemVariable PGPASSWORD -Value $postgrespwd #Install latest PostgreSQL -cinst postgresql --params "/Password:$env:PGPASSWORD" --params-global +cinst postgresql --params "/Password:$postgrespwd" --params-global --debug --verbose #Get Path to pg_ctl.exe $paths = (Get-CimInstance Win32_Service -Filter "Name LIKE 'postgresql-%'").PathName