Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
ad7b2e0a
Unverified
Commit
ad7b2e0a
authored
Sep 18, 2019
by
Erik Wilson
Committed by
GitHub
Sep 18, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #756 from joakimr-axis/joakimr-axis_wget
install.sh: Add wget fallback if curl isn't available
parents
36ca6060
a0d27438
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
9 deletions
+43
-9
install.sh
install.sh
+43
-9
No files found.
install.sh
View file @
ad7b2e0a
...
@@ -67,6 +67,7 @@ set -e
...
@@ -67,6 +67,7 @@ set -e
# if not specified.
# if not specified.
GITHUB_URL
=
https://github.com/rancher/k3s/releases
GITHUB_URL
=
https://github.com/rancher/k3s/releases
DOWNLOADER
=
# --- helper functions for logs ---
# --- helper functions for logs ---
info
()
info
()
...
@@ -260,11 +261,14 @@ setup_verify_arch() {
...
@@ -260,11 +261,14 @@ setup_verify_arch() {
esac
esac
}
}
# --- fatal if no curl ---
# --- verify existence of network downloader executable ---
verify_curl
()
{
verify_downloader
()
{
if
[
-z
$(
which curl
||
true
)
]
;
then
# Return failure if it doesn't exist or is no executable
fatal
"Can not find curl for downloading files"
[
-x
"
$(
which
$1
)
"
]
||
return
1
fi
# Set verified executable as our downloader program and return success
DOWNLOADER
=
$1
return
0
}
}
# --- create tempory directory and cleanup when done ---
# --- create tempory directory and cleanup when done ---
...
@@ -288,16 +292,46 @@ get_release_version() {
...
@@ -288,16 +292,46 @@ get_release_version() {
VERSION_K3S
=
"
${
INSTALL_K3S_VERSION
}
"
VERSION_K3S
=
"
${
INSTALL_K3S_VERSION
}
"
else
else
info
"Finding latest release"
info
"Finding latest release"
VERSION_K3S
=
$(
curl
-w
"%{url_effective}"
-I
-L
-s
-S
${
GITHUB_URL
}
/latest
-o
/dev/null |
sed
-e
's|.*/||'
)
case
$DOWNLOADER
in
curl
)
VERSION_K3S
=
$(
curl
-w
'%{url_effective}'
-I
-L
-s
-S
${
GITHUB_URL
}
/latest
-o
/dev/null |
sed
-e
's|.*/||'
)
;;
wget
)
VERSION_K3S
=
$(
wget
-SqO
/dev/null
${
GITHUB_URL
}
/latest 2>&1 |
grep
Location |
sed
-e
's|.*/||'
)
;;
*
)
fatal
"Incorrect downloader executable '
$DOWNLOADER
'"
;;
esac
fi
fi
info
"Using
${
VERSION_K3S
}
as release"
info
"Using
${
VERSION_K3S
}
as release"
}
}
# --- download from github url ---
download
()
{
[
$#
-eq
2
]
||
fatal
'download needs exactly 2 arguments'
case
$DOWNLOADER
in
curl
)
curl
-o
$1
-sfL
$2
;;
wget
)
wget
-qO
$1
$2
;;
*
)
fatal
"Incorrect executable '
$DOWNLOADER
'"
;;
esac
# Abort if download command failed
[
$?
-eq
0
]
||
fatal
'Download failed'
}
# --- download hash from github url ---
# --- download hash from github url ---
download_hash
()
{
download_hash
()
{
HASH_URL
=
${
GITHUB_URL
}
/download/
${
VERSION_K3S
}
/sha256sum-
${
ARCH
}
.txt
HASH_URL
=
${
GITHUB_URL
}
/download/
${
VERSION_K3S
}
/sha256sum-
${
ARCH
}
.txt
info
"Downloading hash
${
HASH_URL
}
"
info
"Downloading hash
${
HASH_URL
}
"
curl
-o
${
TMP_HASH
}
-sfL
${
HASH_URL
}
||
fatal
"Hash download failed"
download
${
TMP_HASH
}
${
HASH_URL
}
HASH_EXPECTED
=
$(
grep
" k3s
${
SUFFIX
}
$"
${
TMP_HASH
}
|
awk
'{print $1}'
)
HASH_EXPECTED
=
$(
grep
" k3s
${
SUFFIX
}
$"
${
TMP_HASH
}
|
awk
'{print $1}'
)
}
}
...
@@ -316,7 +350,7 @@ installed_hash_matches() {
...
@@ -316,7 +350,7 @@ installed_hash_matches() {
download_binary
()
{
download_binary
()
{
BIN_URL
=
${
GITHUB_URL
}
/download/
${
VERSION_K3S
}
/k3s
${
SUFFIX
}
BIN_URL
=
${
GITHUB_URL
}
/download/
${
VERSION_K3S
}
/k3s
${
SUFFIX
}
info
"Downloading binary
${
BIN_URL
}
"
info
"Downloading binary
${
BIN_URL
}
"
curl
-o
${
TMP_BIN
}
-sfL
${
BIN_URL
}
||
fatal
"Binary download failed"
download
${
TMP_BIN
}
${
BIN_URL
}
}
}
# --- verify downloaded binary hash ---
# --- verify downloaded binary hash ---
...
@@ -359,7 +393,7 @@ download_and_verify() {
...
@@ -359,7 +393,7 @@ download_and_verify() {
fi
fi
setup_verify_arch
setup_verify_arch
verify_
curl
verify_
downloader curl
||
verify_downloader wget
||
fatal
'Can not find curl or wget for downloading files'
setup_tmp
setup_tmp
get_release_version
get_release_version
download_hash
download_hash
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment