2017-07-15 21:40:25 +08:00
|
|
|
#!/bin/bash
|
|
|
|
if [[ $# -eq 0 ]] ; then
|
2017-07-16 00:00:44 +08:00
|
|
|
printf "Available commands:\n";
|
|
|
|
printf " install\t\t Installs docker-sync gem on the host machine.\n";
|
|
|
|
printf " up <services>\t Starts docker-sync and runs docker compose.\n";
|
|
|
|
printf " down \t\t Stops containers and docker-sync.\n";
|
|
|
|
printf " trigger \t\t Manually triggers the synchronization of files.\n";
|
|
|
|
printf " clean \t\t Removes all synched files from docker-sync container.\n";
|
2017-07-15 21:40:25 +08:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2017-07-15 21:46:52 +08:00
|
|
|
if [ "$1" == "up" ] ; then
|
2017-07-16 00:00:44 +08:00
|
|
|
printf "Initializing Docker Sync (may take several minutes the first time)";
|
2017-07-15 21:40:25 +08:00
|
|
|
docker-sync start;
|
2017-07-16 00:00:44 +08:00
|
|
|
printf "Initializing Docker Compose";
|
2017-07-15 23:13:50 +08:00
|
|
|
shift; # removing first argument
|
|
|
|
docker-compose -f docker-compose.yml -f docker-compose.sync.yml up -d ${@};
|
2017-07-16 00:00:44 +08:00
|
|
|
|
2017-07-15 21:46:52 +08:00
|
|
|
elif [ "$1" == "down" ]; then
|
2017-07-16 00:00:44 +08:00
|
|
|
printf "Stopping Docker Compose";
|
2017-07-15 21:40:25 +08:00
|
|
|
docker-compose down;
|
2017-07-16 00:00:44 +08:00
|
|
|
printf "Stopping Docker Sync";
|
2017-07-15 21:44:09 +08:00
|
|
|
docker-sync stop;
|
2017-07-16 00:00:44 +08:00
|
|
|
|
2017-07-15 23:01:52 +08:00
|
|
|
elif [ "$1" == "install" ]; then
|
2017-07-16 00:00:44 +08:00
|
|
|
printf "Installing docker-sync";
|
2017-07-15 23:01:52 +08:00
|
|
|
gem install docker-sync;
|
2017-07-16 00:00:44 +08:00
|
|
|
|
|
|
|
elif [ "$1" == "trigger" ]; then
|
|
|
|
printf "Manually triggering sync between host and docker-sync container.";
|
2017-07-15 23:01:52 +08:00
|
|
|
docker-sync sync;
|
2017-07-16 00:00:44 +08:00
|
|
|
|
2017-07-15 23:01:52 +08:00
|
|
|
elif [ "$1" == "clean" ]; then
|
2017-07-16 00:00:44 +08:00
|
|
|
printf "Removing and cleaning up files from the docker-sync container.";
|
2017-07-15 23:01:52 +08:00
|
|
|
docker-sync clean;
|
2017-07-16 00:00:44 +08:00
|
|
|
|
2017-07-15 21:46:52 +08:00
|
|
|
else
|
2017-07-16 00:00:44 +08:00
|
|
|
printf "Invalid argument. Use 'up','down','install','trigger' or 'clean' ";
|
2017-07-15 21:40:25 +08:00
|
|
|
fi
|