summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xbin/container3
-rwxr-xr-xshare/hooks/notification-logfile23
2 files changed, 23 insertions, 3 deletions
diff --git a/bin/container b/bin/container
index 805dba6..0a6b7e3 100755
--- a/bin/container
+++ b/bin/container
@@ -68,9 +68,6 @@ else
DATE="$(date +%Y-%m-%d\ %H:%M:%S)"
HOST="$(hostname -f)"
- # logfile
- echo "${DATE} ${HOST} ${USER} ${PROGRAM} ${COMMAND} ${OPTIONS}" >> "/var/log/${SOFTWARE}/${PROGRAM}.log"
-
# irc
if [ -e /usr/bin/irk ] && [ -e "/etc/default/${SOFTWARE}" ]
then
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