diff options
author | Daniel Baumann <daniel.baumann@open-infrastructure.net> | 2021-11-15 21:26:02 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@open-infrastructure.net> | 2021-11-15 21:32:51 +0000 |
commit | 58c7c54784b8b52e9a8498ac6f202a791508ca21 (patch) | |
tree | e1b8c48df9489b6114842a4825f0f06b6d87995c /libexec/container | |
parent | Preparing update notifications handling in container update command. (diff) | |
download | compute-tools-58c7c54784b8b52e9a8498ac6f202a791508ca21.tar.xz compute-tools-58c7c54784b8b52e9a8498ac6f202a791508ca21.zip |
Adding notification handling in container update command.
Signed-off-by: Daniel Baumann <daniel.baumann@open-infrastructure.net>
Diffstat (limited to '')
-rwxr-xr-x | libexec/container/update | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/libexec/container/update b/libexec/container/update index 42f42c8..80f154a 100755 --- a/libexec/container/update +++ b/libexec/container/update @@ -128,6 +128,8 @@ do ;; *) + PACKAGES="$(for PACKAGE in $(container run -n ${NAME} -- "apt list \-\-upgradable 2>/dev/null | grep '\/'" | awk -F/ '{ print $1 }'); do echo -n "${PACKAGE} "; done | sed -e 's| $||'; echo)" + case "${FULL_UPGRADE}" in true) container run -n ${NAME} -- "apt ${YES} full-upgrade" @@ -140,6 +142,38 @@ do ;; esac + # Notification + if [ -n "${PACKAGES}" ] + then + CONTAINER_USER="${SUDO_USER:-${USER}}" + + DATE="$(date +%Y-%m-%d\ %H:%M:%S)" + HOST="$(hostname -f 2> /dev/null || hostname)" + + # logfile + echo "${DATE} ${HOST} ${CONTAINER_USER} ${NAME} ${UPDATES} upgraded: ${PACKAGES}" >> "/var/log/${SOFTWARE}/${PROGRAM}.log" + + # irc + if [ -e /usr/bin/irk ] + then + for FILE in "/etc/${SOFTWARE}/${PROGRAM}.conf" "/etc/${SOFTWARE}/${PROGRAM}.conf.d"/*.conf + do + if [ -e "${FILE}" ] + then + . "${FILE}" + fi + done + + if [ -n "${IRK_TARGETS}" ] + then + for TARGET in ${IRK_TARGETS} + do + irk "${TARGET}" "\x0300${CONTAINER_USER}\x03@\x0312${HOST}:\x03 \x0303${NAME}\x03 \x0307${UPDATES} upgraded\x03: ${PACKAGES}" + done + fi + fi + fi + case "${AUTOREMOVE}" in true) container run -n ${NAME} -- "apt ${YES} autoremove ${PURGE}" |