|
@@ -0,0 +1,465 @@
|
|
1
|
+#!/bin/bash
|
|
2
|
+#
|
|
3
|
+# _____ _ _
|
|
4
|
+# | __|___ ___ ___ _| |___ _____| |_ ___ ___ ___
|
|
5
|
+# | __| _| -_| -_| . | . | | . | . | | -_|
|
|
6
|
+# |__| |_| |___|___|___|___|_|_|_|___|___|_|_|___|
|
|
7
|
+#
|
|
8
|
+# Freedom in the Cloud
|
|
9
|
+#
|
|
10
|
+# This needs python 3.6, which is later than the debian version
|
|
11
|
+#
|
|
12
|
+# License
|
|
13
|
+# =======
|
|
14
|
+#
|
|
15
|
+# Copyright (C) 2018 Bob Mottram <bob@freedombone.net>
|
|
16
|
+#
|
|
17
|
+# This program is free software: you can redistribute it and/or modify
|
|
18
|
+# it under the terms of the GNU Affero General Public License as published by
|
|
19
|
+# the Free Software Foundation, either version 3 of the License, or
|
|
20
|
+# (at your option) any later version.
|
|
21
|
+#
|
|
22
|
+# This program is distributed in the hope that it will be useful,
|
|
23
|
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
24
|
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
25
|
+# GNU Affero General Public License for more details.
|
|
26
|
+#
|
|
27
|
+# You should have received a copy of the GNU Affero General Public License
|
|
28
|
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
29
|
+
|
|
30
|
+VARIANTS=''
|
|
31
|
+
|
|
32
|
+IN_DEFAULT_INSTALL=0
|
|
33
|
+SHOW_ON_ABOUT=1
|
|
34
|
+
|
|
35
|
+MICROBLOGPUB_DOMAIN_NAME=
|
|
36
|
+MICROBLOGPUB_CODE=
|
|
37
|
+MICROBLOGPUB_ONION_PORT=9261
|
|
38
|
+MICROBLOGPUB_REPO="https://github.com/tsileo/microblog.pub"
|
|
39
|
+MICROBLOGPUB_COMMIT='791e55c7f5eee26792b90b94668d5f0dbbc767f9'
|
|
40
|
+MICROBLOGPUB_PORT_INTERNAL=5005
|
|
41
|
+
|
|
42
|
+# These parameters are used by the FreedomBox mobile app
|
|
43
|
+MICROBLOGPUB_SHORT_DESCRIPTION=
|
|
44
|
+MICROBLOGPUB_DESCRIPTION=
|
|
45
|
+MICROBLOGPUB_MOBILE_APP_URL=
|
|
46
|
+
|
|
47
|
+microblogpub_variables=(ONION_ONLY
|
|
48
|
+ MICROBLOGPUB_DOMAIN_NAME
|
|
49
|
+ MICROBLOGPUB_CODE
|
|
50
|
+ DDNS_PROVIDER
|
|
51
|
+ MY_USERNAME)
|
|
52
|
+
|
|
53
|
+function logging_on_microblogpub {
|
|
54
|
+ echo -n ''
|
|
55
|
+}
|
|
56
|
+
|
|
57
|
+function logging_off_microblogpub {
|
|
58
|
+ echo -n ''
|
|
59
|
+}
|
|
60
|
+
|
|
61
|
+function remove_user_microblogpub {
|
|
62
|
+ remove_username="$1"
|
|
63
|
+
|
|
64
|
+ "${PROJECT_NAME}-pass" -u "$remove_username" --rmapp microblogpub
|
|
65
|
+}
|
|
66
|
+
|
|
67
|
+function add_user_microblogpub {
|
|
68
|
+ new_username="$1"
|
|
69
|
+ new_user_password="$2"
|
|
70
|
+
|
|
71
|
+ "${PROJECT_NAME}-pass" -u "$new_username" -a microblogpub -p "$new_user_password"
|
|
72
|
+ echo '0'
|
|
73
|
+}
|
|
74
|
+
|
|
75
|
+function install_interactive_microblogpub {
|
|
76
|
+ if [ ! "$ONION_ONLY" ]; then
|
|
77
|
+ ONION_ONLY='no'
|
|
78
|
+ fi
|
|
79
|
+
|
|
80
|
+ if [[ "$ONION_ONLY" != "no" ]]; then
|
|
81
|
+ MICROBLOGPUB_DOMAIN_NAME='microblogpub.local'
|
|
82
|
+ write_config_param "MICROBLOGPUB_DOMAIN_NAME" "$MICROBLOGPUB_DOMAIN_NAME"
|
|
83
|
+ else
|
|
84
|
+ interactive_site_details "microblogpub" "MICROBLOGPUB_DOMAIN_NAME" "MICROBLOGPUB_CODE"
|
|
85
|
+ fi
|
|
86
|
+ APP_INSTALLED=1
|
|
87
|
+}
|
|
88
|
+
|
|
89
|
+function change_password_microblogpub {
|
|
90
|
+ #curr_username="$1"
|
|
91
|
+ new_user_password="$2"
|
|
92
|
+
|
|
93
|
+ read_config_param 'MY_USERNAME'
|
|
94
|
+ read_config_param 'MICROBLOGPUB_DOMAIN_NAME'
|
|
95
|
+
|
|
96
|
+ "${PROJECT_NAME}-pass" -u "$MY_USERNAME" -a microblogpub -p "$new_user_password"
|
|
97
|
+
|
|
98
|
+ { echo 'import bcrypt';
|
|
99
|
+ echo "print(bcrypt.hashpw(\"$new_user_password\", bcrypt.gensalt()).decode('utf-8'))"; } > /tmp/microblogpub
|
|
100
|
+ MICROBLOGPUB_HASHED_PASSWORD=$(python /tmp/microblogpub)
|
|
101
|
+ rm /tmp/microblogpub
|
|
102
|
+}
|
|
103
|
+
|
|
104
|
+function microblogpub_create_database {
|
|
105
|
+ if [ -f "$IMAGE_PASSWORD_FILE" ]; then
|
|
106
|
+ MICROBLOGPUB_ADMIN_PASSWORD="$(printf "%d" "$(cat "")")"
|
|
107
|
+ else
|
|
108
|
+ if [ ! "$MICROBLOGPUB_ADMIN_PASSWORD" ]; then
|
|
109
|
+ MICROBLOGPUB_ADMIN_PASSWORD=$(create_password "${MINIMUM_PASSWORD_LENGTH}")
|
|
110
|
+ fi
|
|
111
|
+ fi
|
|
112
|
+ if [ ! "$MICROBLOGPUB_ADMIN_PASSWORD" ]; then
|
|
113
|
+ return
|
|
114
|
+ fi
|
|
115
|
+
|
|
116
|
+ create_database_mongodb microblogpub "$MICROBLOGPUB_ADMIN_PASSWORD" "$MY_USERNAME"
|
|
117
|
+}
|
|
118
|
+
|
|
119
|
+function reconfigure_microblogpub {
|
|
120
|
+ # This is used if you need to switch identity. Dump old keys and generate new ones
|
|
121
|
+ echo -n ''
|
|
122
|
+}
|
|
123
|
+
|
|
124
|
+function configure_interactive_microblogpub {
|
|
125
|
+ W=(1 $"Option 1"
|
|
126
|
+ 2 $"Option 2")
|
|
127
|
+
|
|
128
|
+ while true
|
|
129
|
+ do
|
|
130
|
+ # shellcheck disable=SC2068
|
|
131
|
+ selection=$(dialog --backtitle $"Freedombone Administrator Control Panel" --title $"microblogpub" --menu $"Choose an operation, or ESC for main menu:" 14 70 3 "${W[@]}" 3>&2 2>&1 1>&3)
|
|
132
|
+
|
|
133
|
+ if [ ! "$selection" ]; then
|
|
134
|
+ break
|
|
135
|
+ fi
|
|
136
|
+ case $selection in
|
|
137
|
+ 1) # call some function for option 1
|
|
138
|
+ ;;
|
|
139
|
+ 2) # call some function for option 2
|
|
140
|
+ ;;
|
|
141
|
+ esac
|
|
142
|
+ done
|
|
143
|
+}
|
|
144
|
+
|
|
145
|
+function upgrade_microblogpub {
|
|
146
|
+ CURR_MICROBLOGPUB_COMMIT=$(get_completion_param "microblogpub commit")
|
|
147
|
+ if [[ "$CURR_MICROBLOGPUB_COMMIT" == "$MICROBLOGPUB_COMMIT" ]]; then
|
|
148
|
+ return
|
|
149
|
+ fi
|
|
150
|
+
|
|
151
|
+ if grep -q "microblogpub domain" "$COMPLETION_FILE"; then
|
|
152
|
+ MICROBLOGPUB_DOMAIN_NAME=$(get_completion_param "microblogpub domain")
|
|
153
|
+ fi
|
|
154
|
+
|
|
155
|
+ # update to the next commit
|
|
156
|
+ set_repo_commit "/etc/microblogpub" "microblogpub commit" "$MICROBLOGPUB_COMMIT" "$MICROBLOGPUB_REPO"
|
|
157
|
+ chown -R microblogpub:microblogpub "/etc/microblogpub"
|
|
158
|
+ systemctl restart microblogpub
|
|
159
|
+}
|
|
160
|
+
|
|
161
|
+function backup_local_microblogpub {
|
|
162
|
+ MICROBLOGPUB_DOMAIN_NAME='microblogpub'
|
|
163
|
+ if grep -q "microblogpub domain" "$COMPLETION_FILE"; then
|
|
164
|
+ MICROBLOGPUB_DOMAIN_NAME=$(get_completion_param "microblogpub domain")
|
|
165
|
+ fi
|
|
166
|
+
|
|
167
|
+ source_directory=/etc/microblogpub
|
|
168
|
+
|
|
169
|
+ suspend_site "${MICROBLOGPUB_DOMAIN_NAME}"
|
|
170
|
+
|
|
171
|
+ systemctl stop microblogpub
|
|
172
|
+
|
|
173
|
+ dest_directory=microblogpub
|
|
174
|
+ backup_directory_to_usb "$source_directory" $dest_directory
|
|
175
|
+
|
|
176
|
+ USE_MONGODB=1
|
|
177
|
+ backup_database_to_usb microblogpub
|
|
178
|
+
|
|
179
|
+ restart_site
|
|
180
|
+ systemctl start microblogpub
|
|
181
|
+}
|
|
182
|
+
|
|
183
|
+function restore_local_microblogpub {
|
|
184
|
+ if ! grep -q "microblogpub domain" "$COMPLETION_FILE"; then
|
|
185
|
+ return
|
|
186
|
+ fi
|
|
187
|
+ MICROBLOGPUB_DOMAIN_NAME=$(get_completion_param "microblogpub domain")
|
|
188
|
+ if [ ! "$MICROBLOGPUB_DOMAIN_NAME" ]; then
|
|
189
|
+ return
|
|
190
|
+ fi
|
|
191
|
+ suspend_site "${MICROBLOGPUB_DOMAIN_NAME}"
|
|
192
|
+ systemctl stop microblogpub
|
|
193
|
+
|
|
194
|
+ temp_restore_dir=/root/tempmicroblogpub
|
|
195
|
+ microblogpub_dir=/etc/microblogpub
|
|
196
|
+
|
|
197
|
+ microblogpub_create_database
|
|
198
|
+
|
|
199
|
+ USE_MONGODB=1
|
|
200
|
+ restore_database microblogpub
|
|
201
|
+ if [ -d $temp_restore_dir ]; then
|
|
202
|
+ rm -rf $temp_restore_dir
|
|
203
|
+ fi
|
|
204
|
+
|
|
205
|
+ restore_directory_from_usb $temp_restore_dir microblogpub
|
|
206
|
+ if [ -d $temp_restore_dir ]; then
|
|
207
|
+ if [ -d "$temp_restore_dir$microblogpub_dir" ]; then
|
|
208
|
+ cp -rp "$temp_restore_dir$microblogpub_dir"/* "$microblogpub_dir"/
|
|
209
|
+ else
|
|
210
|
+ if [ ! -d "$microblogpub_dir" ]; then
|
|
211
|
+ mkdir "$microblogpub_dir"
|
|
212
|
+ fi
|
|
213
|
+ cp -rp "$temp_restore_dir"/* "$microblogpub_dir"/
|
|
214
|
+ fi
|
|
215
|
+ chown -R microblogpub:microblogpub "$microblogpub_dir"
|
|
216
|
+ rm -rf $temp_restore_dir
|
|
217
|
+ fi
|
|
218
|
+ systemctl start microblogpub
|
|
219
|
+
|
|
220
|
+ restart_site
|
|
221
|
+}
|
|
222
|
+
|
|
223
|
+function backup_remote_microblogpub {
|
|
224
|
+ MICROBLOGPUB_DOMAIN_NAME='microblogpub'
|
|
225
|
+ if grep -q "microblogpub domain" "$COMPLETION_FILE"; then
|
|
226
|
+ MICROBLOGPUB_DOMAIN_NAME=$(get_completion_param "microblogpub domain")
|
|
227
|
+ fi
|
|
228
|
+
|
|
229
|
+ source_directory=/etc/microblogpub
|
|
230
|
+
|
|
231
|
+ suspend_site "${MICROBLOGPUB_DOMAIN_NAME}"
|
|
232
|
+ systemctl stop microblogpub
|
|
233
|
+
|
|
234
|
+ dest_directory=microblogpub
|
|
235
|
+ backup_directory_to_friend "$source_directory" $dest_directory
|
|
236
|
+ USE_MONGODB=1
|
|
237
|
+ backup_database_to_friend microblogpub
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+ systemctl start microblogpub
|
|
241
|
+
|
|
242
|
+ restart_site
|
|
243
|
+}
|
|
244
|
+
|
|
245
|
+function restore_remote_microblogpub {
|
|
246
|
+ if ! grep -q "microblogpub domain" "$COMPLETION_FILE"; then
|
|
247
|
+ return
|
|
248
|
+ fi
|
|
249
|
+ MICROBLOGPUB_DOMAIN_NAME=$(get_completion_param "microblogpub domain")
|
|
250
|
+ if [ ! "$MICROBLOGPUB_DOMAIN_NAME" ]; then
|
|
251
|
+ return
|
|
252
|
+ fi
|
|
253
|
+ suspend_site "${MICROBLOGPUB_DOMAIN_NAME}"
|
|
254
|
+ systemctl stop microblogpub
|
|
255
|
+
|
|
256
|
+ temp_restore_dir=/root/tempmicroblogpub
|
|
257
|
+ microblogpub_dir=/etc/microblogpub
|
|
258
|
+
|
|
259
|
+ microblogpub_create_database
|
|
260
|
+
|
|
261
|
+ USE_MONGODB=1
|
|
262
|
+ restore_database_from_friend microblogpub
|
|
263
|
+ if [ -d "$temp_restore_dir" ]; then
|
|
264
|
+ rm -rf $temp_restore_dir
|
|
265
|
+ fi
|
|
266
|
+
|
|
267
|
+ restore_directory_from_friend $temp_restore_dir microblogpub
|
|
268
|
+ if [ -d $temp_restore_dir ]; then
|
|
269
|
+ if [ -d "$temp_restore_dir$microblogpub_dir" ]; then
|
|
270
|
+ cp -rp "$temp_restore_dir$microblogpub_dir"/* "$microblogpub_dir"/
|
|
271
|
+ else
|
|
272
|
+ if [ ! -d "$microblogpub_dir" ]; then
|
|
273
|
+ mkdir "$microblogpub_dir"
|
|
274
|
+ fi
|
|
275
|
+ cp -rp $temp_restore_dir/* "$microblogpub_dir"/
|
|
276
|
+ fi
|
|
277
|
+ chown -R microblogpub:microblogpub "$microblogpub_dir"
|
|
278
|
+ rm -rf $temp_restore_dir
|
|
279
|
+ fi
|
|
280
|
+ systemctl start microblogpub
|
|
281
|
+
|
|
282
|
+ restart_site
|
|
283
|
+}
|
|
284
|
+
|
|
285
|
+function remove_microblogpub {
|
|
286
|
+ nginx_dissite "$MICROBLOGPUB_DOMAIN_NAME"
|
|
287
|
+ remove_certs "$MICROBLOGPUB_DOMAIN_NAME"
|
|
288
|
+
|
|
289
|
+ if [ -f /etc/systemd/system/microblogpub.service ]; then
|
|
290
|
+ systemctl stop microblogpub
|
|
291
|
+ systemctl disable microblogpub
|
|
292
|
+ rm /etc/systemd/system/microblogpub.service
|
|
293
|
+ fi
|
|
294
|
+ userdel -r microblogpub
|
|
295
|
+
|
|
296
|
+ if [ -d "/var/www/$MICROBLOGPUB_DOMAIN_NAME" ]; then
|
|
297
|
+ rm -rf "/var/www/$MICROBLOGPUB_DOMAIN_NAME"
|
|
298
|
+ fi
|
|
299
|
+ if [ -f "/etc/nginx/sites-available/$MICROBLOGPUB_DOMAIN_NAME" ]; then
|
|
300
|
+ rm "/etc/nginx/sites-available/$MICROBLOGPUB_DOMAIN_NAME"
|
|
301
|
+ fi
|
|
302
|
+ drop_database_mongodb microblogpub
|
|
303
|
+ remove_onion_service microblogpub "${MICROBLOGPUB_ONION_PORT}"
|
|
304
|
+ if grep -q "microblogpub" /etc/crontab; then
|
|
305
|
+ sed -i "/microblogpub/d" /etc/crontab
|
|
306
|
+ fi
|
|
307
|
+ remove_app microblogpub
|
|
308
|
+ remove_completion_param install_microblogpub
|
|
309
|
+ sed -i '/microblogpub/d' "$COMPLETION_FILE"
|
|
310
|
+
|
|
311
|
+ remove_ddns_domain "$MICROBLOGPUB_DOMAIN_NAME"
|
|
312
|
+}
|
|
313
|
+
|
|
314
|
+function install_microblogpub {
|
|
315
|
+ apt-get -yq install python3-pip python3-flask
|
|
316
|
+
|
|
317
|
+ install_mongodb
|
|
318
|
+
|
|
319
|
+ if [ ! "$MICROBLOGPUB_DOMAIN_NAME" ]; then
|
|
320
|
+ echo $'No domain name was given'
|
|
321
|
+ exit 3568356
|
|
322
|
+ fi
|
|
323
|
+
|
|
324
|
+ if [ -d "/var/www/$MICROBLOGPUB_DOMAIN_NAME/htdocs" ]; then
|
|
325
|
+ rm -rf "/var/www/$MICROBLOGPUB_DOMAIN_NAME/htdocs"
|
|
326
|
+ fi
|
|
327
|
+ if [ -d /repos/microblogpub ]; then
|
|
328
|
+ mkdir "/var/www/$MICROBLOGPUB_DOMAIN_NAME/htdocs"
|
|
329
|
+ cp -r -p /repos/microblogpub/. "/etc/microblogpub"
|
|
330
|
+ cd "/etc/microblogpub" || exit 36487365
|
|
331
|
+ git pull
|
|
332
|
+ else
|
|
333
|
+ git_clone "$MICROBLOGPUB_REPO" "/etc/microblogpub"
|
|
334
|
+ fi
|
|
335
|
+
|
|
336
|
+ if [ ! -d "/etc/microblogpub" ]; then
|
|
337
|
+ echo $'Unable to clone microblogpub repo'
|
|
338
|
+ exit 87525
|
|
339
|
+ fi
|
|
340
|
+
|
|
341
|
+ cd "/etc/microblogpub" || exit 3463754637
|
|
342
|
+ git checkout "$MICROBLOGPUB_COMMIT" -b "$MICROBLOGPUB_COMMIT"
|
|
343
|
+ set_completion_param "microblogpub commit" "$MICROBLOGPUB_COMMIT"
|
|
344
|
+
|
|
345
|
+ pip3 install -r requirements.txt
|
|
346
|
+
|
|
347
|
+ { echo 'import sass';
|
|
348
|
+ echo "sass.compile(dirname=('sass', 'static/css'), output_style='compressed')"; } > generate_css.py
|
|
349
|
+ python3 generate_css.py
|
|
350
|
+
|
|
351
|
+ { echo "username: '$MY_USERNAME'";
|
|
352
|
+ echo "name: '$MY_NAME'";
|
|
353
|
+ echo "icon_url: 'https://$MICROBLOGPUB_DOMAIN_NAME/me.png'";
|
|
354
|
+ echo "domain: '$MICROBLOGPUB_DOMAIN_NAME'";
|
|
355
|
+ echo "summary: 'your summary'";
|
|
356
|
+ echo 'https: false'; } > config/me.yml
|
|
357
|
+
|
|
358
|
+ chmod g+w "/var/www/$MICROBLOGPUB_DOMAIN_NAME/htdocs"
|
|
359
|
+ chown -R www-data:www-data "/var/www/$MICROBLOGPUB_DOMAIN_NAME/htdocs"
|
|
360
|
+
|
|
361
|
+ microblogpub_create_database
|
|
362
|
+
|
|
363
|
+ add_ddns_domain "$MICROBLOGPUB_DOMAIN_NAME"
|
|
364
|
+
|
|
365
|
+ MICROBLOGPUB_ONION_HOSTNAME=$(add_onion_service microblogpub 80 "${MICROBLOGPUB_ONION_PORT}")
|
|
366
|
+
|
|
367
|
+ microblogpub_nginx_site=/etc/nginx/sites-available/$MICROBLOGPUB_DOMAIN_NAME
|
|
368
|
+ if [[ "$ONION_ONLY" == "no" ]]; then
|
|
369
|
+ nginx_http_redirect "$MICROBLOGPUB_DOMAIN_NAME" "index index.html"
|
|
370
|
+ { echo 'server {';
|
|
371
|
+ echo ' listen 443 ssl;';
|
|
372
|
+ echo ' #listen [::]:443 ssl;';
|
|
373
|
+ echo " server_name $MICROBLOGPUB_DOMAIN_NAME;";
|
|
374
|
+ echo ''; } >> "$microblogpub_nginx_site"
|
|
375
|
+ nginx_compress "$MICROBLOGPUB_DOMAIN_NAME"
|
|
376
|
+ echo '' >> "$microblogpub_nginx_site"
|
|
377
|
+ echo ' # Security' >> "$microblogpub_nginx_site"
|
|
378
|
+ nginx_ssl "$MICROBLOGPUB_DOMAIN_NAME"
|
|
379
|
+
|
|
380
|
+ nginx_security_options "$MICROBLOGPUB_DOMAIN_NAME"
|
|
381
|
+
|
|
382
|
+ { echo ' add_header Strict-Transport-Security max-age=15768000;';
|
|
383
|
+ echo '';
|
|
384
|
+ echo ' access_log /dev/null;';
|
|
385
|
+ echo ' error_log /dev/null;';
|
|
386
|
+ echo '';
|
|
387
|
+ echo " root /var/www/$MICROBLOGPUB_DOMAIN_NAME/htdocs;";
|
|
388
|
+ echo '';
|
|
389
|
+ echo ' index index.html;';
|
|
390
|
+ echo ' # Location';
|
|
391
|
+ echo ' location / {'; } >> "$microblogpub_nginx_site"
|
|
392
|
+ nginx_limits "$MICROBLOGPUB_DOMAIN_NAME" '15m'
|
|
393
|
+ { echo " proxy_pass http://localhost:$MICROBLOGPUB_PORT_INTERNAL;";
|
|
394
|
+ echo ' }';
|
|
395
|
+ echo '}'; } >> "$microblogpub_nginx_site"
|
|
396
|
+ else
|
|
397
|
+ echo -n '' > "$microblogpub_nginx_site"
|
|
398
|
+ fi
|
|
399
|
+ { echo 'server {';
|
|
400
|
+ echo " listen 127.0.0.1:$MICROBLOGPUB_ONION_PORT default_server;";
|
|
401
|
+ echo " server_name $MICROBLOGPUB_ONION_HOSTNAME;";
|
|
402
|
+ echo ''; } >> "$microblogpub_nginx_site"
|
|
403
|
+ nginx_compress "$MICROBLOGPUB_DOMAIN_NAME"
|
|
404
|
+ echo '' >> "$microblogpub_nginx_site"
|
|
405
|
+ nginx_security_options "$MICROBLOGPUB_DOMAIN_NAME"
|
|
406
|
+ { echo '';
|
|
407
|
+ echo ' access_log /dev/null;';
|
|
408
|
+ echo ' error_log /dev/null;';
|
|
409
|
+ echo '';
|
|
410
|
+ echo " root /var/www/$MICROBLOGPUB_DOMAIN_NAME/htdocs;";
|
|
411
|
+ echo '';
|
|
412
|
+ echo ' index index.html;';
|
|
413
|
+ echo ' # Location';
|
|
414
|
+ echo ' location / {'; } >> "$microblogpub_nginx_site"
|
|
415
|
+ nginx_limits "$MICROBLOGPUB_DOMAIN_NAME" '15m'
|
|
416
|
+ { echo " proxy_pass http://localhost:$MICROBLOGPUB_PORT_INTERNAL;";
|
|
417
|
+ echo ' }';
|
|
418
|
+ echo '}'; } >> "$microblogpub_nginx_site"
|
|
419
|
+
|
|
420
|
+ adduser --system --home="/etc/microblogpub" --group microblogpub
|
|
421
|
+
|
|
422
|
+ { echo '[Unit]';
|
|
423
|
+ echo 'Description=microblogpub';
|
|
424
|
+ echo 'After=syslog.target';
|
|
425
|
+ echo 'After=network.target';
|
|
426
|
+ echo "Documentation=$MICROBLOGPUB_REPO";
|
|
427
|
+ echo '';
|
|
428
|
+ echo '[Service]';
|
|
429
|
+ echo 'Type=simple';
|
|
430
|
+ echo 'User=microblogpub';
|
|
431
|
+ echo 'Group=microblogpub';
|
|
432
|
+ echo 'WorkingDirectory=/etc/microblogpub';
|
|
433
|
+ echo "ExecStart=/usr/local/bin/flask run -p $MICROBLOGPUB_PORT_INTERNAL --with-threads";
|
|
434
|
+ echo 'Environment=USER=microblogpub';
|
|
435
|
+ echo 'Environment=FLASK_APP=app.py';
|
|
436
|
+ echo 'Environment=MICROBLOGPUB_DEBUG=1';
|
|
437
|
+ echo 'Restart=always';
|
|
438
|
+ echo 'StandardError=syslog';
|
|
439
|
+ echo '';
|
|
440
|
+ echo '[Install]';
|
|
441
|
+ echo 'WantedBy=multi-user.target'; } > "/etc/systemd/system/microblogpub.service"
|
|
442
|
+ systemctl enable microblogpub
|
|
443
|
+ chown -R microblogpub:microblogpub "/etc/microblogpub"
|
|
444
|
+ systemctl start microblogpub
|
|
445
|
+
|
|
446
|
+ create_site_certificate "$MICROBLOGPUB_DOMAIN_NAME" 'yes'
|
|
447
|
+
|
|
448
|
+ nginx_ensite "$MICROBLOGPUB_DOMAIN_NAME"
|
|
449
|
+
|
|
450
|
+ systemctl restart nginx
|
|
451
|
+
|
|
452
|
+ "${PROJECT_NAME}-pass" -u "$MY_USERNAME" -a microblogpub -p "$MICROBLOGPUB_ADMIN_PASSWORD"
|
|
453
|
+
|
|
454
|
+
|
|
455
|
+ { echo 'import bcrypt';
|
|
456
|
+ echo "print(bcrypt.hashpw(\"$MICROBLOGPUB_ADMIN_PASSWORD\", bcrypt.gensalt()).decode('utf-8'))"; } > /tmp/microblogpub
|
|
457
|
+ MICROBLOGPUB_HASHED_PASSWORD=$(python /tmp/microblogpub)
|
|
458
|
+ rm /tmp/microblogpub
|
|
459
|
+
|
|
460
|
+ set_completion_param "microblogpub domain" "$MICROBLOGPUB_DOMAIN_NAME"
|
|
461
|
+
|
|
462
|
+ APP_INSTALLED=1
|
|
463
|
+}
|
|
464
|
+
|
|
465
|
+# NOTE: deliberately there is no "exit 0"
|