|
|
@ -59,6 +59,9 @@ scurl() { |
|
|
|
# - `--fail` ensures that the command fails if HTTP response is not 2xx. |
|
|
|
# - `--fail` ensures that the command fails if HTTP response is not 2xx. |
|
|
|
# - `--show-error` causes curl to output error messages when it fails (when |
|
|
|
# - `--show-error` causes curl to output error messages when it fails (when |
|
|
|
# also invoked with -s|--silent). |
|
|
|
# also invoked with -s|--silent). |
|
|
|
|
|
|
|
if [[ "$DEBUG" == "true" ]]; then |
|
|
|
|
|
|
|
echo "Executing: curl --proto \"=https\" --tlsv1.2 --fail --show-error $*" >&2 |
|
|
|
|
|
|
|
fi |
|
|
|
curl --proto "=https" --tlsv1.2 --fail --show-error "$@" |
|
|
|
curl --proto "=https" --tlsv1.2 --fail --show-error "$@" |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -104,15 +107,13 @@ checkTagProvided() { |
|
|
|
checkLatestVersion() { |
|
|
|
checkLatestVersion() { |
|
|
|
local latest_release_url="$REPO_URL/releases/latest" |
|
|
|
local latest_release_url="$REPO_URL/releases/latest" |
|
|
|
if type "curl" > /dev/null; then |
|
|
|
if type "curl" > /dev/null; then |
|
|
|
if [[ "$DEBUG" == "true" ]]; then |
|
|
|
|
|
|
|
echo "Fetching latest release URL: $latest_release_url" |
|
|
|
|
|
|
|
TAG=$(scurl -Lvvv -o /dev/null -w %{url_effective} $latest_release_url | grep -oE "[^/]+$" ) |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
TAG=$(scurl -Ls -o /dev/null -w %{url_effective} $latest_release_url | grep -oE "[^/]+$" ) |
|
|
|
TAG=$(scurl -Ls -o /dev/null -w %{url_effective} $latest_release_url | grep -oE "[^/]+$" ) |
|
|
|
fi |
|
|
|
|
|
|
|
elif type "wget" > /dev/null; then |
|
|
|
elif type "wget" > /dev/null; then |
|
|
|
TAG=$(wget $latest_release_url --server-response -O /dev/null 2>&1 | awk '/^\s*Location: /{DEST=$2} END{ print DEST}' | grep -oE "[^/]+$") |
|
|
|
TAG=$(wget $latest_release_url --server-response -O /dev/null 2>&1 | awk '/^\s*Location: /{DEST=$2} END{ print DEST}' | grep -oE "[^/]+$") |
|
|
|
fi |
|
|
|
fi |
|
|
|
|
|
|
|
if [[ "$DEBUG" == "true" ]]; then |
|
|
|
|
|
|
|
echo "Resolved latest tag: <$TAG>" >&2 |
|
|
|
|
|
|
|
fi |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
# downloadFile downloads the latest binary package and also the checksum |
|
|
|
# downloadFile downloads the latest binary package and also the checksum |
|
|
@ -126,12 +127,7 @@ downloadFile() { |
|
|
|
K3D_TMP_ROOT="$(mktemp -dt k3d-binary-XXXXXX)" |
|
|
|
K3D_TMP_ROOT="$(mktemp -dt k3d-binary-XXXXXX)" |
|
|
|
K3D_TMP_FILE="$K3D_TMP_ROOT/$K3D_DIST" |
|
|
|
K3D_TMP_FILE="$K3D_TMP_ROOT/$K3D_DIST" |
|
|
|
if type "curl" > /dev/null; then |
|
|
|
if type "curl" > /dev/null; then |
|
|
|
if [[ "$DEBUG" == "true" ]]; then |
|
|
|
|
|
|
|
echo "Downloading $DOWNLOAD_URL to $K3D_TMP_FILE" |
|
|
|
|
|
|
|
scurl -L -vvv "$DOWNLOAD_URL" -o "$K3D_TMP_FILE" |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
scurl -sL "$DOWNLOAD_URL" -o "$K3D_TMP_FILE" |
|
|
|
scurl -sL "$DOWNLOAD_URL" -o "$K3D_TMP_FILE" |
|
|
|
fi |
|
|
|
|
|
|
|
elif type "wget" > /dev/null; then |
|
|
|
elif type "wget" > /dev/null; then |
|
|
|
wget -q -O "$K3D_TMP_FILE" "$DOWNLOAD_URL" |
|
|
|
wget -q -O "$K3D_TMP_FILE" "$DOWNLOAD_URL" |
|
|
|
fi |
|
|
|
fi |
|
|
|