mirror of
https://github.com/actions/runner-images.git
synced 2025-12-18 07:46:57 +00:00
[Windows] Move PGDATA out of Program Files (#13107)
This commit is contained in:
@@ -7,6 +7,9 @@
|
|||||||
$pgUser = "postgres"
|
$pgUser = "postgres"
|
||||||
$pgPwd = "root"
|
$pgPwd = "root"
|
||||||
|
|
||||||
|
# Save current value of ErrorActionPreference and set it to Stop
|
||||||
|
$errorActionOldValue = $ErrorActionPreference
|
||||||
|
|
||||||
# Prepare environment variable for validation
|
# Prepare environment variable for validation
|
||||||
[Environment]::SetEnvironmentVariable("PGUSER", $pgUser, "Machine")
|
[Environment]::SetEnvironmentVariable("PGUSER", $pgUser, "Machine")
|
||||||
[Environment]::SetEnvironmentVariable("PGPASSWORD", $pgPwd, "Machine")
|
[Environment]::SetEnvironmentVariable("PGPASSWORD", $pgPwd, "Machine")
|
||||||
@@ -35,7 +38,6 @@ if ($null -ne ($toolsetVersion | Select-String -Pattern '\d+\.\d+\.\d+')) {
|
|||||||
$targetMinorVersions = ($minorVersions | Sort-Object)[-1]
|
$targetMinorVersions = ($minorVersions | Sort-Object)[-1]
|
||||||
|
|
||||||
# In order to get rid of error messages (we know we will have them), force ErrorAction to SilentlyContinue
|
# In order to get rid of error messages (we know we will have them), force ErrorAction to SilentlyContinue
|
||||||
$errorActionOldValue = $ErrorActionPreference
|
|
||||||
$ErrorActionPreference = 'SilentlyContinue'
|
$ErrorActionPreference = 'SilentlyContinue'
|
||||||
|
|
||||||
# Install latest PostgreSQL
|
# Install latest PostgreSQL
|
||||||
@@ -58,10 +60,27 @@ if ($null -ne ($toolsetVersion | Select-String -Pattern '\d+\.\d+\.\d+')) {
|
|||||||
} while (!$response)
|
} while (!$response)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Return the previous value of ErrorAction and invoke Install-Binary function
|
# Return the previous value of ErrorAction and invoke Install-Binary function
|
||||||
$ErrorActionPreference = $errorActionOldValue
|
$ErrorActionPreference = $errorActionOldValue
|
||||||
$installerArgs = @("--install_runtimes 0", "--superpassword root", "--enable_acledit 1", "--unattendedmodeui none", "--mode unattended")
|
|
||||||
|
# Define new data directory for PostgreSQL and create it
|
||||||
|
if ($installerUrl -match 'postgresql-(\d+)') {
|
||||||
|
$pgMajorVersion = $matches[1]
|
||||||
|
}
|
||||||
|
$pgData = "C:\PostgreSQL\$pgMajorVersion\data"
|
||||||
|
if (-Not (Test-Path -Path $pgData)) {
|
||||||
|
New-Item -ItemType Directory -Path $pgData | Out-Null
|
||||||
|
}
|
||||||
|
|
||||||
|
# Define silent install arguments for PostgreSQL
|
||||||
|
$installerArgs = @(
|
||||||
|
"--install_runtimes 0",
|
||||||
|
"--superpassword root",
|
||||||
|
"--enable_acledit 1",
|
||||||
|
"--unattendedmodeui none",
|
||||||
|
"--mode unattended",
|
||||||
|
"--datadir `"$pgData`""
|
||||||
|
)
|
||||||
|
|
||||||
Install-Binary `
|
Install-Binary `
|
||||||
-Url $installerUrl `
|
-Url $installerUrl `
|
||||||
@@ -74,8 +93,7 @@ $pgPath = (Get-CimInstance Win32_Service -Filter "Name LIKE 'postgresql-%'").Pat
|
|||||||
|
|
||||||
# Parse output of command above to obtain pure path
|
# Parse output of command above to obtain pure path
|
||||||
$pgBin = Split-Path -Path $pgPath.split('"')[1]
|
$pgBin = Split-Path -Path $pgPath.split('"')[1]
|
||||||
$pgRoot = Split-Path -Path $pgPath.split('"')[5]
|
$pgRoot = Split-Path $pgBin -Parent
|
||||||
$pgData = Join-Path $pgRoot "data"
|
|
||||||
|
|
||||||
# Validate PostgreSQL installation
|
# Validate PostgreSQL installation
|
||||||
$pgReadyPath = Join-Path $pgBin "pg_isready.exe"
|
$pgReadyPath = Join-Path $pgBin "pg_isready.exe"
|
||||||
|
|||||||
Reference in New Issue
Block a user