From 452178c0820b1bc317f8543e1a2e4028c4b6f6a1 Mon Sep 17 00:00:00 2001 From: Nick Rhodes Date: Wed, 13 Feb 2019 09:16:22 +0000 Subject: [PATCH] Move the apply phase sleep to before pre-scripts and package manager lock checks. --- auter.aptModule | 9 ++++++--- auter.yumdnfModule | 8 +++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/auter.aptModule b/auter.aptModule index 1346c8e..5c7794e 100644 --- a/auter.aptModule +++ b/auter.aptModule @@ -111,13 +111,16 @@ function apply_updates() { if [[ "${AVAILABLE_PACKAGE_COUNT}" -gt 0 ]]; then local PACKAGES_BEFORE local PACKAGES_AFTER - for SCRIPT in "${PREAPPLYSCRIPTDIR}"/*; do - run_script "${SCRIPT}" "Pre-Apply" - done + # Sleep before running pre-scripts and updates SLEEP_DELAY=$((RANDOM % MAXDELAY)) [[ ${SLEEP_DELAY} -gt 1 ]] && logit "INFO: Sleeping for ${SLEEP_DELAY} seconds" sleep ${SLEEP_DELAY} + + for SCRIPT in "${PREAPPLYSCRIPTDIR}"/*; do + run_script "${SCRIPT}" "Pre-Apply" + done + logit "INFO: Applying updates" PACKAGES_BEFORE=$(dpkg --list) diff --git a/auter.yumdnfModule b/auter.yumdnfModule index 1119014..8f9920e 100644 --- a/auter.yumdnfModule +++ b/auter.yumdnfModule @@ -146,6 +146,11 @@ function apply_updates() { # If check-update has an exit code of 100, updates are available. if [[ "${RC}" -eq 100 ]]; then + # Sleep before continuing with pre-scripts and updates + SLEEP_DELAY=$((RANDOM % MAXDELAY)) + [[ ${SLEEP_DELAY} -gt 1 ]] && logit "INFO: Sleeping for ${SLEEP_DELAY} seconds" + sleep ${SLEEP_DELAY} + # Check for yum.lock file check_package_manager_lock @@ -153,9 +158,6 @@ function apply_updates() { run_script "${SCRIPT}" "Pre-Apply" done - SLEEP_DELAY=$((RANDOM % MAXDELAY)) - [[ ${SLEEP_DELAY} -gt 1 ]] && logit "INFO: Sleeping for ${SLEEP_DELAY} seconds" - sleep ${SLEEP_DELAY} logit "INFO: Applying updates" HISTORY_BEFORE=$(${PACKAGE_MANAGER} history list)