From: Lukas Schauer Date: Mon, 15 Feb 2016 18:51:35 +0000 (+0100) Subject: exit with error message if curl has problems connecting (fixes #133) X-Git-Tag: v0.1.0~21 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1233dc950ce8b7d810f7d0d6c26a0bf09ec1a891;p=thirdparty%2Fdehydrated.git exit with error message if curl has problems connecting (fixes #133) --- diff --git a/letsencrypt.sh b/letsencrypt.sh index d3877d9..6f21d1c 100755 --- a/letsencrypt.sh +++ b/letsencrypt.sh @@ -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