summaryrefslogtreecommitdiffstats
path: root/share/hooks
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@open-infrastructure.net>2016-12-20 17:39:30 +0000
committerDaniel Baumann <daniel.baumann@open-infrastructure.net>2017-01-28 21:30:57 +0000
commitda665e1f9e7c9fb45e2cbb94e783164b1953150f (patch)
treee712a287cbb25b8c3fa193240bf32d1d14071035 /share/hooks
parentMoving logfile notification from container program to hook. (diff)
downloadcompute-tools-da665e1f9e7c9fb45e2cbb94e783164b1953150f.tar.xz
compute-tools-da665e1f9e7c9fb45e2cbb94e783164b1953150f.zip
Moving irc notification from container program to hook.
Signed-off-by: Daniel Baumann <daniel.baumann@open-infrastructure.net>
Diffstat (limited to '')
-rwxr-xr-xshare/hooks/notification-irc35
1 files changed, 35 insertions, 0 deletions
diff --git a/share/hooks/notification-irc b/share/hooks/notification-irc
new file mode 100755
index 0000000..1b4b620
--- /dev/null
+++ b/share/hooks/notification-irc
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+set -e
+
+CONFFILE="${0}.conf"
+
+if echo "${OPTIONS}" | grep -qs "\--no-notification"
+then
+ exit 0
+fi
+
+if [ ! -e /usr/bin/irk ] || [ ! -r "${CONFFILE}" ]
+then
+ exit 0
+fi
+
+. "${CONFFILE}"
+
+if [ -z "${IRC_CHANNELS}" ]
+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}}"
+
+ for CHANNEL in ${IRC_CHANNELS}
+ do
+ irk ${CHANNEL} "\x0300${USER}\x03@\x0312${HOST}:\x03 \x0303${PROGRAM}\x03 \x0307${COMMAND}\x03 ${OPTIONS}"
+ done
+ ;;
+esac