diff --git a/scripts/docker/setup.sh b/scripts/docker/setup.sh index 5551e5b8cc36..678053268ddf 100755 --- a/scripts/docker/setup.sh +++ b/scripts/docker/setup.sh @@ -37,7 +37,11 @@ run_docker_build() { run_docker_pull() { local image="$1" if command -v timeout >/dev/null 2>&1; then - timeout "$DOCKER_PULL_TIMEOUT" docker pull "$image" + if timeout --kill-after=1s 1s true >/dev/null 2>&1; then + timeout --kill-after=30s "$DOCKER_PULL_TIMEOUT" docker pull "$image" + else + timeout "$DOCKER_PULL_TIMEOUT" docker pull "$image" + fi return fi docker pull "$image" diff --git a/scripts/podman/setup.sh b/scripts/podman/setup.sh index 4f6cf47175fb..d3b4bab79208 100755 --- a/scripts/podman/setup.sh +++ b/scripts/podman/setup.sh @@ -47,7 +47,11 @@ fail() { run_podman_pull() { local image="$1" if command -v timeout >/dev/null 2>&1; then - timeout "$PODMAN_PULL_TIMEOUT" podman pull "$image" + if timeout --kill-after=1s 1s true >/dev/null 2>&1; then + timeout --kill-after=30s "$PODMAN_PULL_TIMEOUT" podman pull "$image" + else + timeout "$PODMAN_PULL_TIMEOUT" podman pull "$image" + fi return fi podman pull "$image" diff --git a/test/scripts/test-install-sh-docker.test.ts b/test/scripts/test-install-sh-docker.test.ts index 4a73263dd764..8b0e032e655d 100644 --- a/test/scripts/test-install-sh-docker.test.ts +++ b/test/scripts/test-install-sh-docker.test.ts @@ -126,6 +126,8 @@ describe("test-install-sh-docker", () => { expect(script).toContain('DOCKER_PULL_TIMEOUT="${OPENCLAW_DOCKER_SETUP_PULL_TIMEOUT:-600s}"'); expect(script).toContain("run_docker_pull()"); + expect(script).toContain("timeout --kill-after=1s 1s true"); + expect(script).toContain('timeout --kill-after=30s "$DOCKER_PULL_TIMEOUT" docker pull "$image"'); expect(script).toContain('timeout "$DOCKER_PULL_TIMEOUT" docker pull "$image"'); expect(script).toContain('run_docker_pull "$IMAGE_NAME"'); expect(script).not.toContain('docker pull "$IMAGE_NAME"'); @@ -138,6 +140,8 @@ describe("test-install-sh-docker", () => { 'PODMAN_PULL_TIMEOUT="${OPENCLAW_PODMAN_SETUP_PULL_TIMEOUT:-600s}"', ); expect(script).toContain("run_podman_pull()"); + expect(script).toContain("timeout --kill-after=1s 1s true"); + expect(script).toContain('timeout --kill-after=30s "$PODMAN_PULL_TIMEOUT" podman pull "$image"'); expect(script).toContain('timeout "$PODMAN_PULL_TIMEOUT" podman pull "$image"'); expect(script).toContain('run_podman_pull "$OPENCLAW_IMAGE"'); expect(script).not.toContain('podman pull "$OPENCLAW_IMAGE"');