Skip to content

Commit

Permalink
Add 'wait_and_retry'.
Browse files Browse the repository at this point in the history
Signed-off-by: Nobuhiro MIKI <nob@bobuhiro11.net>
  • Loading branch information
bobuhiro11 committed Oct 10, 2023
1 parent 87c18a0 commit fc3988b
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion scripts/prepare.bash
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,28 @@ LINUX_VERSION=$3
GIT_URL=$4
GIT_BRANCH=$5

wait_and_retry() {
local retries="$1"
local wait="$2"
local command="${*:3}"

echo "retries=$retries wait=$wait command=$command"

$command
local exit_code=$?

if [[ $exit_code -ne 0 && $retries -gt 0 ]]; then
sleep "$wait"
wait_and_retry $((retries - 1)) "$wait" "$command"
else
return $exit_code
fi
}

sudo bash -c "docker build -t buildenv-busybox - < centos6.Dockerfile"
sudo bash -c "docker build -t \"buildenv-${LINUX_VERSION}\" - < $DOCKERFILE"
test -d "linux-${LINUX_VERSION}" \
|| git clone "${GIT_URL}" --depth 1 -b "${GIT_BRANCH}" "linux-${LINUX_VERSION}"
|| wait_and_retry 5 10 git clone "${GIT_URL}" --depth 1 -b "${GIT_BRANCH}" "linux-${LINUX_VERSION}"
sudo docker run --sysctl net.ipv6.conf.all.disable_ipv6=1 --cap-add=NET_ADMIN \
--rm -v "${CWD}/linux-${LINUX_VERSION}:/tmp" \
"buildenv-${LINUX_VERSION}" \
Expand Down

0 comments on commit fc3988b

Please sign in to comment.