Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PostgreSQL install on Ubuntu/Windows. #636

Merged
merged 31 commits into from
Jun 2, 2020
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
8064611
added windows installation script for postgresql
Mar 27, 2020
88a0923
removed if from Start-PostreSQL
Mar 27, 2020
91f9f18
added script to packar template.
Mar 27, 2020
1cce8a7
changed postgresql.sh for ubuntu.
Mar 27, 2020
519d071
postgresql stop and disalbe services.
Mar 30, 2020
c9a3f89
change name of the functions
Mar 30, 2020
53c2cad
Stop postgreSQL after validation instead of start.
Mar 30, 2020
5d0961f
added validation and re-work installation prcoedur
Mar 31, 2020
46bf438
remove redundunt code from psql
Mar 31, 2020
d7b6fb4
correct intendation
Mar 31, 2020
210b56a
path to Path
Mar 31, 2020
c2ed09d
added PostgreSQL validation procedure.
Mar 31, 2020
430a51e
Removed useless last line.
Mar 31, 2020
fbeafca
redundunt parameter passed in function call.
Mar 31, 2020
501bf0d
removed repeated part of code.
Mar 31, 2020
4b7b0d1
removed Stop function since it was useless.
Mar 31, 2020
2ed9586
Merge branch 'master' into v-danurg/postgresql_install
Mar 31, 2020
ec8752f
spaces
Darleev Apr 10, 2020
f765855
spaces =
Darleev Apr 10, 2020
32eac62
Update Windows2019-Azure.json
Darleev Apr 15, 2020
9149a5d
Merge branch 'master' into v-danurg/postgresql_install
Apr 15, 2020
1a6efd3
resolve confictls
Apr 15, 2020
32981cd
added validate and install postgresql
Apr 15, 2020
79561ec
added password to choco install and variables.
Apr 16, 2020
ed187d9
Merge remote-tracking branch 'upstream/master' into v-danurg/postgres…
Apr 17, 2020
e393e34
add new system variables.
Apr 20, 2020
f3193cc
added --params flag
Darleev Apr 21, 2020
73b520f
added correct quotas
Darleev Apr 22, 2020
344a76c
added logging for PostgreSQL install
Darleev Apr 22, 2020
a9e8af1
Merge remote-tracking branch 'upstream/master' into v-danurg/postgres…
Darleev Apr 27, 2020
7b84230
Merge remote-tracking branch 'upstream/master' into v-danurg/postgres…
Darleev Jun 1, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions images/linux/scripts/installers/postgresql.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,26 @@
# 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
Darleev marked this conversation as resolved.
Show resolved Hide resolved

DocumentInstalledItem "$(psql -V 2>&1 | cut -d ' ' -f 1,2,3)"

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
12 changes: 12 additions & 0 deletions images/win/Windows2016-Azure.json
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,12 @@
"scripts":[
"{{ template_dir }}/scripts/Installers/Install-7zip.ps1"
]
},
{
"type": "powershell",
Darleev marked this conversation as resolved.
Show resolved Hide resolved
"scripts":[
"{{ template_dir }}/scripts/Installers/Install-PostgreSQL.ps1"
]
},
{
"type": "powershell",
Expand Down Expand Up @@ -476,6 +482,12 @@
"{{ template_dir }}/scripts/Installers/Install-MysqlCli.ps1"
]
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Validate-PostgreSQL.ps1"
]
},
{
"type": "powershell",
"scripts":[
Expand Down
12 changes: 12 additions & 0 deletions images/win/Windows2019-Azure.json
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,12 @@
"{{ template_dir }}/scripts/Installers/Install-Vcpkg.ps1"
]
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Install-PostgreSQL.ps1"
]
},
{
"type": "powershell",
"scripts":[
Expand Down Expand Up @@ -844,6 +850,12 @@
"{{ template_dir }}/scripts/Installers/Validate-Vcpkg.ps1"
]
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Validate-PostgreSQL.ps1"
]
},
{
"type": "powershell",
"scripts":[
Expand Down
13 changes: 13 additions & 0 deletions images/win/scripts/Installers/Install-PostgreSQL.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
$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", "")
#Added PostgreSQL bin path into PATH variable.
Add-MachinePathItem $pgbin
32 changes: 32 additions & 0 deletions images/win/scripts/Installers/Validate-PostgreSQL.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
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
}
}

$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
$SoftwareName = "PostgreSQL"
$Description = @"
_Version:_ $psqlVersion<br/>
_Default Path:_ $pgroot
"@

Add-SoftwareDetailsToMarkdown -SoftwareName $SoftwareName -DescriptionMarkdown $Description

#Stop and disable PostgreSQL service
Stop-Service -Name $pgservice
Set-Service $pgservice -StartupType Disabled