1
0
Fork 0
mirror of https://github.com/yavook/kiwi-backup.git synced 2024-11-25 08:03:01 +00:00

Merge branch 'release/0.12.0'

This commit is contained in:
Jörn-Michael Miehe 2022-10-24 01:37:06 +02:00
commit 2d520afecb
4 changed files with 44 additions and 14 deletions

View file

@ -9,6 +9,7 @@ RUN set -ex; \
# duplicity software dependencies # duplicity software dependencies
apk --no-cache add \ apk --no-cache add \
ca-certificates \ ca-certificates \
curl \
gettext \ gettext \
gnupg \ gnupg \
lftp \ lftp \
@ -101,6 +102,9 @@ ENV \
OPTIONS_CLEANUP="" \ OPTIONS_CLEANUP="" \
OPTIONS_RMFULL="" \ OPTIONS_RMFULL="" \
OPTIONS_RMINCR="" \ OPTIONS_RMINCR="" \
WEBHOOK_URL="" \
WEBHOOK_FAIL_URL="" \
WEBHOOK_INSECURE="" \
\ \
############## ##############
# ENCRYPTION # # ENCRYPTION #

View file

@ -166,6 +166,9 @@ backup:
# Webhook to be pinged on action (use "%%MSG%%" as a placeholder for a message) # Webhook to be pinged on action (use "%%MSG%%" as a placeholder for a message)
WEBHOOK_URL: "" WEBHOOK_URL: ""
# Webhook to be pinged on failed action (use "%%MSG%%" as a placeholder for a message)
WEBHOOK_FAIL_URL: ""
# Allow self-signed certificates on webhook target # Allow self-signed certificates on webhook target
WEBHOOK_INSECURE: "0" WEBHOOK_INSECURE: "0"
``` ```

View file

@ -19,20 +19,25 @@ if [ -n "${GPG_PASSPHRASE}" ]; then
unset GPG_PASSPHRASE unset GPG_PASSPHRASE
fi fi
# run webhook # run start webhook
if [ -n "${WEBHOOK_URL}" ]; then /usr/local/libexec/kiwi-cron/run_webhook \
wget_args="" "${WEBHOOK_URL}" "running task ${*}" "${WEBHOOK_INSECURE}"
if [ "${WEBHOOK_INSECURE}" = "1" ]; then
wget_args="--no-check-certificate"
fi
WEBHOOK_URL="$(echo "${WEBHOOK_URL}" | sed "s,%%MSG%%,running%20task%20${*},g" )"
wget -O /dev/null ${wget_args} "${WEBHOOK_URL}" 1>/dev/null 2>/dev/null
fi
# hand over # hand over
set -ex set -ex
exec $( \ eval "$( \
"${this_dir}/build_command" \ "${this_dir}/build_command" \
"${@}" \ "${@}" \
) )"
exit_status="${?}"
# run finish webhook
if [ "${exit_status}" -eq "0" ]; then
/usr/local/libexec/kiwi-cron/run_webhook \
"${WEBHOOK_URL}" "task ${*} successful" "${WEBHOOK_INSECURE}"
else
/usr/local/libexec/kiwi-cron/run_webhook \
"${WEBHOOK_FAIL_URL:-${WEBHOOK_URL}}" "task ${*} failed, status ${exit_status}" "${WEBHOOK_INSECURE}"
fi

18
libexec/kiwi-backup/run_webhook Executable file
View file

@ -0,0 +1,18 @@
#!/bin/sh
message="$(echo "${2}" | sed "s,\s,%20,g" )"
webhook_url="$(echo "${1}" | sed "s,%%MSG%%,${message},g" )"
webhook_insecure="${3:-0}"
if [ -z "${webhook_url}" ]; then
return 1
fi
curl_args=""
if [ "${webhook_insecure}" = "1" ]; then
curl_args="--insecure"
fi
curl ${curl_args} "${webhook_url}" 1>/dev/null 2>/dev/null