Skip to content

Instantly share code, notes, and snippets.

@deeagle
Last active April 30, 2021 09:16
Show Gist options
  • Select an option

  • Save deeagle/6ee1129a4e893d04c9ee98e69a7e0839 to your computer and use it in GitHub Desktop.

Select an option

Save deeagle/6ee1129a4e893d04c9ee98e69a7e0839 to your computer and use it in GitHub Desktop.

Revisions

  1. deeagle revised this gist Apr 30, 2021. No changes.
  2. deeagle revised this gist Apr 30, 2021. No changes.
  3. deeagle created this gist Apr 30, 2021.
    39 changes: 39 additions & 0 deletions debian-xcrypt_2.0-update-log.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,39 @@
    #!/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."