Repository navigation
Expand file tree
/
Copy pathconfigure
More file actions
executable file
·116 lines (84 loc) · 2.54 KB
/
Copy pathconfigure
File metadata and controls
executable file
·116 lines (84 loc) · 2.54 KB
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/bin/bash
#### Loading / Writing configuration
function load_prev_config() {
# load the defaults from the file if it exists
if [ -f ".config/save" ]; then
source ".config/save";
# else load some defaults
else
echo "No saved settings found, loading defaults for local development setup. "
SET_MWS_DOMAIN_NAME="localhost"
fi;
}
function save_current_config() {
{
echo "echo \"Loaded previous settings from $(date)\"";
echo_save_line "SET_MWS_DOMAIN_NAME" "$MWS_DOMAIN_NAME";
echo_save_line "SET_MWS_SSL_EMAIL" "$MWS_SSL_EMAIL";
} > .config/save
echo "Wrote .config/save"
}
function echo_save_line() {
echo "$1='$2'"
}
#### Reading configuration settings
function read_mws_domain_name() {
cat << EOF
When running in a production setup, MWS needs to know the domain
name it is running under. Please either enter a domain name now, or
leave it blank to use "$SET_MWS_DOMAIN_NAME".
EOF
printf "MWS_DOMAIN_NAME="
read MWS_DOMAIN_NAME
if [ -z "$MWS_DOMAIN_NAME" ]
then
MWS_DOMAIN_NAME="$SET_MWS_DOMAIN_NAME"
fi;
echo "export MWS_DOMAIN_NAME=$MWS_DOMAIN_NAME"
}
function read_mws_ssl_email() {
cat << EOF
If SSL Certificates should be automatically retrieved, MWS needs to
know an email address to register a new Let’s Encrypt account under.
Please note by entering an email address here, you implicitly agree to
the Let’s Encrypt subscriber agreement currently found under
https://letsencrypt.org/documents/2017.11.15-LE-SA-v1.2.pdf.
Defaults to "$SET_MWS_SSL_EMAIL".
EOF
printf "MWS_SSL_EMAIL="
read MWS_SSL_EMAIL
if [ -z "$MWS_SSL_EMAIL" ]
then
MWS_SSL_EMAIL="$SET_MWS_SSL_EMAIL"
fi;
echo "export MWS_SSL_EMAIL=$MWS_SSL_EMAIL"
}
### Writing configuration
function write_nginx_config() {
echo "DEFAULT_HOST=$MWS_DOMAIN_NAME" > .config/nginx
echo "Wrote .config/nginx"
}
function write_frontend_config() {
echo "VIRTUAL_HOST=$MWS_DOMAIN_NAME" > .config/frontend
if [ ! -z "$MWS_SSL_EMAIL" ]; then
echo "LETSENCRYPT_HOST=$MWS_DOMAIN_NAME" >> .config/frontend
echo "LETSENCRYPT_EMAIL=$MWS_SSL_EMAIL" >> .config/frontend
fi;
echo "Wrote .config/frontend"
}
function main() {
echo "MWS DOCKER CONFIGURATION"
load_prev_config
echo ""
read_mws_domain_name
echo ""
read_mws_ssl_email
echo ""
echo "WRITING CONFIGURATION"
mkdir -p .config
save_current_config
write_nginx_config
write_frontend_config
echo "Done. "
}
main