Skip to content
This repository has been archived by the owner on Dec 8, 2023. It is now read-only.

Commit

Permalink
Add k3s upgrade script
Browse files Browse the repository at this point in the history
  • Loading branch information
zimme committed Oct 28, 2019
1 parent 2a5dc87 commit 94f78d9
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions overlay/sbin/k3s-upgrade
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

if [ $(whoami) != "root" ]
then
echo "This script must be run as root."
exit 1
fi

PROC=$(uname -m)

# Take a parameter of the version number (i.e. v0.4.0) if it is given, otherwise use latest
if [ -z $K3S_VERSION ]
then
K3S_VERSION=$(curl -sL api.github.com/repos/rancher/k3s/releases/latest | jq .tag_name -r)
fi

if [ $PROC == "x86_64" ]
then
ARCH="amd64"
elif [ $PROC == "aarch64" ]
then
ARCH="arm64"
elif [ $PROC == "armv7l" ]
then
ARCH="armhf"
else
echo "Unsupported CPU architecture."
exit 1
fi

K3S_URL="https://github.com/rancher/k3s/releases/download/${K3S_VERSION}/k3s-${ARCH}"

cd /k3os/system/k3s
mount -o remount,rw ..
echo "Upgrading k3s to ${K3S_VERSION}"
mkdir -p "${K3S_VERSION}"
curl -fsSL -o "${K3S_VERSION}/k3s" "${K3S_URL}"
chmod +x "${K3S_VERSION}/k3s"
ln -sfn "${K3S_VERSION}" current
sync

echo "Upgrade complete! Please reboot."

0 comments on commit 94f78d9

Please sign in to comment.