2019-11-19 16:06:10 +00:00
|
|
|
Set-StrictMode -Version latest
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
|
|
|
|
# Force TLS1.2
|
|
|
|
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
|
|
|
|
|
|
|
Set-Location C:\opt
|
|
|
|
|
|
|
|
Try {
|
|
|
|
$releases = "https://releases.hashicorp.com"
|
2020-05-11 17:17:28 +00:00
|
|
|
$version = "1.7.3"
|
2019-11-19 16:06:10 +00:00
|
|
|
$url = "${releases}/consul/${version}/consul_${version}_windows_amd64.zip"
|
|
|
|
|
2020-09-04 12:51:22 +00:00
|
|
|
New-Item -ItemType Directory -Force -Path C:\opt\consul
|
|
|
|
New-Item -ItemType Directory -Force -Path C:\opt\consul.d
|
2019-11-19 16:06:10 +00:00
|
|
|
|
|
|
|
# TODO: check sha!
|
|
|
|
Write-Output "Downloading Consul from: $url"
|
|
|
|
Invoke-WebRequest -Uri $url -Outfile consul.zip
|
|
|
|
Expand-Archive .\consul.zip .\
|
|
|
|
mv consul.exe C:\opt\consul.exe
|
|
|
|
C:\opt\consul.exe version
|
|
|
|
rm consul.zip
|
|
|
|
|
|
|
|
} Catch {
|
|
|
|
Write-Error "Failed to install Consul."
|
|
|
|
$host.SetShouldExit(-1)
|
|
|
|
throw
|
|
|
|
}
|
|
|
|
|
|
|
|
Write-Output "Installed Consul."
|