From cc605a22bda092708d486c55901e8eb7fe5dba31 Mon Sep 17 00:00:00 2001 From: Lukas Schauer Date: Fri, 8 Jan 2016 19:30:56 +0100 Subject: [PATCH] moved _openssl helper a bit up to be near the other helper methods --- letsencrypt.sh | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/letsencrypt.sh b/letsencrypt.sh index cc5c8b0..7fd89a9 100755 --- a/letsencrypt.sh +++ b/letsencrypt.sh @@ -152,6 +152,22 @@ get_json_array() { grep -Eo '"'"${1}"'":[^\[]*\[[^]]*]' } +# OpenSSL writes to stderr/stdout even when there are no errors. So just +# display the output if the exit code was != 0 to simplify debugging. +_openssl() { + set +e + out="$(openssl "${@}" 2>&1)" + res=$? + set -e + if [[ $res -ne 0 ]]; then + echo " + ERROR: failed to run $* (Exitcode: $res)" >&2 + echo >&2 + echo "Details:" >&2 + echo "$out" >&2 + exit $res + fi +} + http_request() { tempcont="$(mktemp)" @@ -187,22 +203,6 @@ http_request() { rm -f "${tempcont}" } -# OpenSSL writes to stderr/stdout even when there are no errors. So just -# display the output if the exit code was != 0 to simplify debugging. -_openssl() { - set +e - out="$(openssl "${@}" 2>&1)" - res=$? - set -e - if [[ $res -ne 0 ]]; then - echo " + ERROR: failed to run $* (Exitcode: $res)" >&2 - echo >&2 - echo "Details:" >&2 - echo "$out" >&2 - exit $res - fi -} - signed_request() { # Encode payload as urlbase64 payload64="$(printf '%s' "${2}" | urlbase64)" -- 2.39.5