]> git.street.me.uk Git - andy/dehydrated.git/commitdiff
exit with error message if curl has problems connecting (fixes #133)
authorLukas Schauer <lukas@schauer.so>
Mon, 15 Feb 2016 18:51:35 +0000 (19:51 +0100)
committerLukas Schauer <lukas@schauer.so>
Mon, 15 Feb 2016 18:51:35 +0000 (19:51 +0100)
letsencrypt.sh

index d3877d953753a752ba3e66f8ac548b7f1352ff9b..6f21d1c38d531a64421bb59470150c9f08676a45 100755 (executable)
@@ -238,15 +238,25 @@ _openssl() {
 http_request() {
   tempcont="$(mktemp -t XXXXXX)"
 
+  set +e
   if [[ "${1}" = "head" ]]; then
     statuscode="$(curl -s -w "%{http_code}" -o "${tempcont}" "${2}" -I)"
+    curlret="${?}"
   elif [[ "${1}" = "get" ]]; then
     statuscode="$(curl -s -w "%{http_code}" -o "${tempcont}" "${2}")"
+    curlret="${?}"
   elif [[ "${1}" = "post" ]]; then
     statuscode="$(curl -s -w "%{http_code}" -o "${tempcont}" "${2}" -d "${3}")"
+    curlret="${?}"
   else
+    set -e
     _exiterr "Unknown request method: ${1}"
   fi
+  set -e
+
+  if [[ ! "${curlret}" = "0" ]]; then
+    _exiterr "Problem connecting to server (curl returned with ${curlret})"
+  fi
 
   if [[ ! "${statuscode:0:1}" = "2" ]]; then
     echo "  + ERROR: An error occurred while sending ${1}-request to ${2} (Status ${statuscode})" >&2