summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2021-11-16 06:00:51 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2021-11-16 06:00:51 +0000
commit902f8aaf5115f62e26fc7e8dd2f1c67dcee4508a (patch)
treebd95e580b5098d6b2417f193002070f48953b2e0
parentAdding upstream version 20211115. (diff)
downloadopen-infrastructure-compute-tools-902f8aaf5115f62e26fc7e8dd2f1c67dcee4508a.tar.xz
open-infrastructure-compute-tools-902f8aaf5115f62e26fc7e8dd2f1c67dcee4508a.zip
Adding upstream version 20211116.upstream/20211116
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
-rw-r--r--CHANGELOG.txt11
-rw-r--r--VERSION.txt2
-rwxr-xr-xlibexec/container/update96
3 files changed, 72 insertions, 37 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index cdef7dd..34f4308 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -1,3 +1,14 @@
+2021-11-16 Daniel Baumann <daniel.baumann@open-infrastructure.net>
+
+ * Releasing version 20211116.
+
+ [ Daniel Baumann ]
+ * Adding comment about using grep to de-colorize apt messages in container update command.
+ * Making container update command work entirely non-interactive.
+ * Updating notifications in container update command.
+ * Refactoring notification in container update command.
+ * Adding notificiations for autoremovals in container update command.
+
2021-11-15 Daniel Baumann <daniel.baumann@open-infrastructure.net>
* Releasing version 20211115.
diff --git a/VERSION.txt b/VERSION.txt
index 4dc8ff2..7090fb4 100644
--- a/VERSION.txt
+++ b/VERSION.txt
@@ -1 +1 @@
-20211115
+20211116
diff --git a/libexec/container/update b/libexec/container/update
index 80f154a..de76942 100755
--- a/libexec/container/update
+++ b/libexec/container/update
@@ -93,6 +93,46 @@ Usage ()
Parameters "${@}"
+Notification ()
+{
+ TYPE="${1}"
+ NUMBER="${2}"
+ PACKAGES="${3}"
+
+ if [ -z "${PACKAGES}" ]
+ then
+ return
+ fi
+
+ 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} ${NUMBER} ${TYPE}: ${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${NUMBER} ${TYPE}\x03: ${PACKAGES}"
+ done
+ fi
+ fi
+}
+
case "${NAME}" in
ALL)
NAMES="$(container list --started --format shell)"
@@ -121,62 +161,46 @@ do
container run -n ${NAME} -- "apt update"
- UPDATES="$(container run -n ${NAME} -- "apt \-\-simulate full-upgrade" | awk '/^[0-9]* upgraded, / { print $1 }')"
+ UPDATE_NUMBER="$(container run -n ${NAME} -- "apt \-\-simulate full-upgrade" | awk '/^[0-9]* upgraded, / { print $1 }')"
- case "${UPDATES}" in
+ case "${UPDATE_NUMBER}" in
0)
;;
*)
- 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)"
+ # usefull use of grep to de-colorize apt output
+ UPDATE_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"
+ container run -n ${NAME} -- "DEBCONF_FRONTEND='noninteractive' DEBCONF_PRIORITY='critical' apt \-o Dpkg::Options::=\-\-force-confold ${YES} full-upgrade"
;;
*)
- container run -n ${NAME} -- "apt ${YES} upgrade"
+ container run -n ${NAME} -- "DEBCONF_FRONTEND='noninteractive' DEBCONF_PRIORITY='critical' apt \-o Dpkg::Options::=\-\-force-confold ${YES} upgrade"
;;
esac
+
+ Notification "update(s)" "${UPDATE_NUMBER}" "${UPDATE_PACKAGES}"
;;
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)"
+ case "${AUTOREMOVE}" in
+ true)
+ REMOVE_NUMBER="$(container run -n ${NAME} -- "apt \-\-simulate autoremove" | awk '/^[0-9]* upgraded, / { print $6 }')"
- # logfile
- echo "${DATE} ${HOST} ${CONTAINER_USER} ${NAME} ${UPDATES} upgraded: ${PACKAGES}" >> "/var/log/${SOFTWARE}/${PROGRAM}.log"
+ case "${REMOVE_NUMBER}" in
+ 0)
+ ;;
- # 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
+ *)
+ REMOVE_PACKAGES="$(for LINE in $(container run -n ${NAME} -- "apt \-\-simulate autoremove" | grep '^ '); do echo ${LINE}; done | sed -e 's|^ ||' -e 's| $||'; echo)"
- 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
+ container run -n ${NAME} -- "apt ${YES} autoremove ${PURGE}"
- case "${AUTOREMOVE}" in
- true)
- container run -n ${NAME} -- "apt ${YES} autoremove ${PURGE}"
+ Notification "removal(s)" "${REMOVE_NUMBER}" "$(echo ${REMOVE_PACKAGES})"
+ ;;
+ esac
;;
esac