From 7e5b3d5c611813155b9a04e4d50a1bde9ee6268c Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Tue, 20 Dec 2016 18:37:12 +0100 Subject: Moving logfile notification from container program to hook. Signed-off-by: Daniel Baumann --- share/hooks/notification-logfile | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 share/hooks/notification-logfile (limited to 'share/hooks') diff --git a/share/hooks/notification-logfile b/share/hooks/notification-logfile new file mode 100755 index 0000000..68c7221 --- /dev/null +++ b/share/hooks/notification-logfile @@ -0,0 +1,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 -- cgit v1.2.3