Skip to content

Commit

Permalink
Merge pull request #18 from barrettj12/apt-timeout
Browse files Browse the repository at this point in the history
Add max attempts to package manager loop
  • Loading branch information
barrettj12 authored Oct 24, 2022
2 parents 2ed4de2 + 3e9dee7 commit 6786bbb
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions config/global_constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,19 @@ package config
const (
// PackageManagerLoopFunction is a bash function that executes its arguments
// in a loop with a delay until either the command either returns
// with an exit code other than 100.
// with an exit code other than 100. It times out after 5 failed attempts.
PackageManagerLoopFunction = `
function package_manager_loop {
local attempts=0
local rc=
while true; do
attempts=$((attempts+1))
if ($*); then
return 0
else
rc=$?
fi
if [ $rc -eq 100 ]; then
if [ $attempts -lt 5 -a $rc -eq 100 ]; then
sleep 10s
continue
fi
Expand Down

0 comments on commit 6786bbb

Please sign in to comment.