Skip to content

Commit

Permalink
Windows install (#6)
Browse files Browse the repository at this point in the history
Windows script to install the provider
  • Loading branch information
CharlieBlain authored Jul 8, 2021
1 parent 6a385db commit e5e8657
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,20 @@ The above will install the latest available release. To install a specific relea
VERSION=v0.0.5 bash <(curl -sL https://raw.githubusercontent.com/HewlettPackard/terraform-provider-hpegl/main/tools/install-hpegl-provider.sh)
```

### Windows

Use the script `tools/install-hpegl-provider-windows.ps1` to automatically download and install hpegl provider:

```shell
. { iwr -useb https://raw.githubusercontent.com/HewlettPackard/terraform-provider-hpegl/main/tools/install-hpegl-provider-windows.ps1 } | iex ;
```
The above will install the latest available release. To install a specific release:
```shell
iex "& { $(irm https://raw.githubusercontent.com/HewlettPackard/terraform-provider-hpegl/main/tools/install-hpegl-provider-windows.ps1) } -VERSION v0.0.1"
```
### MacOS
Before using the install script, install GNU grep via homebrew with `brew install grep`
Expand All @@ -34,7 +48,6 @@ Before using the install script, install GNU grep via homebrew with `brew instal
Use the script `tools/install-hpegl-provider-macos.sh` to automatically download and install hpegl provider:

```shell
bash <(curl -sL https://raw.githubusercontent.com/HewlettPackard/terraform-provider-hpegl/main/tools/install-hpegl-provider-macos.sh)
```
Expand Down
40 changes: 40 additions & 0 deletions tools/install-hpegl-provider-windows.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
param ($VERSION)

$os="windows"
$arch="amd64"
$repo="HewlettPackard/terraform-provider-hpegl"
$windows_hpegl_dir="$env:appdata\terraform.d\plugins\registry.terraform.io\hewlettpackard\hpegl"

function get_latest_release {
Write-Host Getting latest release
$release_url="https://api.github.com/repos/${repo}/releases/latest"
$tag = (Invoke-WebRequest $release_url | ConvertFrom-Json)[0].tag_name
$VERSION=${tag}

$VERSION
}

if (!$VERSION) {
$VERSION=get_latest_release
}

$version_number=$VERSION -replace 'v'

$dest_dir="${windows_hpegl_dir}\${version_number}\${os}_${arch}\"
$hpegl_zip="terraform-provider-hpegl_${version_number}_${os}_${arch}.zip"
$hpegl=$hpegl_zip -replace '.zip'
$hpegl_dl_url="https://github.com/${repo}/releases/download/${VERSION}/${hpegl_zip}"

Write-Host Downloading latest release
mkdir "$dest_dir"
Set-Location "$dest_dir"
Invoke-WebRequest $hpegl_dl_url -Out $hpegl_zip

Write-Host Extracting release files
Expand-Archive $hpegl_zip -Force

Get-ChildItem -Path $hpegl -Recurse -File | Move-Item -Destination $dest_dir

Remove-Item $hpegl_zip -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item $hpegl -Recurse -Force -ErrorAction SilentlyContinue
Write-Host Complete

0 comments on commit e5e8657

Please sign in to comment.