summaryrefslogtreecommitdiffstats
path: root/share/hooks/notification-irc
blob: 3415b6baa43a58d420b8fefc9301400737abed1c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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} "[\x0305${SOFTWARE}\x03] \x0312${USER}@${HOST}:\x03 \x0303${PROGRAM}\x03 \x0307${COMMAND}\x03 \x0300${OPTIONS}\x03"
		done
		;;
esac