Skip to content

Commit 387e41f

Browse files
committed
dodanie możliwości wyboru wersji K3s i ustawienie domyślnej wersji na "stable"
Signed-off-by: Marcin Fabrykowski <[email protected]>
1 parent 405a4b5 commit 387e41f

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

scripts/chce_k3s.sh

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,36 @@
33
# Autor: Maciej Loper @2023.05
44
# Edytowane przez: Andrzej Szczepaniak @2023.11
55
# Edytowane, ze wzgledu na to, ze dual-stack nie dziala na najnowszej wersji K3s
6+
# Edytowane przez: TORGiren @2025.06
7+
# Edytowane, dodanie możliwości wyboru wersji K3s i ustawienie domyślnej wersji na "stable"
8+
9+
VERSION=${1:-"stable"}
10+
11+
function get_release() {
12+
local version="$1"
13+
# Sprawdzenie, czy wersja zawiera "+k3s" (np. "1.27.6+k3s1"). Jeśli tak, to zwróć ją bez zmian.
14+
if [[ "$version" =~ \+k3s ]]; then
15+
echo "$version"
16+
return
17+
fi
18+
local latest_version=$(curl -s https://update.k3s.io/v1-release/channels | python3 -c "import sys, json; print(list(filter(lambda x: x['id'] == '$version',json.load(sys.stdin)['data']))[0]['latest'])" 2>/dev/null)
19+
if [[ -z "$latest_version" ]]; then
20+
echo "Error: Version '$version' not found in release channels."
21+
exit 1
22+
fi
23+
echo "$latest_version"
24+
}
25+
26+
RELEASE=$(get_release "$VERSION")
27+
if [[ $? -ne 0 ]]; then
28+
echo "$RELEASE"
29+
exit 1
30+
fi
31+
32+
echo "Instalacja K3s w wersji: $RELEASE"
633

734
# pobranie binarki K3s w wersji 1.27.6+k3s1
8-
wget -O /usr/local/bin/k3s https://github.com/k3s-io/k3s/releases/download/v1.27.6%2Bk3s1/k3s
35+
wget -O /usr/local/bin/k3s "https://github.com/k3s-io/k3s/releases/download/$RELEASE/k3s"
936

1037
# nadanie uprawnien binarce k3s
1138
chmod +x /usr/local/bin/k3s

0 commit comments

Comments
 (0)