diff options
author | Daniel Baumann <daniel.baumann@open-infrastructure.net> | 2016-12-30 19:38:48 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@open-infrastructure.net> | 2017-01-28 21:30:57 +0000 |
commit | d761adc50cf4aacbef365f3827e2899044b76878 (patch) | |
tree | 84844f20ada98d3beae8c9b78c2fe42fa1853ca5 /share | |
parent | Prefixing irc notification with container-tools. (diff) | |
download | compute-tools-d761adc50cf4aacbef365f3827e2899044b76878.tar.xz compute-tools-d761adc50cf4aacbef365f3827e2899044b76878.zip |
Adding hook for notification by mail.
Signed-off-by: Daniel Baumann <daniel.baumann@open-infrastructure.net>
Diffstat (limited to '')
-rwxr-xr-x | share/hooks/notification-mail | 31 |
1 files changed, 31 insertions, 0 deletions
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 |