Skip to content

Commit

Permalink
Limit curl retries to 20
Browse files Browse the repository at this point in the history
  • Loading branch information
marcone committed Oct 22, 2023
1 parent 75ccb09 commit 6409e92
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions setup/pi/setup-teslausb
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,16 @@ function setup_progress () {

function curlwrapper () {
setup_progress "curl $*" > /dev/null
local attempts=0
while ! curl -s -S --stderr /tmp/curl.err --fail "$@"
do
attempts=$((attempts + 1))
if [ "$attempts" -ge 20 ]
then
setup_progress "giving up after 20 tries"
setup_progress "$(cat /tmp/curl.err)"
exit 1
fi
setup_progress "'curl $*' failed, retrying" > /dev/null
sntp -S time.google.com || true
sleep 3
Expand Down

0 comments on commit 6409e92

Please sign in to comment.