summaryrefslogtreecommitdiffstats
path: root/share
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xshare/hooks/notification-mail31
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