diff --git a/README.md b/README.md index e46d56b..a492f59 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,8 @@ Options --no-mail disable the mail hook --db enable the database hook (default) --no-db disable the database hook + --api enable the API hook (default) + --no-api disable the API hook --commit enable the commit hook (default) --no-commit disable the commit hook --evocheck enable evocheck execution (default) diff --git a/evomaintenance.sh b/evomaintenance.sh index d99c536..7b580ff 100755 --- a/evomaintenance.sh +++ b/evomaintenance.sh @@ -231,7 +231,7 @@ hook_api() { fi if [ "${DRY_RUN}" != "1" ] && [ -x "${CURL_BIN}" ]; then - curl -s -X POST \ + API_RETURN_STATUS=$(curl -s -o /dev/null -X POST \ "${API_ENDPOINT}" -k \ -F api_key="${API_KEY}" \ -F action=insertEvoMaintenance \ @@ -240,7 +240,14 @@ hook_api() { -F ipaddress="${IP}" \ -F begin_date="${BEGIN_DATE}" \ -F end_date='now()' \ - -F details="${MESSAGE}" > /dev/null + -F details="${MESSAGE}" \ + -w '%{http_code}') + + if [ "$API_RETURN_STATUS" -eq 200 ]; then + echo "Evomaintenance successfully sent to the API." + else + printf "Error while sending data to the API (code %s).\n" "${API_RETURN_STATUS}" + fi fi }