-
Notifications
You must be signed in to change notification settings - Fork 2
/
generate_config.sh
executable file
·96 lines (80 loc) · 2.21 KB
/
generate_config.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/bash
config_local_list=(
"http://localhost:8082" #BACKEND
"http://localhost:8080" #LANDING
"http://localhost:8083" #SUPPORT
"http://localhost:8081" #FRONTEND
"http://localhost:8084" #FEATURE
"http://localhost:8085" #WEBCHAT
);
APP_DOMAIN="development-cis.appspot.com";
config_development_list=(
"https://backend-dot-$APP_DOMAIN" #BACKEND
"https://$APP_DOMAIN" #LANDING
"https://support-dot-$APP_DOMAIN" #SUPPORT
"https://frontend-dot-$APP_DOMAIN" #FRONTEND
"https://feature-dot-$APP_DOMAIN" #FEATURE
"https://webchat-dot-$APP_DOMAIN" #WEBCHAT
);
APP_DOMAIN="plataformacis.org";
config_production_list=(
"https://backend-dot-eciis-splab.appspot.com" #BACKEND
"https://$APP_DOMAIN" #LANDING
"https://support.$APP_DOMAIN" #SUPPORT
"https://frontend.$APP_DOMAIN" #FRONTEND
"https://feature.$APP_DOMAIN" #FEATURE
"https://webchat.$APP_DOMAIN" #WEBCHAT
);
function create_config {
if [ $# -lt 6 ] ; then
echo "This function requires 6 arguments!";
exit 1;
fi
config="\"use strict\";
var Config = {
BACKEND_URL: '$1',
LANDINGPAGE_URL: '$2',
SUPPORT_URL: '$3',
FRONTEND_URL: '$4',
FEATURE_URL: '$5',
WEBCHAT_URL: '$6',
APP_VERSION: '$7'
};"
echo "$config"
}
function generate_config_file {
app_version=$2;
config_list=();
case $1 in
local)
config_list=${config_local_list[@]};
;;
dev)
config_list=${config_development_list[@]};
;;
prod)
config_list=${config_production_list[@]};
;;
*)
echo "Invalid option!";
exit 1;
;;
esac
config_list=(
${config_list[@]}
$app_version
);
config=$(create_config ${config_list[@]});
for file in ${@:3} ; do
echo "$config" > $file;
done
}
function generate_config_file_with_urls {
app_version=$1;
config_list=(${@:2:5} $app_version);
config=$(create_config ${config_list[@]});
files=${@:7};
for file in ${files[@]} ; do
echo "$config" > $file;
done
}