|
18 | 18 | print_style () { |
19 | 19 |
|
20 | 20 | if [ "$2" == "info" ] ; then |
21 | | - COLOR="96m"; |
| 21 | + COLOR="96m" |
22 | 22 | elif [ "$2" == "success" ] ; then |
23 | | - COLOR="92m"; |
| 23 | + COLOR="92m" |
24 | 24 | elif [ "$2" == "warning" ] ; then |
25 | | - COLOR="93m"; |
| 25 | + COLOR="93m" |
26 | 26 | elif [ "$2" == "danger" ] ; then |
27 | | - COLOR="91m"; |
| 27 | + COLOR="91m" |
28 | 28 | else #default color |
29 | | - COLOR="0m"; |
| 29 | + COLOR="0m" |
30 | 30 | fi |
31 | 31 |
|
32 | | - STARTCOLOR="\e[$COLOR"; |
33 | | - ENDCOLOR="\e[0m"; |
| 32 | + STARTCOLOR="\e[$COLOR" |
| 33 | + ENDCOLOR="\e[0m" |
34 | 34 |
|
35 | | - printf "$STARTCOLOR%b$ENDCOLOR" "$1"; |
| 35 | + printf "$STARTCOLOR%b$ENDCOLOR" "$1" |
36 | 36 | } |
37 | 37 |
|
38 | 38 | display_options () { |
39 | 39 | printf "Available options:\n"; |
40 | | - print_style " install" "info"; printf "\t\t Installs docker-sync gem on the host machine.\n"; |
41 | | - print_style " up [services]" "success"; printf "\t Starts docker-sync and runs docker compose.\n"; |
42 | | - print_style " down" "success"; printf "\t\t\t Stops containers and docker-sync.\n"; |
43 | | - print_style " bash" "success"; printf "\t\t\t Opens bash on the workspace.\n"; |
44 | | - print_style " trigger" "success"; printf "\t\t Manually triggers the synchronization of files.\n"; |
45 | | - print_style " clean" "warning"; printf "\t\t Removes all files from docker-sync.\n"; |
| 40 | + print_style " install" "info"; printf "\t\t Installs docker-sync gem on the host machine.\n" |
| 41 | + print_style " up [services]" "success"; printf "\t Starts docker-sync and runs docker compose.\n" |
| 42 | + print_style " down" "success"; printf "\t\t\t Stops containers and docker-sync.\n" |
| 43 | + print_style " bash" "success"; printf "\t\t\t Opens bash on the workspace.\n" |
| 44 | + print_style " trigger" "success"; printf "\t\t Manually triggers the synchronization of files.\n" |
| 45 | + print_style " clean" "warning"; printf "\t\t Removes all files from docker-sync.\n" |
46 | 46 | } |
47 | 47 |
|
48 | 48 | if [[ $# -eq 0 ]] ; then |
49 | | - print_style "Missing arguments.\n" "danger"; |
50 | | - display_options; |
| 49 | + print_style "Missing arguments.\n" "danger" |
| 50 | + display_options |
51 | 51 | exit 1 |
52 | 52 | fi |
53 | 53 |
|
54 | 54 | if [ "$1" == "up" ] ; then |
55 | | - print_style "Initializing Docker Sync\n" "info"; |
56 | | - print_style "May take a long time (15min+) the first run\n" "info"; |
| 55 | + value=$(<sync-services.txt) |
| 56 | + echo "$value" |
| 57 | + |
| 58 | + print_style "Initializing Docker Sync\n" "info" |
| 59 | + print_style "May take a long time (15min+) the first run\n" "info" |
57 | 60 | docker-sync start; |
58 | 61 |
|
59 | | - print_style "Initializing Docker Compose\n" "info"; |
60 | | - shift; # removing first argument |
61 | | - docker-compose -f docker-compose.yml -f docker-compose.sync.yml up -d ${@}; |
| 62 | + print_style "Initializing Docker Compose\n" "info" |
| 63 | + shift # removing first argument |
| 64 | + docker-compose -f docker-compose.yml -f docker-compose.sync.yml up -d "$value" |
62 | 65 |
|
63 | 66 | elif [ "$1" == "down" ]; then |
64 | | - print_style "Stopping Docker Compose\n" "info"; |
65 | | - docker-compose down; |
| 67 | + print_style "Stopping Docker Compose\n" "info" |
| 68 | + docker-compose down |
66 | 69 |
|
67 | | - print_style "Stopping Docker Sync\n" "info"; |
68 | | - docker-sync stop; |
| 70 | + print_style "Stopping Docker Sync\n" "info" |
| 71 | + docker-sync stop |
69 | 72 |
|
70 | 73 | elif [ "$1" == "bash" ]; then |
71 | | - docker-compose exec workspace bash; |
| 74 | + docker-compose exec workspace bash |
72 | 75 |
|
73 | 76 | elif [ "$1" == "install" ]; then |
74 | | - print_style "Installing docker-sync\n" "info"; |
75 | | - gem install docker-sync; |
| 77 | + print_style "Installing docker-sync\n" "info" |
| 78 | + gem install docker-sync |
76 | 79 |
|
77 | 80 | elif [ "$1" == "trigger" ]; then |
78 | | - print_style "Manually triggering sync between host and docker-sync container.\n" "info"; |
| 81 | + print_style "Manually triggering sync between host and docker-sync container.\n" "info" |
79 | 82 | docker-sync sync; |
80 | 83 |
|
81 | 84 | elif [ "$1" == "clean" ]; then |
82 | | - print_style "Removing and cleaning up files from the docker-sync container.\n" "warning"; |
83 | | - docker-sync clean; |
| 85 | + print_style "Removing and cleaning up files from the docker-sync container.\n" "warning" |
| 86 | + docker-sync clean |
84 | 87 | else |
85 | | - print_style "Invalid arguments.\n" "danger"; |
86 | | - display_options; |
| 88 | + print_style "Invalid arguments.\n" "danger" |
| 89 | + display_options |
87 | 90 | exit 1 |
88 | 91 | fi |
0 commit comments