Skip to content

Commit

Permalink
check docker is running or not in prepare_env.sh/prepare_env_wsl.sh (#17
Browse files Browse the repository at this point in the history
)
  • Loading branch information
acezen authored Dec 21, 2020
1 parent a570a31 commit edc0b0e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
17 changes: 15 additions & 2 deletions scripts/prepare_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,23 @@ function install_dependencies() {
chmod +x minikube && sudo mv minikube /usr/local/bin/ && sudo ln /usr/local/bin/minikube /usr/bin/minikube || true
}

if [ -f "${HOME}/.kube/config" ];
then
echo "We found existing kubernetes config, seems that you already have a ready kubernetes cluster"
echo "WARNING: If you do want to reset the kubernetes environment, please delete the existing config by"
echo ""
echo " rm -rf ${HOME}/.kube"
echo ""
echo "and retry this script again."
exit 0
fi

install_dependencies

# start docker daemon
sudo systemctl start docker
# start docker daemon if docker not running.
if ! sudo docker info >/dev/null 2>&1; then
sudo systemctl start docker
fi


# launch k8s cluster
Expand Down
17 changes: 15 additions & 2 deletions scripts/prepare_env_wsl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,23 @@ function install_dependencies() {
chmod +x kind && sudo mv kind /usr/local/bin/ && sudo ln /usr/local/bin/kind /usr/bin/kind || true
}

if [ -f "${HOME}/.kube/config" ];
then
echo "We found existing kubernetes config, seems that you already have a ready kubernetes cluster"
echo "WARNING: If you do want to reset the kubernetes environment, please delete the existing config by"
echo ""
echo " rm -rf ${HOME}/.kube"
echo ""
echo "and retry this script ."
exit 0
fi

install_dependencies

# start docker daemon
sudo dockerd > /dev/null& || true
# start docker daemon if docker not running.
if ! sudo docker info >/dev/null 2>&1; then
sudo dockerd > /dev/null& || true
fi

# launch k8s cluster
echo "$(date '+%Y-%m-%d %H:%M:%S') launch k8s cluster"
Expand Down

0 comments on commit edc0b0e

Please sign in to comment.