Skip to content

Instantly share code, notes, and snippets.

@deeagle
Last active April 30, 2021 09:16
Show Gist options
  • Save deeagle/6ee1129a4e893d04c9ee98e69a7e0839 to your computer and use it in GitHub Desktop.
Save deeagle/6ee1129a4e893d04c9ee98e69a7e0839 to your computer and use it in GitHub Desktop.
Simple log solution to do debian updates and get the problematic updates logged and run repair-debian-lib-XCRYPT_2.0.sh after (further details see: https://gist.github.com/deeagle/768bc0b50bf705e6edb027a04c14c076).
#!/usr/bin/env bash
XCRYPT_CHECK_BIN="/<path-to-folder>/repair-lib-xcrypt2.0.sh"
UPDATE_LIST_PATH="/tmp/debian-xcrypt_2.0-update-log.list"
UPDATE_LOG="/var/log/debian-xcrypt_2.0-update-log.log"
function log() {
local state=${1}
local msg=${2}
printf "%s [%s] %s\n" "$(date --rfc-3339=seconds)" "$@" | tee -a "${UPDATE_LOG}"
}
if [ "${EUID}" -ne 0 ]; then
echo "[ERR!]" "You must run the script as real root because of the repair command."
exit 2
fi
log "INFO" "${0} started."
# reset list if exists
if test -e "${UPDATE_LIST_PATH}"; then
rm "${UPDATE_LIST_PATH}"
fi
# get list of packages to update
aptitude search -F '%p' --disable-columns '~U' | xargs -n 1 >> "${UPDATE_LIST_PATH}"
UPDATES=$(cat ${UPDATE_LIST_PATH})
for UPDATE in ${UPDATES}; do
log "INFO" "Check update of package <${UPDATE}>"
aptitude install -yq "${UPDATE}"
bash "${XCRYPT_CHECK_BIN}" >/dev/null
if [ $? -ne 0 ]; then
log "ERR!" "XCRYPT error after update of package <${UPDATE}>"
bash "${XCRYPT_CHECK_BIN}" -r >/dev/null
fi
done
log "INFO" "${0} successfully finished."
@deeagle
Copy link
Author

deeagle commented Apr 30, 2021

Possible log looks like:

...
2021-04-30 09:33:59+02:00 [INFO] Check update of package <libsystemd0>
2021-04-30 09:34:03+02:00 [INFO] Check update of package <libudev1>
2021-04-30 09:34:10+02:00 [ERR!] XCRYPT error after update of package <libudev1>
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment