Created
August 31, 2018 12:40
-
-
Save ErikFontanel/ab80f4b2b6abb64f2a6dfe87b5526198 to your computer and use it in GitHub Desktop.
Start docker daemon if it's not already when docker-compose up is ran
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 | |
# spinner | |
# @see https://stackoverflow.com/questions/238073/how-to-add-a-progress-bar-to-a-shell-script | |
sp="/-\|" | |
sc=0 | |
spin() { | |
printf "\b${sp:sc++:1}" | |
((sc==${#sp})) && sc=0 | |
} | |
endspin() { | |
printf "\r%s\n" "$@" | |
} | |
# Check if Docker is running, if not, launch and wait for ready | |
startdocker() { | |
if ! docker system info; then | |
echo -e "\e[36mLaunching Docker…\e[0m"; | |
open --background -a Docker; | |
while ! docker system info > /dev/null 2>&1; | |
spin | |
do sleep 1; | |
done | |
endspin | |
fi | |
} | |
# Start project | |
up() { | |
startdocker; | |
if [[ -n $1 ]]; then | |
cd $SITES/$1 || return; | |
fi | |
docker-compose up -d; | |
} | |
down() { | |
if [[ -n $1 ]]; then | |
cd $SITES/$1 || return; | |
fi | |
docker-compose down; | |
} | |
restart() { | |
if [[ -n $1 ]]; then | |
cd $SITES/$1 || return; | |
fi | |
docker-compose restart; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment