Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Download latest release for install script #49

Merged
merged 1 commit into from
Mar 1, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 18 additions & 13 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/bin/sh
set -e

VERSION=v0.1.0

info()
{
echo "[INFO] " "$@"
Expand All @@ -14,6 +12,18 @@ fatal()
exit 1
}

if [ -z `which curl || true` ]; then
fatal "Can not find curl for downloading files"
fi

if [ -n "$1" ]; then
VERSION=$1
else
info "Finding latest release"
VERSION=`curl -w "%{url_effective}" -I -L -s -S https://github.com/rancher/k3s/releases/latest -o /dev/null | sed -e 's|.*/||'`
fi
info "Using $VERSION as release"

ARCH=`uname -m`

case $ARCH in
Expand Down Expand Up @@ -87,19 +97,14 @@ EOF
$SUDO chown root:root $TMPUNINSTALL
$SUDO mv -f $TMPUNINSTALL /usr/local/bin/k3s-uninstall.sh

CURL=`which curl`

if [ -n "$CURL" ]; then
TMPHASH=`mktemp -t k3s-install.XXXXXXXXXX`
TMPBIN=`mktemp -t k3s-install.XXXXXXXXXX`
TMPHASH=`mktemp -t k3s-install.XXXXXXXXXX`
TMPBIN=`mktemp -t k3s-install.XXXXXXXXXX`

info Downloading $HASHURL
$CURL -o $TMPHASH -sfL $HASHURL

info Downloading $BINURL
$CURL -o $TMPBIN -sfL $BINURL
fi
info Downloading $HASHURL
curl -o $TMPHASH -sfL $HASHURL

info Downloading $BINURL
curl -o $TMPBIN -sfL $BINURL

info Verifying download
EXPECTED=`grep k3s $TMPHASH | awk '{print $1}'`
Expand Down