summaryrefslogtreecommitdiffstats
path: root/share
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@open-infrastructure.net>2016-12-20 17:37:12 +0000
committerDaniel Baumann <daniel.baumann@open-infrastructure.net>2017-01-28 21:30:57 +0000
commit7e5b3d5c611813155b9a04e4d50a1bde9ee6268c (patch)
treebd7077c9ac262bc87d0b4a06c716d9b3095e8f09 /share
parentPreparing common hooks. (diff)
downloadcompute-tools-7e5b3d5c611813155b9a04e4d50a1bde9ee6268c.tar.xz
compute-tools-7e5b3d5c611813155b9a04e4d50a1bde9ee6268c.zip
Moving logfile notification from container program to hook.
Signed-off-by: Daniel Baumann <daniel.baumann@open-infrastructure.net>
Diffstat (limited to '')
-rwxr-xr-xshare/hooks/notification-logfile23
1 files changed, 23 insertions, 0 deletions
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