#!/bin/bash # This shell script is an optional tool to simplify # the installation and usage of laradock with docker-sync. # To run, make sure to add permissions to this file: # chmod 755 sync.sh # Usage: # Install docker-sync: ./sync.sh install # Start sync and services with nginx and mysql: ./sync.sh up nginx mysql # Stop containers and sync: ./sync.sh down # Open bash inside the workspace: ./sync.sh bash # Force sync: ./sync.sh sync trigger # Clean synced files: ./sync.sh clean # prints colored text print_style () { if [ "$2" == "info" ] ; then COLOR="96m" elif [ "$2" == "success" ] ; then COLOR="92m" elif [ "$2" == "warning" ] ; then COLOR="93m" elif [ "$2" == "danger" ] ; then COLOR="91m" else #default color COLOR="0m" fi STARTCOLOR="\e[$COLOR" ENDCOLOR="\e[0m" printf "$STARTCOLOR%b$ENDCOLOR" "$1" } display_options () { printf "Available options:\n"; print_style " install" "info"; printf "\t\t Installs docker-sync gem on the host machine.\n" print_style " up [services]" "success"; printf "\t Starts docker-sync and runs docker compose.\n" print_style " down" "success"; printf "\t\t\t Stops containers and docker-sync.\n" print_style " bash" "success"; printf "\t\t\t Opens bash on the workspace.\n" print_style " trigger" "success"; printf "\t\t Manually triggers the synchronization of files.\n" print_style " clean" "warning"; printf "\t\t Removes all files from docker-sync.\n" } if [[ $# -eq 0 ]] ; then print_style "Missing arguments.\n" "danger" display_options exit 1 fi if [ "$1" == "up" ] ; then value=$(