-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Install script and build version fix
- Loading branch information
Matt Olenik
committed
Oct 27, 2017
1 parent
eaac0d9
commit 5944dc0
Showing
2 changed files
with
24 additions
and
45 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 |
---|---|---|
@@ -1,48 +1,30 @@ | ||
#!/usr/bin/env dash | ||
# Installs or upgrades to the latest version of hclq | ||
#!/bin/sh | ||
# Installs or upgrades hclq, by default installing into /usr/local/bin | ||
# This can be overridden by passing a directory as the first parameter. | ||
set -e | ||
|
||
main() { | ||
destination=${1:-"/usr/local/bin"} | ||
destination=${1:-"/usr/local/bin"} | ||
[ ! -d "$destination" ] && printf "Install directory '%s' does not exist\n", "$destination" && exit 1 | ||
|
||
if [ ! -d "$destination" ]; then | ||
echo "Install directory '$destination' does not exist" | ||
printUsage | ||
exit 1 | ||
fi | ||
if ! command -v jq > /dev/null 2>&1; then | ||
printf "jq is required for this install script" | ||
[ "$(uname)" = "Darwin" ] && printf ", it can be installed with 'brew install jq\n'" | ||
exit 1 | ||
fi | ||
|
||
if ! command -v jq > /dev/null 2>&1; then | ||
printf "jq is required for this install script" | ||
[ "$(uname)" = "Darwin" ] && printf ", it can be installed with 'brew install jq'" | ||
echo | ||
exit 1 | ||
fi | ||
if command -v hclq > /dev/null 2>&1; then | ||
msg="Upgrading hclq..." | ||
ver="$(hclq --version)" | ||
else | ||
msg="Installing hclq..." | ||
fi | ||
|
||
if command -v hclq > /dev/null 2>&1; then | ||
msg="Upgrading hclq..." | ||
ver=$(hclq --version) | ||
else | ||
msg="Installing hclq..." | ||
fi | ||
latest="$(curl -s https://api.github.com/repos/mattolenik/hclq/releases/latest)" | ||
tag="$(printf "$latest" | jq -r '.tag_name')" | ||
[ "$tag" = "$ver" ] && printf "hclq is already at the latest version\n" && exit 0 | ||
printf "%s\n" "$msg" | ||
|
||
latest=$(curl -s https://api.github.com/repos/mattolenik/hclq/releases/latest) | ||
tag=$(echo $latest | jq -r '.tag_name') | ||
if [ "$tag" = "$ver" ]; then | ||
echo "hclq is already at the latest version" | ||
exit 0 | ||
fi | ||
hclq_url=$(curl -s https://api.github.com/repos/mattolenik/hclq/releases/latest | jq -r '.assets[] | .browser_download_url' | grep -i "$(uname)") | ||
curl --progress-var -JLo "$destination/hclq" "$hclq_url" && chmod +x "$destination/hclq" | ||
|
||
echo $msg | ||
hclq_url=$(curl -s https://api.github.com/repos/mattolenik/hclq/releases/latest | jq -r '.assets[] | .browser_download_url' | grep -i "$(uname)") | ||
curl -sSJLo "$destination/hclq" "$hclq_url" && chmod +x "$destination/hclq" | ||
|
||
echo "hclq now at version $(hclq --version)" | ||
} | ||
|
||
printUsage() { | ||
echo "Usage: install.sh [installDir]" | ||
echo | ||
echo "Default installDir is /usr/local/bin" | ||
} | ||
|
||
main "$@" | ||
printf "hclq now at version %s\n" "$(hclq --version)" |