summaryrefslogtreecommitdiffstats
path: root/share/hooks/notification-logfile
blob: 68c72218a3d1ad94d4d1da472fb5c95b8403a3be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/sh

set -e

if echo "${OPTIONS}" | grep -qs "\--no-notification"
then
	exit 0
fi

if [ ! -w "/var/log/${SOFTWARE}/${PROGRAM}.log" ]
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}}"

		echo "${DATE} ${HOST} ${USER} ${PROGRAM} ${COMMAND} ${OPTIONS}" >> "/var/log/${SOFTWARE}/${PROGRAM}.log"
		;;
esac