-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall-linux.sh
32 lines (24 loc) · 899 Bytes
/
install-linux.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/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_SUFFIX=`uname -s | tr '[:upper:]' '[:lower:]'`-`uname -i`
ZIP_FILE=$BINARY_FILE-$LATEST_TAG-$ZIP_SUFFIX.zip
BIN_DIR=/usr/local/bin
# unzip cannot work on Unix pipe
echo "Downloading '"$ZIP_FILE"'..."
curl -sSfLO "https://github.com/$REPO_USERNAME/$REPO_NAME/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$BINARY_FILE requires terraform, be sure to place terraform in PATH.\n"