summaryrefslogtreecommitdiffstats
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
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 '')
-rw-r--r--Makefile4
-rwxr-xr-xbin/container17
-rw-r--r--share/man/container.1.txt3
-rw-r--r--share/systemd/container@.service6
4 files changed, 27 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 1121655..8553973 100644
--- a/Makefile
+++ b/Makefile
@@ -107,7 +107,11 @@ install: build
mkdir -p $(DESTDIR)/lib/systemd/system
cp -r share/systemd/* $(DESTDIR)/lib/systemd/system
+ mkdir -p $(DESTDIR)/var/log/$(SOFTWARE)
+
uninstall:
+ rmdir --ignore-fail-on-non-empty --parents $(DESTDIR)/var/log/$(SOFTWARE) || true
+
for FILE in share/systemd*; \
do \
if [ -e "$${FILE}" ]; \
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}"
diff --git a/share/man/container.1.txt b/share/man/container.1.txt
index b56a2bd..670efbe 100644
--- a/share/man/container.1.txt
+++ b/share/man/container.1.txt
@@ -108,6 +108,9 @@ The following files are used:
*/var/lib/machines*::
Container root directory.
+*/var/log/container-tools*::
+ Container log files.
+
SEE ALSO
--------
diff --git a/share/systemd/container@.service b/share/systemd/container@.service
index 539139e..4a30ff6 100644
--- a/share/systemd/container@.service
+++ b/share/systemd/container@.service
@@ -4,9 +4,9 @@ Documentation=man:container-tools
[Service]
Type=simple
-ExecStart=/usr/bin/container start --name %i --nspawn
-ExecStartPost=/usr/bin/container start --name %i --start
-ExecStopPost=/usr/bin/container stop -n %i --clean
+ExecStart=/usr/bin/container start --name %i --nspawn --no-notification
+ExecStartPost=/usr/bin/container start --name %i --start --no-notification
+ExecStopPost=/usr/bin/container stop -n %i --clean --no-notification
KillMode=mixed
[Install]