From 462905f137b1055cb3baa1ad71213e3efcd610b1 Mon Sep 17 00:00:00 2001 From: Matt McKinnon Date: Wed, 20 Mar 2019 14:19:18 -0400 Subject: [PATCH] refactor based on error output rather than return code --- bootstrap-salt.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bootstrap-salt.sh b/bootstrap-salt.sh index 57ff6c2..f231872 100755 --- a/bootstrap-salt.sh +++ b/bootstrap-salt.sh @@ -1818,27 +1818,27 @@ __wait_for_apt(){ WAIT_TIMEOUT=900 # Run our passed in apt command - "${@}" + APT_ERR=$(mktemp /tmp/apt_error.XXXX) + "${@}" 2>$APT_ERR APT_RETURN=$? - # If our exit code from apt is 100, then we're waiting on a lock - while [ $APT_RETURN -eq 100 ]; do + # Make sure we're not waiting on a lock + while [ $APT_RETURN -ne 0 ] && [ $(grep -c "^E: Could not get lock" $APT_ERR) -ge 1 ]; do echoinfo "Aware of the lock. Patiently waiting $WAIT_TIMEOUT more seconds..." sleep 1 WAIT_TIMEOUT=$((WAIT_TIMEOUT - 1)) - # If timeout reaches 0, abort. if [ "$WAIT_TIMEOUT" -eq 0 ]; then echoerror "Apt, apt-get, aptitude, or dpkg process is taking too long." echoerror "Bootstrap script cannot proceed. Aborting." return 1 else - # Try running apt again until our return code != 100 "${@}" APT_RETURN=$? fi done + rm $APT_ERR return $APT_RETURN }