-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add install script for Linux AMD64 (#8)
* Add install script for linux * Add install instruction to README
- Loading branch information
Showing
2 changed files
with
43 additions
and
6 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,30 @@ | ||
#!/usr/bin/env sh | ||
if [ `id -u` != 0 ]; then | ||
echo "Run the script as root/sudo!" | ||
exit 1 | ||
fi | ||
|
||
REPO_USERNAME=guangie88 | ||
REPO_NAME=terraform-zap | ||
|
||
LATEST_TAG=$(curl -sSf "https://api.github.com/repos/$REPO_USERNAME/$REPO_NAME/releases/latest" \ | ||
| grep tag_name \ | ||
| sed -n 's/.*"\(v.*\)".*/\1/p') | ||
|
||
BINARY_FILE=terraform-zap | ||
ZIP_FILE=$BINARY_FILE-$LATEST_TAG.zip | ||
BIN_DIR=/usr/local/bin | ||
|
||
# unzip cannot work on Unix pipe | ||
echo "Downloading '"$ZIP_FILE"'..." | ||
curl -sSfLO "https://github.com/guangie88/terraform-zap/releases/download/$LATEST_TAG/$ZIP_FILE" | ||
|
||
echo "Unzipping..." | ||
unzip -qq "$ZIP_FILE" | ||
rm "$ZIP_FILE" | ||
|
||
echo "Moving binary file '"$BINARY_FILE"' to $BIN_DIR/..." | ||
mv $BINARY_FILE $BIN_DIR/ | ||
chmod +x $BIN_DIR/$BINARY_FILE | ||
|
||
echo "DONE!\n\nterraform-zap requires terraform, be sure to place terraform in PATH.\n" |