Created
May 16, 2023 15:56
-
-
Save protosam/27d15417a92633109a7b25177de594d7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# detect mac os | |
if ! uname | grep -i -q darwin; then | |
echo "ERROR: Only Mac OS is supported." | |
exit 1 | |
fi | |
# kill docker desktop | |
DOCKER_DESKTOP_PID=$(ps aux | grep '/Applications/Docker\.app/Contents/MacOS/Docker$' | awk '{print $2}') | |
if [ ! -z "${DOCKER_DESKTOP_PID}" ]; then | |
kill "${DOCKER_DESKTOP_PID}" | |
echo "Waiting for Docker Desktop to close." | |
while ps aux | grep 'com\.docker|Docker\.app'; do | |
sleep 1 | |
done | |
fi | |
# start docker desktop | |
if open /Applications/Docker.app; then | |
echo "Waiting for Docker Desktop to start." | |
while ! docker ps >/dev/null 2>&1; do | |
sleep 1 | |
done | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment