diff options
-rwxr-xr-x | bin/container-shell | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/bin/container-shell b/bin/container-shell index 38a9ab9..742e18d 100755 --- a/bin/container-shell +++ b/bin/container-shell @@ -25,12 +25,45 @@ COMMAND="$(basename ${0})" LC_ALL="C.UTF-8" +if [ -n "${SSH_CONNECTION}" ] +then + # ip address + CONTAINER_SHELL_USER="$(echo ${SSH_CONNECTION} | awk '{ print $1 }')" +else + # username + CONTAINER_SHELL_USER="${SUDO_USER:-${USER}}" +fi + Usage () { echo "Usage: ${PROGRAM}-shell" >&2 exit 1 } +Log () +{ + DATE="$(date +%Y-%m-%d\ %H:%M:%S)" + HOST="$(hostname -f)" + MESSAGE="${@}" + + # logfile + echo "${DATE} ${HOST} ${CONTAINER_SHELL_USER} ${MESSAGE}" >> "/var/log/${SOFTWARE}/${PROGRAM}.log" + + # irc + if [ -e /usr/bin/irk ] && [ -e "/etc/default/${SOFTWARE}" ] + then + . /etc/default/${SOFTWARE} + + if [ -n "${IRK_TARGETS}" ] + then + for TARGET in ${IRK_TARGETS} + do + irk ${TARGET} "\x0300${USER}\x03@\x0312${HOST}:\x03 \x0303${PROGRAM}\x03 \x0307${COMMAND}\x03 ${OPTIONS}" + done + fi + fi +} + Shell () { COMMAND="${1}" @@ -105,6 +138,8 @@ Shell () ;; *) + Log "'${COMMAND}' command not allowed" + echo "'${COMMAND}': command not allowed for current user" >&2 return ;; @@ -126,6 +161,8 @@ Shell () case "${COMMAND_DISALLOWED}" in true) + Log "'${COMMAND}' command not allowed" + echo "'${COMMAND}': command not allowed for current user" >&2 return ;; |