From df9f347849d45ada9c4b6824b5ff78ad3e4b718f Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 1 Dec 2016 09:24:27 +0100 Subject: Logging some container actions in container program to /var/log/container-tools/container.log. Signed-off-by: Daniel Baumann --- bin/container | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'bin') 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}" -- cgit v1.2.3