-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
install: curl|bash script to make install easier
- Loading branch information
Showing
1 changed file
with
45 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/bin/bash | ||
# | ||
# This script installs the latest version into /usr/local/bin or TARGET if specified | ||
# | ||
set -eo pipefail | ||
|
||
username="tractordev" | ||
repo="wanix" | ||
binpath="${TARGET:-/usr/local/bin}" | ||
|
||
repoURL="https://github.com/${username}/${repo}" | ||
releaseURL="$(curl -sI ${repoURL}/releases/latest | grep 'location:' | awk '{print $2}')" | ||
version="$(basename $releaseURL | cut -c 2- | tr -d '\r')" | ||
|
||
os="" | ||
arch="" | ||
|
||
# Detect operating system | ||
if [[ "$OSTYPE" == "linux-gnu"* ]]; then | ||
os="linux" | ||
elif [[ "$OSTYPE" == "darwin"* ]]; then | ||
os="darwin" | ||
elif [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" ]]; then | ||
# WSL uses msys or cygwin as OSTYPE | ||
os="windows" | ||
else | ||
echo "Unsupported operating system" | ||
exit 1 | ||
fi | ||
|
||
# Detect architecture | ||
if [[ "$(uname -m)" == "x86_64" ]]; then | ||
arch="amd64" | ||
elif [[ "$(uname -m)" == "arm64" ]]; then | ||
arch="arm64" | ||
else | ||
echo "Unsupported architecture" | ||
exit 1 | ||
fi | ||
|
||
filename="${repo}_${version}_${os}_${arch}.zip" | ||
|
||
curl -sSLO "${repoURL}/releases/download/v${version}/${filename}" | ||
unzip $filename wanix -d $binpath | ||
rm $filename |