From 20a937e4435edb10f7e41842584c25e280ba6b21 Mon Sep 17 00:00:00 2001 From: David Mcanulty Date: Mon, 18 Apr 2016 15:07:05 -0700 Subject: [PATCH 1/5] If debug mode, don't pass --silent to curl This also fixes the issue of curl getting the -L option passed to it twice. --- acme.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/acme.sh b/acme.sh index 66ea5c9b..036dfe1e 100755 --- a/acme.sh +++ b/acme.sh @@ -754,7 +754,7 @@ _initpath() { dp="$LE_WORKING_DIR/curl.dump" CURL="curl -L --silent" if [ "$DEBUG" ] && [ "$DEBUG" -ge "2" ] ; then - CURL="$CURL -L --trace-ascii $dp " + CURL="curl -L --trace-ascii $dp " fi _DEFAULT_ACCOUNT_KEY_PATH="$LE_WORKING_DIR/account.key" From 4880297e5c580e829e6e35d6e1fbc0844d68b5b9 Mon Sep 17 00:00:00 2001 From: David Mcanulty Date: Mon, 18 Apr 2016 15:26:21 -0700 Subject: [PATCH 2/5] Check return status of curl and report error This is really handy if you run without DEBUG mode and curl has a problem (like out of date SSL certs) --- acme.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/acme.sh b/acme.sh index 036dfe1e..e0b2bc87 100755 --- a/acme.sh +++ b/acme.sh @@ -491,8 +491,14 @@ _post() { CURL="$CURL --dump-header $HTTP_HEADER " if [ "$needbase64" ] ; then response="$($CURL -A "User-Agent: $USER_AGENT" -X POST --data "$body" $url | _base64)" + if [[ $? -gt 0 ]] ;then + _err "Curl failed with exit code $?, trying running script in DEBUG=1 mode" + fi else response="$($CURL -A "User-Agent: $USER_AGENT" -X POST --data "$body" $url)" + if [[ $? -gt 0 ]] ;then + _err "Curl failed with exit code $?, trying running script in DEBUG=1 mode" + fi fi else if [ "$needbase64" ] ; then @@ -514,8 +520,14 @@ _get() { if _exists "curl" ; then if [ "$onlyheader" ] ; then $CURL -I -A "User-Agent: $USER_AGENT" $url + if [[ $? -gt 0 ]] ;then + _err "Curl failed with exit code $?, trying running script in DEBUG=1 mode" + fi else $CURL -A "User-Agent: $USER_AGENT" $url + if [[ $? -gt 0 ]] ;then + _err "Curl failed with exit code $?, trying running script in DEBUG=1 mode" + fi fi else _debug "WGET" "$WGET" From acc7c235ca3ee730e430bbd84296605220e3b071 Mon Sep 17 00:00:00 2001 From: David Mcanulty Date: Mon, 18 Apr 2016 15:30:26 -0700 Subject: [PATCH 3/5] debug level 2 required to see curl output --- acme.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/acme.sh b/acme.sh index e0b2bc87..0aa19b9b 100755 --- a/acme.sh +++ b/acme.sh @@ -492,12 +492,12 @@ _post() { if [ "$needbase64" ] ; then response="$($CURL -A "User-Agent: $USER_AGENT" -X POST --data "$body" $url | _base64)" if [[ $? -gt 0 ]] ;then - _err "Curl failed with exit code $?, trying running script in DEBUG=1 mode" + _err "Curl failed with exit code $?, trying running script in DEBUG=2 mode" fi else response="$($CURL -A "User-Agent: $USER_AGENT" -X POST --data "$body" $url)" if [[ $? -gt 0 ]] ;then - _err "Curl failed with exit code $?, trying running script in DEBUG=1 mode" + _err "Curl failed with exit code $?, trying running script in DEBUG=2 mode" fi fi else @@ -521,12 +521,12 @@ _get() { if [ "$onlyheader" ] ; then $CURL -I -A "User-Agent: $USER_AGENT" $url if [[ $? -gt 0 ]] ;then - _err "Curl failed with exit code $?, trying running script in DEBUG=1 mode" + _err "Curl failed with exit code $?, trying running script in DEBUG=2 mode" fi else $CURL -A "User-Agent: $USER_AGENT" $url if [[ $? -gt 0 ]] ;then - _err "Curl failed with exit code $?, trying running script in DEBUG=1 mode" + _err "Curl failed with exit code $?, trying running script in DEBUG=2 mode" fi fi else From 83c8248a072e68bbe95859a20f2ad899f7bfd613 Mon Sep 17 00:00:00 2001 From: David Mcanulty Date: Thu, 21 Apr 2016 10:16:37 -0700 Subject: [PATCH 4/5] sh/dash compatible if and changed debug message --- acme.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/acme.sh b/acme.sh index 0aa19b9b..c53c6fa0 100755 --- a/acme.sh +++ b/acme.sh @@ -491,13 +491,13 @@ _post() { CURL="$CURL --dump-header $HTTP_HEADER " if [ "$needbase64" ] ; then response="$($CURL -A "User-Agent: $USER_AGENT" -X POST --data "$body" $url | _base64)" - if [[ $? -gt 0 ]] ;then - _err "Curl failed with exit code $?, trying running script in DEBUG=2 mode" + if [ $? -gt 0 ] ;then + _err "Curl failed with exit code $?, trying running script with --debug 2" fi else response="$($CURL -A "User-Agent: $USER_AGENT" -X POST --data "$body" $url)" - if [[ $? -gt 0 ]] ;then - _err "Curl failed with exit code $?, trying running script in DEBUG=2 mode" + if [ $? -gt 0 ] ;then + _err "Curl failed with exit code $?, trying running script with --debug 2" fi fi else @@ -520,13 +520,13 @@ _get() { if _exists "curl" ; then if [ "$onlyheader" ] ; then $CURL -I -A "User-Agent: $USER_AGENT" $url - if [[ $? -gt 0 ]] ;then - _err "Curl failed with exit code $?, trying running script in DEBUG=2 mode" + if [ $? -gt 0 ] ;then + _err "Curl failed with exit code $?, trying running script with --debug 2" fi else $CURL -A "User-Agent: $USER_AGENT" $url - if [[ $? -gt 0 ]] ;then - _err "Curl failed with exit code $?, trying running script in DEBUG=2 mode" + if [ $? -gt 0 ] ;then + _err "Curl failed with exit code $?, trying running script with --debug 2" fi fi else From 011d39ae23515ed1585053c68b9eefd629d97ae9 Mon Sep 17 00:00:00 2001 From: David Mcanulty Date: Tue, 3 May 2016 11:10:04 -0700 Subject: [PATCH 5/5] Move test to bottom and switched from $? to $ret I could refactor the if/else logic to provide curl|wget in the debug message, but wanted to keep the change simple to hopefully get pulled. --- acme.sh | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/acme.sh b/acme.sh index c53c6fa0..469fffa8 100755 --- a/acme.sh +++ b/acme.sh @@ -520,14 +520,8 @@ _get() { if _exists "curl" ; then if [ "$onlyheader" ] ; then $CURL -I -A "User-Agent: $USER_AGENT" $url - if [ $? -gt 0 ] ;then - _err "Curl failed with exit code $?, trying running script with --debug 2" - fi else $CURL -A "User-Agent: $USER_AGENT" $url - if [ $? -gt 0 ] ;then - _err "Curl failed with exit code $?, trying running script with --debug 2" - fi fi else _debug "WGET" "$WGET" @@ -538,6 +532,9 @@ _get() { fi fi ret=$? + if [ $ret -gt 0 ] ;then + _err "URL get failed with exit code $ret, trying running script with --debug 2" + fi return $ret }