hook API #9

Merged
jlecour merged 4 commits from hook-api into master 2019-04-26 10:43:49 +02:00
2 changed files with 11 additions and 2 deletions
Showing only changes of commit 5ad41113ad - Show all commits

View file

@ -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)

View file

@ -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
}