mirror of https://github.com/k3s-io/k3s
Download latest release for install script
Check for latest release of k3s or pass a desired version as an argument. Adds curl as a requirement and early exits if not available. Fixes silent abort when wget is not available and `which` returns non-zero exit code.pull/109/head
parent
af9ea1d65e
commit
a7640cfb90
23
install.sh
23
install.sh
|
@ -1,8 +1,6 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
VERSION=v0.1.0
|
|
||||||
|
|
||||||
info()
|
info()
|
||||||
{
|
{
|
||||||
echo "[INFO] " "$@"
|
echo "[INFO] " "$@"
|
||||||
|
@ -14,6 +12,18 @@ fatal()
|
||||||
exit 1
|
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`
|
ARCH=`uname -m`
|
||||||
|
|
||||||
case $ARCH in
|
case $ARCH in
|
||||||
|
@ -87,19 +97,14 @@ EOF
|
||||||
$SUDO chown root:root $TMPUNINSTALL
|
$SUDO chown root:root $TMPUNINSTALL
|
||||||
$SUDO mv -f $TMPUNINSTALL /usr/local/bin/k3s-uninstall.sh
|
$SUDO mv -f $TMPUNINSTALL /usr/local/bin/k3s-uninstall.sh
|
||||||
|
|
||||||
CURL=`which curl`
|
|
||||||
|
|
||||||
if [ -n "$CURL" ]; then
|
|
||||||
TMPHASH=`mktemp -t k3s-install.XXXXXXXXXX`
|
TMPHASH=`mktemp -t k3s-install.XXXXXXXXXX`
|
||||||
TMPBIN=`mktemp -t k3s-install.XXXXXXXXXX`
|
TMPBIN=`mktemp -t k3s-install.XXXXXXXXXX`
|
||||||
|
|
||||||
info Downloading $HASHURL
|
info Downloading $HASHURL
|
||||||
$CURL -o $TMPHASH -sfL $HASHURL
|
curl -o $TMPHASH -sfL $HASHURL
|
||||||
|
|
||||||
info Downloading $BINURL
|
info Downloading $BINURL
|
||||||
$CURL -o $TMPBIN -sfL $BINURL
|
curl -o $TMPBIN -sfL $BINURL
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
info Verifying download
|
info Verifying download
|
||||||
EXPECTED=`grep k3s $TMPHASH | awk '{print $1}'`
|
EXPECTED=`grep k3s $TMPHASH | awk '{print $1}'`
|
||||||
|
|
Loading…
Reference in New Issue