summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@open-infrastructure.net>2021-06-06 17:22:05 +0000
committerDaniel Baumann <daniel.baumann@open-infrastructure.net>2021-06-29 11:19:43 +0000
commit730ff3c91aaf71b667cb5a713ac388df361fc79a (patch)
treea5bf3b583a2a79aaa9208939f9bc2a736fe857bc /bin
parentHandling container run command aequivalent to container enter in bash-complet... (diff)
downloadcompute-tools-730ff3c91aaf71b667cb5a713ac388df361fc79a.tar.xz
compute-tools-730ff3c91aaf71b667cb5a713ac388df361fc79a.zip
Using container-specific user-variable when logging container commands before falling back to system environment.
Signed-off-by: Daniel Baumann <daniel.baumann@open-infrastructure.net>
Diffstat (limited to 'bin')
-rwxr-xr-xbin/container10
1 files changed, 7 insertions, 3 deletions
diff --git a/bin/container b/bin/container
index c3748d9..3e329c9 100755
--- a/bin/container
+++ b/bin/container
@@ -66,12 +66,16 @@ do
else
case "${COMMAND}" in
create|cr|move|mv|remove|rm|restart|rt|start|s|stop|t)
- USER="${SUDO_USER:-${USER}}"
+ if [ -z "${CONTAINER_USER}" ]
+ then
+ CONTAINER_USER="${SUDO_USER:-${USER}}"
+ fi
+
DATE="$(date +%Y-%m-%d\ %H:%M:%S)"
HOST="$(hostname -f 2> /dev/null || hostname)"
# logfile
- echo "${DATE} ${HOST} ${USER} ${PROGRAM} ${COMMAND} ${OPTIONS}" >> "/var/log/${SOFTWARE}/${PROGRAM}.log"
+ echo "${DATE} ${HOST} ${CONTAINER_USER} ${PROGRAM} ${COMMAND} ${OPTIONS}" >> "/var/log/${SOFTWARE}/${PROGRAM}.log"
# irc
if [ -e /usr/bin/irk ] && [ -e "/etc/${SOFTWARE}.conf" ]
@@ -82,7 +86,7 @@ do
then
for TARGET in ${IRK_TARGETS}
do
- irk ${TARGET} "\x0300${USER}\x03@\x0312${HOST}:\x03 \x0303${PROGRAM}\x03 \x0307${COMMAND}\x03 ${OPTIONS}"
+ irk ${TARGET} "\x0300${CONTAINER_USER}\x03@\x0312${HOST}:\x03 \x0303${PROGRAM}\x03 \x0307${COMMAND}\x03 ${OPTIONS}"
done
fi
fi