Skip to content

Commit

Permalink
Add install script for Linux AMD64 (#8)
Browse files Browse the repository at this point in the history
* Add install script for linux

* Add install instruction to README
  • Loading branch information
guangie88 authored Apr 17, 2018
1 parent 04257a3 commit f05a70a
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 6 deletions.
19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,20 @@ commands in order to skip the above resources to possibly resolve the

## How to install

### Direct download for Linux (64-bit)
### Direct download for Linux (AMD64)

The most straightforward way is to visit
<https://github.com/guangie88/terraform-zap/releases>
and download the latest version of statically built binary in the zip asset. The
zip file is named as `terraform-zap-vX.Y.Z.zip`, and is currently meant only for
any Linux 64-bit machine.
The easiest way is to run the install script using shell as shown below.

```bash
curl -sSf https://raw.githubusercontent.com/guangie88/terraform-zap/master/install-index.sh | sudo sh
```

You will need to run as `root`, or run via `sudo`, since the script will place
`terraform-zap` binary file into `/usr/local/bin/`.

You may also choose to visit
[releases](https://github.com/guangie88/terraform-zap/releases)
and download the latest version of statically built binary in the zip asset.

### Via `cargo install`

Expand Down
30 changes: 30 additions & 0 deletions install-linux.sh
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"

0 comments on commit f05a70a

Please sign in to comment.