Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added docker daemon check before continuing prep script #20

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 26 additions & 3 deletions scripts/prep.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,33 @@ CURR_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
# shellcheck source=./common.sh
source "$CURR_DIR/common.sh"

section "Cleaning up docker environment (CAREFUL: STEPS ASK TO DELETE EVERYTHING IN DOCKER!)..."
# Function to check docker daemon status
check_docker_daemon() {
local max_attempts=10
local attempt=1

while [ $attempt -le $max_attempts ]; do
if docker info >/dev/null 2>&1; then
echo "Docker daemon is running."
return 0
fi

echo "Waiting for Docker daemon to start... (Attempt $attempt/$max_attempts)"
sleep 2
attempt=$((attempt + 1))
done

echo "Error: Docker daemon did not start within the expected time."
return 1
}

section "Checking Docker daemon status..."
if ! check_docker_daemon; then
echo "Failed to confirm Docker daemon is running. Please start Docker and try again."
exit 1
fi

section "Cleaning up docker environment (CAREFUL: STEPS ASK TO DELETE EVERYTHING IN DOCKER!)..."
if proceed_or_not "Section (Docker Cleanup: CAREFUL!)"; then
info_pause_exec_options "REMOVE docker containers" "docker rm -f $(docker ps -qa | tr '\n' ' ')"
info_pause_exec_options "REMOVE docker networks" "docker network prune -f"
Expand All @@ -24,9 +49,7 @@ docker pull rancher/k3d-tools:5.0.0
docker pull python:3.7-slim

section "Preparing Filesystem..."

if [ -d "/tmp/src" ]; then
rm -rf /tmp/src
fi

mkdir -p /tmp/src