Skip to content

Commit 07b5b6e

Browse files
committed
Fix broken upgrade url
Add pre and post upgrade sanity checks Fixes #718
1 parent 0cb0241 commit 07b5b6e

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

getssl

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,8 @@
274274
# 2021-09-30 better error if curl returns 60 (#709)
275275
# 2021-10-01 Fix -preferred-chain argument (#712)
276276
# 2021-10-01 Show help if no domain specified (#705)(2.44)
277+
# 2021-10-08 Extract release tag from release api using awk (fix BSD issues)
278+
# 2021-10-11 Fix broken upgrade url (#718)(2.45)
277279
# ----------------------------------------------------------------------------------------
278280

279281
case :$SHELLOPTS: in
@@ -282,7 +284,7 @@ esac
282284

283285
PROGNAME=${0##*/}
284286
PROGDIR="$(cd "$(dirname "$0")" || exit; pwd -P;)"
285-
VERSION="2.44"
287+
VERSION="2.45"
286288

287289
# defaults
288290
ACCOUNT_KEY_LENGTH=4096
@@ -825,22 +827,38 @@ check_getssl_upgrade() { # check if a more recent release is available
825827
# shellcheck disable=SC2086
826828
debug curl ${_NOMETER:---silent} --user-agent "$CURL_USERAGENT" "$CODE_LOCATION" --output "$TEMP_UPGRADE_FILE"
827829
# shellcheck disable=SC2086
828-
curl ${_NOMETER:---silent} --user-agent "$CURL_USERAGENT" "$CODE_LOCATION" --output "$TEMP_UPGRADE_FILE"
830+
status=$(curl ${_NOMETER:---silent} -w "%{http_code}" --user-agent "$CURL_USERAGENT" "$CODE_LOCATION" --output "$TEMP_UPGRADE_FILE")
829831
errcode=$?
832+
debug errcode=$errcode
830833

831834
if [[ $errcode -eq 60 ]]; then
832835
error_exit "curl needs updating, your version does not support SNI (multiple SSL domains on a single IP)"
833836
elif [[ $errcode -gt 0 ]]; then
834837
error_exit "curl error downloading release: $errcode"
835838
fi
836839

840+
if [[ $status -ne 200 ]]; then
841+
error_exit "curl didn't find the updated version of getssl at $CODE_LOCATION"
842+
fi
843+
837844
if ! install "$0" "${0}.v${VERSION}"; then
838845
error_exit "problem renaming old version while updating, check permissions"
839846
fi
840847
if ! install -m 700 "$TEMP_UPGRADE_FILE" "$0"; then
841848
error_exit "problem installing new version while updating, check permissions"
842849
fi
843850

851+
check=$(bash "$0" -U -v)
852+
release_tag_upper=$(echo "$release_tag" | tr "[:lower:]" "[:upper:]")
853+
if [[ "$check" != "getssl ${release_tag_upper}" ]]; then
854+
info "problem running new version, rolling back to old version"
855+
if ! install "${0}.v${VERSION}" "$0"; then
856+
error_exit "problem rolling back, you'll need to manually check $0 and $0.${VERSION}"
857+
fi
858+
error_exit "problem calling new version; output of $TEMP_UPGRADE_FILE -v was \"$check\", expected \"getssl ${release_tag_upper}\""
859+
fi
860+
861+
844862
if [[ ${_MUTE} -eq 0 ]]; then
845863
echo "Updated getssl from v${VERSION} to ${release_tag}"
846864
echo "The old version remains as ${0}.v${VERSION} and should be removed"

0 commit comments

Comments
 (0)