-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·63 lines (48 loc) · 1.64 KB
/
configure
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
#!/bin/bash
#
# Configure script
#
#
# Parse config.yml
#
parse_yaml() {
local prefix=$2
local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034')
sed -ne "s|^\($s\)\($w\)$s:$s\"\(.*\)\"$s\$|\1$fs\2$fs\3|p" \
-e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $1 |
awk -F$fs '{
indent = length($1)/2;
vname[indent] = $2;
for (i in vname) {if (i > indent) {delete vname[i]}}
if (length($3) > 0) {
vn=""; for (i=0; i<indent; i++) {vn=(vn)(vname[i])("_")}
printf("%s%s%s=\"%s\"\n", "'$prefix'",vn, $2, $3);
}
}'
}
if [[ ! -d "src/config" ]]; then
mkdir src/config
fi
#
# Generate gunicorn.cnf
#
eval $(parse_yaml config.yml "config_")
echo "bind = $config_gunicorn_bind" > src/config/gunicorn-cfg.py
echo "workers = $config_gunicorn_workers" >> src/config/gunicorn-cfg.py
echo "accesslog = $config_gunicorn_accesslog" >> src/config/gunicorn-cfg.py
echo "loglevel = $config_gunicorn_loglevel" >> src/config/gunicorn-cfg.py
echo "capture_output = $config_gunicorn_capture_output" >> src/config/gunicorn-cfg.py
echo "enable_stdio_inheritance = $config_gunicorn_enable_stdio_inheritance" >> src/config/gunicorn-cfg.py
#
# Generate api.keys
#
printf "{\n $config_api_example_key : \"example_key\"\n}" > src/api.keys
#
# Generate config.ini
#
cp .config/config.ini src/config/config.ini
sed -i "s/secret_key = /secret_key = ${config_app_secret_key}/" src/config/config.ini
#
# Generate traefik config
#
sed -i -e "s/- \"--certificatesresolvers.myresolver.acme.email=.*\"/- \"--certificatesresolvers.myresolver.acme.email=${config_traefik_letsencrypt_email}\"/" docker-compose-traefik.yml