summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@open-infrastructure.net>2016-12-01 08:24:27 +0000
committerDaniel Baumann <daniel.baumann@open-infrastructure.net>2016-12-04 01:27:32 +0000
commitdf9f347849d45ada9c4b6824b5ff78ad3e4b718f (patch)
treed7ac1215cf2b17d63910303aa9f9b879427aad71 /bin
parentAdding note about configuration files in container manpage. (diff)
downloadcompute-tools-df9f347849d45ada9c4b6824b5ff78ad3e4b718f.tar.xz
compute-tools-df9f347849d45ada9c4b6824b5ff78ad3e4b718f.zip
Logging some container actions in container program to /var/log/container-tools/container.log.
Signed-off-by: Daniel Baumann <daniel.baumann@open-infrastructure.net>
Diffstat (limited to '')
-rwxr-xr-xbin/container17
1 files changed, 17 insertions, 0 deletions
diff --git a/bin/container b/bin/container
index f644e6d..7bb62b8 100755
--- a/bin/container
+++ b/bin/container
@@ -43,5 +43,22 @@ fi
shift 1
OPTIONS="${@}"
+# Notification
+if echo "${OPTIONS}" | grep -qs "\--no-notification"
+then
+ OPTIONS="$(echo "${OPTIONS}" | sed -e 's|--no-notification||')"
+else
+ case "${COMMAND}" in
+ create|remove|rm|restart|start|stop)
+ USER="${SUDO_USER:-${USER}}"
+ DATE="$(date +%Y-%m-%d\ %H:%M:%S)"
+ HOST="$(hostname -f)"
+
+ # logfile
+ echo "${DATE} ${HOST} ${USER} ${PROGRAM} ${COMMAND} ${OPTIONS}" >> "/var/log/${SOFTWARE}/${PROGRAM}.log"
+ ;;
+ esac
+fi
+
# Run
exec "/usr/lib/${SOFTWARE}/${PROGRAM}/${COMMAND}" "${OPTIONS}"