-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from HewlettPackard/macos-install
Install script for MacOS/M1 and README update
- Loading branch information
Showing
2 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
os="darwin" | ||
|
||
if [[ `uname -m` == 'x86_64' ]] | ||
then | ||
echo 'Intel Architecture detected' | ||
arch="amd64" | ||
elif [[ `uname -m` == 'arm64' ]] | ||
then | ||
echo 'Apple Silicon Architecture detected' | ||
arch="arm64" | ||
fi | ||
|
||
repo="HewlettPackard/terraform-provider-hpegl" | ||
macos_hpegl_dir="${HOME}/.terraform.d/plugins/registry.terraform.io/hewlettpackard/hpegl" | ||
|
||
get_latest_release () { | ||
local release_url="https://api.github.com/repos/${repo}/releases/latest" | ||
curl -sL "$release_url" | ggrep -Po '"tag_name": "\K.*?(?=")' | ||
} | ||
|
||
download_and_extract () { | ||
local dest_dir="${macos_hpegl_dir}/${version_number}/${os}_${arch}/" | ||
local hpegl_zip="terraform-provider-hpegl_${version_number}_${os}_${arch}.zip" | ||
local hpegl_dl_url="https://github.com/${repo}/releases/download/${VERSION}/${hpegl_zip}" | ||
|
||
mkdir -p "$dest_dir" && cd "$dest_dir" | ||
curl -sL "$hpegl_dl_url" -o "$hpegl_zip" && \ | ||
unzip -u "$hpegl_zip" && \ | ||
rm -f "$hpegl_zip" | ||
} | ||
|
||
VERSION=${VERSION:=$(get_latest_release)} | ||
version_number=${VERSION//v} | ||
download_and_extract |