Skip to content

Instantly share code, notes, and snippets.

@khorevaa
Created March 15, 2021 11:43
Show Gist options
  • Save khorevaa/b303d9288922ba553774cd90a5af6b2b to your computer and use it in GitHub Desktop.
Save khorevaa/b303d9288922ba553774cd90a5af6b2b to your computer and use it in GitHub Desktop.
#!/bin/sh
set -e
TAR_FILE="/tmp/oneget.tar.gz"
RELEASES_URL="https://github.com/v8platform/oneget/releases"
test -z "$TMPDIR" && TMPDIR="$(mktemp -d)"
last_version() {
curl -sL -o /dev/null -w %{url_effective} "$RELEASES_URL/latest" |
rev |
cut -f1 -d'/'|
rev
}
download() {
test -z "$ONEGET_VERSION" && ONEGET_VERSION="$(last_version)"
test -z "$ONEGET_VERSION" && {
echo "Unable to get oneget version." >&2
exit 1
}
rm -f "$TAR_FILE"
curl -s -L -o "$TAR_FILE" \
"$RELEASES_URL/download/$ONEGET_VERSION/oneget_$(uname -s)_$(uname -m).tar.gz"
}
download
tar -xf "$TAR_FILE" -C "$TMPDIR"
"${TMPDIR}/oneget" "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment