Implement hooks with run-parts #58

This commit is contained in:
Pau Rodriguez-Estivill
2022-08-20 19:29:18 +02:00
parent 1f46aba95a
commit 67ecbb1b3e
5 changed files with 61 additions and 12 deletions
+34
View File
@@ -0,0 +1,34 @@
#!/bin/sh
set -e
# Possible actions: error, pre-backup, post-backup
ACTION="${1}"
if [ "${WEBHOOK_URL}" != "**None**" ]; then
case "${ACTION}" in
"error")
echo "Execute error webhook call to ${WEBHOOK_URL}"
curl --request POST \
--url "${WEBHOOK_URL}" \
--header 'Content-Type: application/json' \
--data '{"status": "error"}' \
--max-time 10 \
--retry 5 \
${WEBHOOK_EXTRA_ARGS}
;;
# "pre-backup")
# echo "Nothing to do"
# ;;
"post-backup")
echo "Execute post-backup webhook call to ${WEBHOOK_URL}"
curl --request POST \
--url "${WEBHOOK_URL}" \
--header 'Content-Type: application/json' \
--data '{"status": "post-backup"}' \
--max-time 10 \
--retry 5 \
${WEBHOOK_EXTRA_ARGS}
;;
esac
fi