Skip to content

Commit f278629

Browse files
authored
Merge pull request #719 from srvrco/timkimber/issue717
Fix upgrade url issue
2 parents 758d00c + f960ac9 commit f278629

File tree

3 files changed

+27
-7
lines changed

3 files changed

+27
-7
lines changed

.github/workflows/run-tests-staging-duckdns.yml

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ jobs:
2424
run: test/run-test.sh centos7-duckdns
2525
test-ubuntu-duckdns:
2626
runs-on: ubuntu-latest
27+
if: always()
28+
needs: test-centos7-duckdns
2729
steps:
2830
- uses: actions/checkout@v2
2931
- name: Build the docker-compose stack

.github/workflows/run-tests-staging-dynu.yml

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ jobs:
2424
run: test/run-test.sh centos7-dynu
2525
test-ubuntu-dynu:
2626
runs-on: ubuntu-latest
27+
if: always()
28+
needs: test-centos7-dynu
2729
steps:
2830
- uses: actions/checkout@v2
2931
- name: Build the docker-compose stack

getssl

+23-7
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
@@ -774,10 +776,8 @@ check_getssl_upgrade() { # check if a more recent release is available
774776
fi
775777
local release_data release_tag release_ver local_ver release_desc NEWCMD
776778
debug "Checking for releases at $RELEASE_API"
777-
# Sometimes the json is pretty-printed, sometimes not. Loosely tied to --user-agent, but not
778-
# always. Normalize it enough to get the 3 elements necessary. Oh, for jq...
779779
# shellcheck disable=SC2086
780-
release_data="$(curl ${_NOMETER:---silent} --user-agent "$CURL_USERAGENT" -H 'Accept: application/vnd.github.v3+json' "$RELEASE_API" | sed -e's/\("[^:]*": *\("[^""]*",\|[^,]*[,}]\)\)/\r\n\1/g')"
780+
release_data="$(curl ${_NOMETER:---silent} --user-agent "$CURL_USERAGENT" -H 'Accept: application/vnd.github.v3+json' "$RELEASE_API")"
781781
errcode=$?
782782
if [[ $errcode -eq 60 ]]; then
783783
error_exit "curl needs updating, your version does not support SNI (multiple SSL domains on a single IP)"
@@ -786,8 +786,8 @@ check_getssl_upgrade() { # check if a more recent release is available
786786
fi
787787
# Replace error in release description with _error (which is ignored by check_output_for_errors() in the tests)
788788
debug "${release_data//error/_error}"
789-
release_data="$(sed -e's/^ *//g' <<<"${release_data}")"
790-
release_tag="$(sed -e'/"tag_name": *"/!d;s/"tag_name": *"\([^""]*\).*$/\1/' <<<"${release_data}")"
789+
# awk from https://stackoverflow.com/questions/1761341/awk-print-next-record-following-matched-record
790+
release_tag=$(awk -F'"' '/tag_name/ {f=NR} f&&NR-1==f' RS=":|," <<<"${release_data}" | sed -e's/"//g')
791791
if [[ "${release_tag:0:1}" != 'v' ]] ; then
792792
if [[ ${_MUTE} -eq 0 ]]; then
793793
info "The current repository has no releases or is improperly tagged; can't check for upgrades: '$release_tag'"
@@ -827,22 +827,38 @@ check_getssl_upgrade() { # check if a more recent release is available
827827
# shellcheck disable=SC2086
828828
debug curl ${_NOMETER:---silent} --user-agent "$CURL_USERAGENT" "$CODE_LOCATION" --output "$TEMP_UPGRADE_FILE"
829829
# shellcheck disable=SC2086
830-
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")
831831
errcode=$?
832+
debug errcode=$errcode
832833

833834
if [[ $errcode -eq 60 ]]; then
834835
error_exit "curl needs updating, your version does not support SNI (multiple SSL domains on a single IP)"
835836
elif [[ $errcode -gt 0 ]]; then
836837
error_exit "curl error downloading release: $errcode"
837838
fi
838839

840+
if [[ $status -ne 200 ]]; then
841+
error_exit "curl didn't find the updated version of getssl at $CODE_LOCATION"
842+
fi
843+
839844
if ! install "$0" "${0}.v${VERSION}"; then
840845
error_exit "problem renaming old version while updating, check permissions"
841846
fi
842847
if ! install -m 700 "$TEMP_UPGRADE_FILE" "$0"; then
843848
error_exit "problem installing new version while updating, check permissions"
844849
fi
845850

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+
846862
if [[ ${_MUTE} -eq 0 ]]; then
847863
echo "Updated getssl from v${VERSION} to ${release_tag}"
848864
echo "The old version remains as ${0}.v${VERSION} and should be removed"

0 commit comments

Comments
 (0)