summaryrefslogtreecommitdiffstats
path: root/share/hooks/notification-logfile
diff options
context:
space:
mode:
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