mirror of
https://github.com/samply/bridgehead.git
synced 2025-06-17 03:40:14 +02:00
Retry git fetch/pull to make it more resilient to e.g. network outages
This commit is contained in:
@ -136,6 +136,28 @@ setHostname() {
|
||||
fi
|
||||
}
|
||||
|
||||
# from: https://gist.github.com/sj26/88e1c6584397bb7c13bd11108a579746
|
||||
# ex. use: retry 5 /bin/false
|
||||
function retry {
|
||||
local retries=$1
|
||||
shift
|
||||
|
||||
local count=0
|
||||
until "$@"; do
|
||||
exit=$?
|
||||
wait=$((2 ** $count))
|
||||
count=$(($count + 1))
|
||||
if [ $count -lt $retries ]; then
|
||||
echo "Retry $count/$retries exited with code $exit, retrying in $wait seconds..."
|
||||
sleep $wait
|
||||
else
|
||||
echo "Retry $count/$retries exited with code $exit, giving up."
|
||||
return $exit
|
||||
fi
|
||||
done
|
||||
return 0
|
||||
}
|
||||
|
||||
##Setting Network properties
|
||||
# currently not needed
|
||||
#export HOSTIP=$(MSYS_NO_PATHCONV=1 docker run --rm --add-host=host.docker.internal:host-gateway ubuntu cat /etc/hosts | grep 'host.docker.internal' | awk '{print $1}');
|
||||
|
Reference in New Issue
Block a user