Skip to content

Commit a1f8ef9

Browse files
committed
adding default services
1 parent 97d198e commit a1f8ef9

3 files changed

Lines changed: 38 additions & 33 deletions

File tree

config.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
THIS ARE THE DEFAILTS

sync-services.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nginx mysql

sync.sh

Lines changed: 36 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -18,71 +18,74 @@
1818
print_style () {
1919

2020
if [ "$2" == "info" ] ; then
21-
COLOR="96m";
21+
COLOR="96m"
2222
elif [ "$2" == "success" ] ; then
23-
COLOR="92m";
23+
COLOR="92m"
2424
elif [ "$2" == "warning" ] ; then
25-
COLOR="93m";
25+
COLOR="93m"
2626
elif [ "$2" == "danger" ] ; then
27-
COLOR="91m";
27+
COLOR="91m"
2828
else #default color
29-
COLOR="0m";
29+
COLOR="0m"
3030
fi
3131

32-
STARTCOLOR="\e[$COLOR";
33-
ENDCOLOR="\e[0m";
32+
STARTCOLOR="\e[$COLOR"
33+
ENDCOLOR="\e[0m"
3434

35-
printf "$STARTCOLOR%b$ENDCOLOR" "$1";
35+
printf "$STARTCOLOR%b$ENDCOLOR" "$1"
3636
}
3737

3838
display_options () {
3939
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"
4646
}
4747

4848
if [[ $# -eq 0 ]] ; then
49-
print_style "Missing arguments.\n" "danger";
50-
display_options;
49+
print_style "Missing arguments.\n" "danger"
50+
display_options
5151
exit 1
5252
fi
5353

5454
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"
5760
docker-sync start;
5861

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"
6265

6366
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
6669

67-
print_style "Stopping Docker Sync\n" "info";
68-
docker-sync stop;
70+
print_style "Stopping Docker Sync\n" "info"
71+
docker-sync stop
6972

7073
elif [ "$1" == "bash" ]; then
71-
docker-compose exec workspace bash;
74+
docker-compose exec workspace bash
7275

7376
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
7679

7780
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"
7982
docker-sync sync;
8083

8184
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
8487
else
85-
print_style "Invalid arguments.\n" "danger";
86-
display_options;
88+
print_style "Invalid arguments.\n" "danger"
89+
display_options
8790
exit 1
8891
fi

0 commit comments

Comments
 (0)