From da665e1f9e7c9fb45e2cbb94e783164b1953150f Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Tue, 20 Dec 2016 18:39:30 +0100 Subject: Moving irc notification from container program to hook. Signed-off-by: Daniel Baumann --- share/hooks/notification-irc | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 share/hooks/notification-irc (limited to 'share/hooks') 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 -- cgit v1.2.3