improved messages
This commit is contained in:
parent
e26ff8bb1e
commit
6bed8d14f1
30
sync.sh
30
sync.sh
|
@ -10,32 +10,37 @@ print_style () {
|
||||||
elif [ "$2" == "warning" ] ; then
|
elif [ "$2" == "warning" ] ; then
|
||||||
COLOR="93m";
|
COLOR="93m";
|
||||||
elif [ "$2" == "danger" ] ; then
|
elif [ "$2" == "danger" ] ; then
|
||||||
COLOR="41m";
|
COLOR="91m";
|
||||||
else #white
|
else #default color
|
||||||
COLOR="97m";
|
COLOR="0m";
|
||||||
fi
|
fi
|
||||||
|
|
||||||
STARTCOLOR="\e[1;$COLOR";
|
STARTCOLOR="\e[$COLOR";
|
||||||
ENDCOLOR="\e[m";
|
ENDCOLOR="\e[0m";
|
||||||
|
|
||||||
printf "$STARTCOLOR%b$ENDCOLOR" "$1";
|
printf "$STARTCOLOR%b$ENDCOLOR" "$1";
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ $# -eq 0 ]] ; then
|
display_options () {
|
||||||
print_style "Invalid argument." "danger"; printf " Available commands:\n";
|
printf "Available options:\n";
|
||||||
print_style " install" "success"; printf "\t\t Installs docker-sync gem on the host machine.\n";
|
print_style " install" "success"; 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 " 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 " down" "success"; printf "\t\t\t Stops containers and docker-sync.\n";
|
||||||
print_style " trigger" "success"; printf "\t\t Manually triggers the synchronization of files.\n";
|
print_style " trigger" "success"; printf "\t\t Manually triggers the synchronization of files.\n";
|
||||||
print_style " clean" "warning"; printf "\t\t Removes all synched files from docker-sync container.\n";
|
print_style " clean" "warning"; printf "\t\t Removes all files from the docker-sync container.\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ $# -eq 0 ]] ; then
|
||||||
|
print_style "Missing arguments.\n" "danger";
|
||||||
|
display_options;
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$1" == "up" ] ; then
|
if [ "$1" == "up" ] ; then
|
||||||
print_style "Initializing Docker Sync\n" "info";
|
print_style "Initializing Docker Sync\n" "info";
|
||||||
print_style "May take a long time (15min+) the first time\n" "info";
|
print_style "May take a long time (15min+) the first run\n" "info";
|
||||||
docker-sync start;
|
docker-sync start;
|
||||||
|
|
||||||
print_style "Initializing Docker Compose\n" "info";
|
print_style "Initializing Docker Compose\n" "info";
|
||||||
shift; # removing first argument
|
shift; # removing first argument
|
||||||
docker-compose -f docker-compose.yml -f docker-compose.sync.yml up -d ${@};
|
docker-compose -f docker-compose.yml -f docker-compose.sync.yml up -d ${@};
|
||||||
|
@ -43,6 +48,7 @@ if [ "$1" == "up" ] ; then
|
||||||
elif [ "$1" == "down" ]; then
|
elif [ "$1" == "down" ]; then
|
||||||
print_style "Stopping Docker Compose\n" "info";
|
print_style "Stopping Docker Compose\n" "info";
|
||||||
docker-compose down;
|
docker-compose down;
|
||||||
|
|
||||||
print_style "Stopping Docker Sync\n" "info";
|
print_style "Stopping Docker Sync\n" "info";
|
||||||
docker-sync stop;
|
docker-sync stop;
|
||||||
|
|
||||||
|
@ -59,5 +65,7 @@ elif [ "$1" == "clean" ]; then
|
||||||
docker-sync clean;
|
docker-sync clean;
|
||||||
|
|
||||||
else
|
else
|
||||||
print_style "Invalid argument. Use 'up','down','install','trigger' or 'clean'" "danger";
|
print_style "Invalid arguments.\n" "danger";
|
||||||
|
display_options;
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue