Skip to content

Commit abbad07

Browse files
committed
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.
1 parent af9ea1d commit abbad07

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

Diff for: install.sh

+24-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
#!/bin/sh
22
set -e
33

4+
<<<<<<< HEAD
45
VERSION=v0.1.0
56

7+
=======
8+
>>>>>>> Download latest release for install script
69
info()
710
{
811
echo "[INFO] " "$@"
@@ -14,6 +17,18 @@ fatal()
1417
exit 1
1518
}
1619

20+
if [ -z `which curl || true` ]; then
21+
fatal "Can not find curl for downloading files"
22+
fi
23+
24+
if [ -n "$1" ]; then
25+
VERSION=$1
26+
else
27+
info "Finding latest release"
28+
VERSION=`curl -w "%{url_effective}" -I -L -s -S https://github.com/rancher/k3s/releases/latest -o /dev/null | sed -e 's|.*/||'`
29+
fi
30+
info "Using $VERSION as release"
31+
1732
ARCH=`uname -m`
1833

1934
case $ARCH in
@@ -87,19 +102,22 @@ EOF
87102
$SUDO chown root:root $TMPUNINSTALL
88103
$SUDO mv -f $TMPUNINSTALL /usr/local/bin/k3s-uninstall.sh
89104

105+
<<<<<<< HEAD
90106
CURL=`which curl`
91107

92108
if [ -n "$CURL" ]; then
93109
TMPHASH=`mktemp -t k3s-install.XXXXXXXXXX`
94110
TMPBIN=`mktemp -t k3s-install.XXXXXXXXXX`
111+
=======
112+
TMPHASH=`mktemp -t k3s-install.XXXXXXXXXX`
113+
TMPBIN=`mktemp -t k3s-install.XXXXXXXXXX`
114+
>>>>>>> Download latest release for install script
95115

96-
info Downloading $HASHURL
97-
$CURL -o $TMPHASH -sfL $HASHURL
98-
99-
info Downloading $BINURL
100-
$CURL -o $TMPBIN -sfL $BINURL
101-
fi
116+
info Downloading $HASHURL
117+
curl -o $TMPHASH -sfL $HASHURL
102118

119+
info Downloading $BINURL
120+
curl -o $TMPBIN -sfL $BINURL
103121

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

0 commit comments

Comments
 (0)