-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure
executable file
·167 lines (131 loc) · 4.19 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
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
#!/bin/bash
function read_jupyterhub_domain_name() {
cat << EOF
When running in a production setup, JupyterHub needs to know the domain
name it is running under. Please either enter a domain name now, or
leave it blank to use "localhost".
EOF
printf "JUPYTERHUB_DOMAIN_NAME="
read JUPYTERHUB_DOMAIN_NAME
if [ -z "$JUPYTERHUB_DOMAIN_NAME" ]
then
JUPYTERHUB_DOMAIN_NAME="localhost"
fi;
echo "export JUPYTERHUB_DOMAIN_NAME=$JUPYTERHUB_DOMAIN_NAME"
}
function read_mmt_domain_name() {
cat << EOF
When running in a production setup, the MMT-server needs to know the domain
name it is running under. Please either enter a domain name now, or
leave it blank to use "127.0.0.1"
EOF
printf "MMT_DOMAIN_NAME="
read MMT_DOMAIN_NAME
if [ -z "$MMT_DOMAIN_NAME" ]
then
MMT_DOMAIN_NAME="127.0.0.1"
fi;
echo "export MMT_DOMAIN_NAME=$MMT_DOMAIN_NAME"
}
function read_mmt_archives() {
cat << EOF
If you have any MMT-archives that you would like to install, please state them space-separated here.
EOF
rm -f .config/mmt-archives
printf "MMT_ARCHIVES="
read MMT_ARCHIVES
if [ -z "$MMT_ARCHIVES" ]
then
MMT_ARCHIVES="meta/inf MMT/LFX@devel MMT/urtheories@devel ODK/ODK@devel alignments/Public"
fi;
echo "Installing: $MMT_ARCHIVES"
}
function read_db_password() {
cat << EOF
Please select a database password, or leave it blank to use: 12345.
If you have openssl installed you can also generate a password by typing: openssl
EOF
printf "POSTGRES_PASSWORD="
read POSTGRES_PASSWORD
if [ -z "$POSTGRES_PASSWORD" ]
then
POSTGRES_PASSWORD="12345"
fi;
if [ "$POSTGRES_PASSWORD" = "openssl" ]
then
echo "Generating postgres password"
POSTGRES_PASSWORD=$(openssl rand -hex 32)
fi;
echo "export POSTGRES_PASSWORD=$POSTGRES_PASSWORD"
}
function read_jupyterhub_ssl_email() {
cat << EOF
If SSL Certificates should be automatically retrieved, JupyterHub 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.
EOF
printf "JUPYTERHUB_SSL_EMAIL="
read JUPYTERHUB_SSL_EMAIL
echo "export JUPYTERHUB_SSL_EMAIL=$JUPYTERHUB_SSL_EMAIL"
}
function write_nginx_config() {
echo "DEFAULT_HOST=$JUPYTERHUB_DOMAIN_NAME" > .config/nginx
echo "Wrote .config/nginx"
}
function write_mmt_archives() {
echo "MMT_ARCHIVES=$MMT_ARCHIVES" > .config/mmt-archives
echo "Wrote .config/mmt-archives"
}
function write_makefile_config() {
echo "MMT_FRONTEND_BASE_URL=$MMT_DOMAIN_NAME" > .config/makefile
echo "Wrote .config/makefile"
}
function write_jupyterhub_config() {
echo "VIRTUAL_HOST=$JUPYTERHUB_DOMAIN_NAME" > .config/jupyterhub
if [ ! -z "$JUPYTERHUB_SSL_EMAIL" ]; then
echo "MMT_FRONTEND_BASE_URL=https://$MMT_DOMAIN_NAME" >> .config/jupyterhub
echo "LETSENCRYPT_HOST=$JUPYTERHUB_DOMAIN_NAME" >> .config/jupyterhub
echo "LETSENCRYPT_EMAIL=$JUPYTERHUB_SSL_EMAIL" >> .config/jupyterhub
else
echo "MMT_FRONTEND_BASE_URL=http://$MMT_DOMAIN_NAME" >> .config/jupyterhub
fi;
echo "Wrote .config/jupyterhub"
}
function write_mmt_config() {
echo "VIRTUAL_HOST=$MMT_DOMAIN_NAME" > .config/mmt
if [ ! -z "$JUPYTERHUB_SSL_EMAIL" ]; then
echo "LETSENCRYPT_HOST=$MMT_DOMAIN_NAME" >> .config/mmt
echo "LETSENCRYPT_EMAIL=$JUPYTERHUB_SSL_EMAIL" >> .config/mmt
fi;
echo "Wrote .config/mmt"
}
function write_db_password() {
echo "POSTGRES_PASSWORD=$POSTGRES_PASSWORD" > .config/postgres
echo "Wrote .config/postgres"
}
function main() {
echo "JUPYTERHUB DOCKER CONFIGURATION"
echo ""
read_jupyterhub_domain_name
echo ""
read_mmt_domain_name
echo ""
read_mmt_archives
echo ""
read_jupyterhub_ssl_email
echo ""
read_db_password
echo ""
echo "WRITING CONFIGURATION"
mkdir -p .config
write_mmt_archives
write_nginx_config
write_makefile_config
write_jupyterhub_config
write_mmt_config
write_db_password
echo "Done. "
}
main