From d761adc50cf4aacbef365f3827e2899044b76878 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 30 Dec 2016 20:38:48 +0100 Subject: Adding hook for notification by mail. Signed-off-by: Daniel Baumann --- share/hooks/notification-mail | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 share/hooks/notification-mail diff --git a/share/hooks/notification-mail b/share/hooks/notification-mail new file mode 100755 index 0000000..8033c01 --- /dev/null +++ b/share/hooks/notification-mail @@ -0,0 +1,31 @@ +#!/bin/sh + +set -e + +if echo "${OPTIONS}" | grep -qs "\--no-notification" +then + exit 0 +fi + +case "${COMMAND}" in + create|remove|rm|restart|start|stop) + DATE="$(date +%Y-%m-%d\ %H:%M:%S)" + HOST="$(hostname -f)" + USER="${SUDO_USER:-${USER}}" + + TMPFILE="$(mktemp ${SOFTWARE}.XXXXXX)" + +cat >> "${TMPFILE}" << EOF +From: ${SOFTWARE} <${USER}@${HOST}> +To: root@localhost +Subject: [${SOFTWARE}] ${PROGRAM} ${COMMAND} + +${DATE} +${USER}@${HOST} +${PROGRAM} ${COMMAND} ${OPTIONS} +EOF + + cat "${TMPFILE}" | /usr/sbin/sendmail -t + rm -f "${TMPFILE}" + ;; +esac -- cgit v1.2.3