瀏覽代碼

Merge branch 'stretch' of https://github.com/bashrc/freedombone

Bob Mottram 6 年之前
父節點
當前提交
dd790f3733

+ 3
- 1
doc/EN/app_peertube.org 查看文件

25
 
25
 
26
 Select *Add/Remove Apps* then *peertube*. You will then be asked for a domain name and if you are using FreeDNS also the code for the domain which can be found under *Dynamic DNS* on the FreeDNS site (the random string from "/quick cron example/" which appears after /update.php?/ and before />>/). For more details on obtaining a domain and making it accessible via dynamic DNS see the [[./faq.html][FAQ]]. Typically the domain name you use will be a subdomain, such as /video.mydomainname.net/. It will need to be a domain which you have bought somewhere and own and not one of the FreeDNS subdomains, otherwise you won't be able to get a SSL/TLS certificate for it.
26
 Select *Add/Remove Apps* then *peertube*. You will then be asked for a domain name and if you are using FreeDNS also the code for the domain which can be found under *Dynamic DNS* on the FreeDNS site (the random string from "/quick cron example/" which appears after /update.php?/ and before />>/). For more details on obtaining a domain and making it accessible via dynamic DNS see the [[./faq.html][FAQ]]. Typically the domain name you use will be a subdomain, such as /video.mydomainname.net/. It will need to be a domain which you have bought somewhere and own and not one of the FreeDNS subdomains, otherwise you won't be able to get a SSL/TLS certificate for it.
27
 
27
 
28
+Although PeerTube can handle a few formats *webm* is the currently recommended one. Other formats might not play in some browsers or on some libre distros.
29
+
28
 * Initial setup
30
 * Initial setup
29
 Navigate to your site and select *Signup* to create a new account. By default the maximum number of accounts on your system is limited to a small number so that millions of random internet users can't then begin uploading dubious content. After that it's pretty straightforward.
31
 Navigate to your site and select *Signup* to create a new account. By default the maximum number of accounts on your system is limited to a small number so that millions of random internet users can't then begin uploading dubious content. After that it's pretty straightforward.
30
 
32
 
40
 
42
 
41
 The first line of login.txt should be your username, the second line should be the password and optionally the third line can contain the words *public* and/or *nsfw*, if you want to make imported videos immediately public or mark them as not suitable for work.
43
 The first line of login.txt should be your username, the second line should be the password and optionally the third line can contain the words *public* and/or *nsfw*, if you want to make imported videos immediately public or mark them as not suitable for work.
42
 
44
 
43
-Prepare your videos in *ogv*, *mp4* or *webm* format. To minimize bandwidth usage try to keep your videos as small as possible. Giant videos with incredibly high resolution tend to result in a bad user experience. Often just converting your videos to *webm* using *ffmpeg* will keep the size down.
45
+Prepare your videos preferably in *webm* format. Other formats may be poorly supported, especially on libre distros. To minimize bandwidth usage try to keep your videos as small as possible. Giant videos with incredibly high resolution tend to result in a bad user experience. Often just converting your videos to *webm* using *ffmpeg* will keep the size down.
44
 
46
 
45
 Now copy or drag and drop your videos into the *~/Sync/peertube_upload* directory. Syncthing will sync to the server and automatically add the videos to PeerTube. Depending on how large the videos are this may take some time.
47
 Now copy or drag and drop your videos into the *~/Sync/peertube_upload* directory. Syncthing will sync to the server and automatically add the videos to PeerTube. Depending on how large the videos are this may take some time.
46
 
48
 

二進制
image_build/prosody-0.10-1nightly478.tar.gz 查看文件


二進制
image_build/prosody-0.10-1nightly485.tar.gz 查看文件


二進制
image_build/prosody-modules-20180322.tar.gz 查看文件


二進制
image_build/prosody-modules-20180602.tar.gz 查看文件


+ 465
- 0
src/freedombone-app-microblogpub 查看文件

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"

+ 36
- 7
src/freedombone-app-peertube 查看文件

38
 PEERTUBE_DOMAIN_NAME=
38
 PEERTUBE_DOMAIN_NAME=
39
 PEERTUBE_CODE=
39
 PEERTUBE_CODE=
40
 PEERTUBE_REPO="https://github.com/Chocobozzz/PeerTube"
40
 PEERTUBE_REPO="https://github.com/Chocobozzz/PeerTube"
41
-PEERTUBE_COMMIT='f209b32afaffbb8b93c265525ebde182ab66c37a'
41
+PEERTUBE_COMMIT='50a3f3b821cd255ad8ae43f086aede0d2c9c778a'
42
 PEERTUBE_ONION_PORT=8136
42
 PEERTUBE_ONION_PORT=8136
43
 PEERTUBE_PORT=9004
43
 PEERTUBE_PORT=9004
44
 MESH_PEERTUBE_PORT=8500
44
 MESH_PEERTUBE_PORT=8500
434
     function_check set_repo_commit
434
     function_check set_repo_commit
435
     set_repo_commit $PEERTUBE_DIR "peertube commit" "$PEERTUBE_COMMIT" $PEERTUBE_REPO
435
     set_repo_commit $PEERTUBE_DIR "peertube commit" "$PEERTUBE_COMMIT" $PEERTUBE_REPO
436
 
436
 
437
-    npm run upgrade-peertube
437
+    if ! npm install -g yarn@1.5.1; then
438
+        echo $'Failed to install yarn'
439
+        exit 79353234
440
+    fi
441
+    yarn add -D webpack --network-concurrency 1
442
+    if ! yarn install; then
443
+        echo $'Failed to run yarn install'
444
+        exit 63754235
445
+    fi
446
+    if ! npm install -g npm@4; then
447
+        # https://github.com/KraigM/homebridge-harmonyhub/issues/119
448
+        echo $'Failed to downgrade npm'
449
+        npm install -g "npm@${NPM_VERSION}"
450
+        cp /root/.npm-global/bin/npm /usr/local/bin/npm
451
+        exit 3476835
452
+    fi
453
+    cp /root/.npm-global/bin/npm /usr/local/bin/npm
454
+    if ! npm install; then
455
+        echo $'Failed to install peertube'
456
+        npm install -g "npm@${NPM_VERSION}"
457
+        cp /root/.npm-global/bin/npm /usr/local/bin/npm
458
+        exit 7835243
459
+    fi
460
+    if ! npm install -g "npm@${NPM_VERSION}"; then
461
+        echo $'Failed to restore npm after downgrade'
462
+        exit 5737583
463
+    fi
464
+    cp /root/.npm-global/bin/npm /usr/local/bin/npm
465
+    npm run build
466
+
467
+    # This doesn't appear to work
468
+    #sudo -u peertube ./upgrade.sh $PEERTUBE_DIR
469
+
438
     chown -R peertube:peertube $PEERTUBE_DIR
470
     chown -R peertube:peertube $PEERTUBE_DIR
439
     systemctl start peertube
471
     systemctl start peertube
440
 }
472
 }
848
       echo '# If enabled, the video will be transcoded to mp4 (x264) with "faststart" flag';
880
       echo '# If enabled, the video will be transcoded to mp4 (x264) with "faststart" flag';
849
       echo '# Uses a lot of CPU!';
881
       echo '# Uses a lot of CPU!';
850
       echo 'transcoding:';
882
       echo 'transcoding:';
851
-      echo '  enabled: true';
883
+      echo '  enabled: false';
852
       echo '  threads: 2';
884
       echo '  threads: 2';
853
       echo '  resolutions: # Only created if the original video has a higher resolution';
885
       echo '  resolutions: # Only created if the original video has a higher resolution';
854
       echo '    240p: true';
886
       echo '    240p: true';
1042
         exit 5737583
1074
         exit 5737583
1043
     fi
1075
     fi
1044
     cp /root/.npm-global/bin/npm /usr/local/bin/npm
1076
     cp /root/.npm-global/bin/npm /usr/local/bin/npm
1045
-    if ! npm run build; then
1046
-        echo $'Failed to build peertube'
1047
-        exit 5293593
1048
-    fi
1077
+    npm run build
1049
 
1078
 
1050
     PEERTUBE_ONION_HOSTNAME=$(add_onion_service peertube 80 ${PEERTUBE_ONION_PORT})
1079
     PEERTUBE_ONION_HOSTNAME=$(add_onion_service peertube 80 ${PEERTUBE_ONION_PORT})
1051
 
1080
 

+ 16
- 23
src/freedombone-app-pihole 查看文件

45
 PIHOLE_WHITELIST=$piholeDir/whitelist.txt
45
 PIHOLE_WHITELIST=$piholeDir/whitelist.txt
46
 
46
 
47
 PIHOLE_REPO="https://github.com/pi-hole/pi-hole"
47
 PIHOLE_REPO="https://github.com/pi-hole/pi-hole"
48
-PIHOLE_COMMIT='e602008459128c233899b1e9d70cca0f38f41670'
48
+PIHOLE_COMMIT='fbee18e24d56b418e3329a56ae4156dbe8fe5e1f'
49
 
49
 
50
 pihole_variables=(ONION_ONLY
50
 pihole_variables=(ONION_ONLY
51
                   PIHOLE_IFACE
51
                   PIHOLE_IFACE
255
 }
255
 }
256
 
256
 
257
 function configure_interactive_pihole {
257
 function configure_interactive_pihole {
258
+    W=(1 $"Edit ads list"
259
+       2 $"Edit blacklisted domain names"
260
+       3 $"Edit whitelisted domain names"
261
+       4 $"Change upstream DNS servers"
262
+       5 $"Pause blocker"
263
+       6 $"Resume blocker")
264
+
258
     while true
265
     while true
259
     do
266
     do
260
-        data=$(mktemp 2>/dev/null)
261
-        dialog --backtitle $"Freedombone Control Panel" \
262
-               --title $"Ad Blocker" \
263
-               --radiolist $"Choose an operation:" 16 70 7 \
264
-               1 $"Edit ads list" off \
265
-               2 $"Edit blacklisted domain names" off \
266
-               3 $"Edit whitelisted domain names" off \
267
-               4 $"Change upstream DNS servers" off \
268
-               5 $"Pause blocker" off \
269
-               6 $"Resume blocker" off \
270
-               7 $"Exit" on 2> "$data"
271
-        sel=$?
272
-        case $sel in
273
-            1) rm -f "$data"
274
-               exit 1;;
275
-            255) rm -f "$data"
276
-                 exit 1;;
277
-        esac
278
-        case $(cat "$data") in
267
+        # shellcheck disable=SC2068
268
+        selection=$(dialog --backtitle $"Freedombone Administrator Control Panel" --title $"Ad blocker" --menu $"Choose an operation, or ESC for main menu:" 13 60 9 "${W[@]}" 3>&2 2>&1 1>&3)
269
+
270
+        if [ ! "$selection" ]; then
271
+           break
272
+        fi
273
+
274
+        case $selection in
279
             1) editor $PIHOLE_CUSTOM_ADLIST
275
             1) editor $PIHOLE_CUSTOM_ADLIST
280
                update_pihole_interactive
276
                update_pihole_interactive
281
                ;;
277
                ;;
292
                ;;
288
                ;;
293
             6) pihole_resume
289
             6) pihole_resume
294
                ;;
290
                ;;
295
-            7) rm -f "$data"
296
-               break;;
297
         esac
291
         esac
298
-        rm -f "$data"
299
     done
292
     done
300
 }
293
 }
301
 
294
 

+ 436
- 0
src/freedombone-app-pixelfed 查看文件

1
+#!/bin/bash
2
+#
3
+#  _____               _           _
4
+# |   __|___ ___ ___ _| |___ _____| |_ ___ ___ ___
5
+# |   __|  _| -_| -_| . | . |     | . | . |   | -_|
6
+# |__|  |_| |___|___|___|___|_|_|_|___|___|_|_|___|
7
+#
8
+#                              Freedom in the Cloud
9
+#
10
+# Pixelfed app
11
+#
12
+# Requires php 7.1.3 but debian version is 7.0.27
13
+#
14
+# License
15
+# =======
16
+#
17
+# Copyright (C) 2018 Bob Mottram <bob@freedombone.net>
18
+#
19
+# This program is free software: you can redistribute it and/or modify
20
+# it under the terms of the GNU Affero General Public License as published by
21
+# the Free Software Foundation, either version 3 of the License, or
22
+# (at your option) any later version.
23
+#
24
+# This program is distributed in the hope that it will be useful,
25
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
26
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27
+# GNU Affero General Public License for more details.
28
+#
29
+# You should have received a copy of the GNU Affero General Public License
30
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
31
+
32
+VARIANTS=''
33
+
34
+IN_DEFAULT_INSTALL=0
35
+SHOW_ON_ABOUT=1
36
+
37
+PIXELFED_DOMAIN_NAME=
38
+PIXELFED_CODE=
39
+PIXELFED_ONION_PORT=9324
40
+PIXELFED_REPO="https://github.com/dansup/pixelfed"
41
+PIXELFED_COMMIT='9fbc5d0902fbc2042a6d2bb698cc3802e7b25508'
42
+
43
+# These parameters are used by the FreedomBox mobile app
44
+PIXELFED_SHORT_DESCRIPTION='Federated image sharing'
45
+PIXELFED_DESCRIPTION='Federated image sharing'
46
+PIXELFED_MOBILE_APP_URL=
47
+
48
+pixelfed_variables=(ONION_ONLY
49
+                    PIXELFED_DOMAIN_NAME
50
+                    PIXELFED_CODE
51
+                    DDNS_PROVIDER
52
+                    MY_USERNAME)
53
+
54
+function logging_on_pixelfed {
55
+    echo -n ''
56
+}
57
+
58
+function logging_off_pixelfed {
59
+    echo -n ''
60
+}
61
+
62
+function remove_user_pixelfed {
63
+    remove_username="$1"
64
+
65
+    "${PROJECT_NAME}-pass" -u "$remove_username" --rmapp pixelfed
66
+}
67
+
68
+function add_user_pixelfed {
69
+    new_username="$1"
70
+    new_user_password="$2"
71
+
72
+    "${PROJECT_NAME}-pass" -u "$new_username" -a pixelfed -p "$new_user_password"
73
+    echo '0'
74
+}
75
+
76
+function install_interactive_pixelfed {
77
+    if [ ! "$ONION_ONLY" ]; then
78
+        ONION_ONLY='no'
79
+    fi
80
+
81
+    if [[ "$ONION_ONLY" != "no" ]]; then
82
+        PIXELFED_DOMAIN_NAME='pixelfed.local'
83
+        write_config_param "PIXELFED_DOMAIN_NAME" "$PIXELFED_DOMAIN_NAME"
84
+    else
85
+        interactive_site_details "pixelfed" "PIXELFED_DOMAIN_NAME" "PIXELFED_CODE"
86
+    fi
87
+    APP_INSTALLED=1
88
+}
89
+
90
+function change_password_pixelfed {
91
+    curr_username="$1"
92
+    new_user_password="$2"
93
+
94
+    read_config_param 'PIXELFED_DOMAIN_NAME'
95
+
96
+    "${PROJECT_NAME}-pass" -u "$curr_username" -a pixelfed -p "$new_user_password"
97
+}
98
+
99
+function pixelfed_create_database {
100
+    if [ -f "$IMAGE_PASSWORD_FILE" ]; then
101
+        PIXELFED_ADMIN_PASSWORD="$(printf "%d" "$(cat "")")"
102
+    else
103
+        if [ ! "$PIXELFED_ADMIN_PASSWORD" ]; then
104
+            PIXELFED_ADMIN_PASSWORD=$(create_password "${MINIMUM_PASSWORD_LENGTH}")
105
+        fi
106
+    fi
107
+    if [ ! "$PIXELFED_ADMIN_PASSWORD" ]; then
108
+        return
109
+    fi
110
+
111
+    create_database pixelfed "$PIXELFED_ADMIN_PASSWORD" "$MY_USERNAME"
112
+}
113
+
114
+function reconfigure_pixelfed {
115
+    # This is used if you need to switch identity. Dump old keys and generate new ones
116
+    echo -n ''
117
+}
118
+
119
+function configure_interactive_pixelfed {
120
+    W=(1 $"Option 1"
121
+       2 $"Option 2")
122
+
123
+    while true
124
+    do
125
+        # shellcheck disable=SC2068
126
+        selection=$(dialog --backtitle $"Freedombone Administrator Control Panel" --title $"pixelfed" --menu $"Choose an operation, or ESC for main menu:" 14 70 3 "${W[@]}" 3>&2 2>&1 1>&3)
127
+
128
+        if [ ! "$selection" ]; then
129
+           break
130
+        fi
131
+        case $selection in
132
+            1) # call some function for option 1
133
+               ;;
134
+            2) # call some function for option 2
135
+               ;;
136
+        esac
137
+    done
138
+}
139
+
140
+function upgrade_pixelfed {
141
+    CURR_PIXELFED_COMMIT=$(get_completion_param "pixelfed commit")
142
+    if [[ "$CURR_PIXELFED_COMMIT" == "$PIXELFED_COMMIT" ]]; then
143
+        return
144
+    fi
145
+
146
+    if grep -q "pixelfed domain" "$COMPLETION_FILE"; then
147
+        PIXELFED_DOMAIN_NAME=$(get_completion_param "pixelfed domain")
148
+    fi
149
+
150
+    # update to the next commit
151
+    set_repo_commit "/var/www/$PIXELFED_DOMAIN_NAME/htdocs" "pixelfed commit" "$PIXELFED_COMMIT" "$PIXELFED_REPO"
152
+
153
+    cd "/var/www/${PIXELFED_DOMAIN_NAME}/htdocs" || exit 634873561
154
+    install_composer
155
+
156
+    chown -R www-data:www-data "/var/www/${PIXELFED_DOMAIN_NAME}/htdocs"
157
+}
158
+
159
+function backup_local_pixelfed {
160
+    PIXELFED_DOMAIN_NAME='pixelfed'
161
+    if grep -q "pixelfed domain" "$COMPLETION_FILE"; then
162
+        PIXELFED_DOMAIN_NAME=$(get_completion_param "pixelfed domain")
163
+    fi
164
+
165
+    source_directory=/var/www/${PIXELFED_DOMAIN_NAME}/htdocs
166
+
167
+    suspend_site "${PIXELFED_DOMAIN_NAME}"
168
+
169
+    dest_directory=pixelfed
170
+    backup_directory_to_usb "$source_directory" $dest_directory
171
+
172
+    backup_database_to_usb pixelfed
173
+
174
+    restart_site
175
+}
176
+
177
+function restore_local_pixelfed {
178
+    if ! grep -q "pixelfed domain" "$COMPLETION_FILE"; then
179
+        return
180
+    fi
181
+    PIXELFED_DOMAIN_NAME=$(get_completion_param "pixelfed domain")
182
+    if [ ! "$PIXELFED_DOMAIN_NAME" ]; then
183
+        return
184
+    fi
185
+    suspend_site "${PIXELFED_DOMAIN_NAME}"
186
+    temp_restore_dir=/root/temppixelfed
187
+    pixelfed_dir=/var/www/${PIXELFED_DOMAIN_NAME}/htdocs
188
+
189
+    pixelfed_create_database
190
+
191
+    restore_database pixelfed
192
+    if [ -d $temp_restore_dir ]; then
193
+        rm -rf $temp_restore_dir
194
+    fi
195
+
196
+    restore_directory_from_usb $temp_restore_dir pixelfed
197
+    if [ -d $temp_restore_dir ]; then
198
+        if [ -d "$temp_restore_dir$pixelfed_dir" ]; then
199
+            cp -rp "$temp_restore_dir$pixelfed_dir"/* "$pixelfed_dir"/
200
+        else
201
+            if [ ! -d "$pixelfed_dir" ]; then
202
+                mkdir "$pixelfed_dir"
203
+            fi
204
+            cp -rp "$temp_restore_dir"/* "$pixelfed_dir"/
205
+        fi
206
+        chown -R www-data:www-data "$pixelfed_dir"
207
+        rm -rf $temp_restore_dir
208
+    fi
209
+    restart_site
210
+}
211
+
212
+function backup_remote_pixelfed {
213
+    PIXELFED_DOMAIN_NAME='pixelfed'
214
+    if grep -q "pixelfed domain" "$COMPLETION_FILE"; then
215
+        PIXELFED_DOMAIN_NAME=$(get_completion_param "pixelfed domain")
216
+    fi
217
+
218
+    source_directory=/var/www/${PIXELFED_DOMAIN_NAME}/htdocs
219
+
220
+    suspend_site "${PIXELFED_DOMAIN_NAME}"
221
+
222
+    dest_directory=pixelfed
223
+    backup_directory_to_friend "$source_directory" $dest_directory
224
+    backup_database_to_friend pixelfed
225
+
226
+
227
+    restart_site
228
+}
229
+
230
+function restore_remote_pixelfed {
231
+    if ! grep -q "pixelfed domain" "$COMPLETION_FILE"; then
232
+        return
233
+    fi
234
+    PIXELFED_DOMAIN_NAME=$(get_completion_param "pixelfed domain")
235
+    if [ ! "$PIXELFED_DOMAIN_NAME" ]; then
236
+        return
237
+    fi
238
+    suspend_site "${PIXELFED_DOMAIN_NAME}"
239
+    temp_restore_dir=/root/temppixelfed
240
+    pixelfed_dir=/var/www/${PIXELFED_DOMAIN_NAME}/htdocs
241
+
242
+    pixelfed_create_database
243
+
244
+    restore_database_from_friend pixelfed
245
+    if [ -d "$temp_restore_dir" ]; then
246
+        rm -rf $temp_restore_dir
247
+    fi
248
+
249
+    restore_directory_from_friend $temp_restore_dir pixelfed
250
+    if [ -d $temp_restore_dir ]; then
251
+        if [ -d "$temp_restore_dir$pixelfed_dir" ]; then
252
+            cp -rp "$temp_restore_dir$pixelfed_dir"/* "$pixelfed_dir"/
253
+        else
254
+            if [ ! -d "$pixelfed_dir" ]; then
255
+                mkdir "$pixelfed_dir"
256
+            fi
257
+            cp -rp $temp_restore_dir/* "$pixelfed_dir"/
258
+        fi
259
+        chown -R www-data:www-data "$pixelfed_dir"
260
+        rm -rf $temp_restore_dir
261
+    fi
262
+    restart_site
263
+}
264
+
265
+function remove_pixelfed {
266
+    nginx_dissite "$PIXELFED_DOMAIN_NAME"
267
+    remove_certs "$PIXELFED_DOMAIN_NAME"
268
+
269
+
270
+    if [ -d "/var/www/$PIXELFED_DOMAIN_NAME" ]; then
271
+        rm -rf "/var/www/$PIXELFED_DOMAIN_NAME"
272
+    fi
273
+    if [ -f "/etc/nginx/sites-available/$PIXELFED_DOMAIN_NAME" ]; then
274
+        rm "/etc/nginx/sites-available/$PIXELFED_DOMAIN_NAME"
275
+    fi
276
+    drop_database pixelfed
277
+    remove_onion_service pixelfed "${PIXELFED_ONION_PORT}"
278
+    if grep -q "pixelfed" /etc/crontab; then
279
+        sed -i "/pixelfed/d" /etc/crontab
280
+    fi
281
+    remove_app pixelfed
282
+    remove_completion_param install_pixelfed
283
+    sed -i '/pixelfed/d' "$COMPLETION_FILE"
284
+
285
+    remove_ddns_domain "$PIXELFED_DOMAIN_NAME"
286
+}
287
+
288
+function install_pixelfed {
289
+    install_mariadb
290
+
291
+    get_mariadb_password
292
+
293
+    apt-get -yq install php-gettext php-curl php-gd php-mysql git curl
294
+    apt-get -yq install memcached php-memcached php-intl exiftool libfcgi0ldbl
295
+    apt-get -yq install redis-server php-redis autoconf imagemagick imagemagick-dev libtool
296
+
297
+    if [ ! "$PIXELFED_DOMAIN_NAME" ]; then
298
+        echo $'No domain name was given'
299
+        exit 3568356
300
+    fi
301
+
302
+    if [ -d "/var/www/$PIXELFED_DOMAIN_NAME/htdocs" ]; then
303
+        rm -rf "/var/www/$PIXELFED_DOMAIN_NAME/htdocs"
304
+    fi
305
+    if [ -d /repos/pixelfed ]; then
306
+        mkdir "/var/www/$PIXELFED_DOMAIN_NAME/htdocs"
307
+        cp -r -p /repos/pixelfed/. "/var/www/$PIXELFED_DOMAIN_NAME/htdocs"
308
+        cd "/var/www/$PIXELFED_DOMAIN_NAME/htdocs" || exit 324687356
309
+        git pull
310
+    else
311
+        git_clone "$PIXELFED_REPO" "/var/www/$PIXELFED_DOMAIN_NAME/htdocs"
312
+    fi
313
+
314
+    if [ ! -d "/var/www/$PIXELFED_DOMAIN_NAME/htdocs" ]; then
315
+        echo $'Unable to clone pixelfed repo'
316
+        exit 87525
317
+    fi
318
+
319
+    cd "/var/www/$PIXELFED_DOMAIN_NAME/htdocs" || exit 36587356
320
+    git checkout "$PIXELFED_COMMIT" -b "$PIXELFED_COMMIT"
321
+    set_completion_param "pixelfed commit" "$PIXELFED_COMMIT"
322
+
323
+    install_composer
324
+
325
+    chmod g+w "/var/www/$PIXELFED_DOMAIN_NAME/htdocs"
326
+    chown -R www-data:www-data "/var/www/$PIXELFED_DOMAIN_NAME/htdocs"
327
+
328
+    pixelfed_create_database
329
+
330
+    add_ddns_domain "$PIXELFED_DOMAIN_NAME"
331
+
332
+    PIXELFED_ONION_HOSTNAME=$(add_onion_service pixelfed 80 "${PIXELFED_ONION_PORT}")
333
+
334
+    pixelfed_nginx_site=/etc/nginx/sites-available/$PIXELFED_DOMAIN_NAME
335
+    if [[ "$ONION_ONLY" == "no" ]]; then
336
+        nginx_http_redirect "$PIXELFED_DOMAIN_NAME" "index index.php"
337
+        { echo 'server {';
338
+          echo '  listen 443 ssl;';
339
+          echo '  #listen [::]:443 ssl;';
340
+          echo "  server_name $PIXELFED_DOMAIN_NAME;";
341
+          echo ''; } >> "$pixelfed_nginx_site"
342
+        nginx_compress "$PIXELFED_DOMAIN_NAME"
343
+        echo '' >> "$pixelfed_nginx_site"
344
+        echo '  # Security' >> "$pixelfed_nginx_site"
345
+        nginx_ssl "$PIXELFED_DOMAIN_NAME"
346
+
347
+        nginx_security_options "$PIXELFED_DOMAIN_NAME"
348
+
349
+        { echo '  add_header Strict-Transport-Security max-age=15768000;';
350
+          echo '';
351
+          echo '    access_log /dev/null;';
352
+          echo '    error_log /dev/null;';
353
+          echo '';
354
+          echo "    root /var/www/$PIXELFED_DOMAIN_NAME/htdocs;";
355
+          echo '';
356
+          echo '  index index.php;';
357
+          echo '  location ~ \.php {';
358
+          echo '    include snippets/fastcgi-php.conf;';
359
+          echo '    fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;';
360
+          echo '    fastcgi_read_timeout 30;';
361
+          echo '    fastcgi_param HTTPS on;';
362
+          echo '  }';
363
+          echo '';
364
+          echo '  # Location';
365
+          echo '  location / {'; } >> "$pixelfed_nginx_site"
366
+        nginx_limits "$PIXELFED_DOMAIN_NAME" '15m'
367
+        { echo "    try_files \$uri \$uri/ /index.php?\$args;";
368
+          echo '  }';
369
+          echo '}'; } >> "$pixelfed_nginx_site"
370
+    else
371
+        echo -n '' > "$pixelfed_nginx_site"
372
+    fi
373
+    { echo 'server {';
374
+      echo "    listen 127.0.0.1:$PIXELFED_ONION_PORT default_server;";
375
+      echo "    server_name $PIXELFED_ONION_HOSTNAME;";
376
+      echo ''; } >> "$pixelfed_nginx_site"
377
+    nginx_compress "$PIXELFED_DOMAIN_NAME"
378
+    echo '' >> "$pixelfed_nginx_site"
379
+    nginx_security_options "$PIXELFED_DOMAIN_NAME"
380
+    { echo '';
381
+      echo '    access_log /dev/null;';
382
+      echo '    error_log /dev/null;';
383
+      echo '';
384
+      echo "    root /var/www/$PIXELFED_DOMAIN_NAME/htdocs;";
385
+      echo '';
386
+      echo '  index index.php;';
387
+      echo '  location ~ \.php {';
388
+      echo '    include snippets/fastcgi-php.conf;';
389
+      echo '    fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;';
390
+      echo '    fastcgi_read_timeout 30;';
391
+      echo '    fastcgi_param HTTPS off;';
392
+      echo '  }';
393
+      echo '';
394
+      echo '  # Location';
395
+      echo '  location / {'; } >> "$pixelfed_nginx_site"
396
+    nginx_limits "$PIXELFED_DOMAIN_NAME" '15m'
397
+    { echo "    try_files \$uri \$uri/ index.php?\$args;";
398
+      echo '  }';
399
+      echo '}'; } >> "$pixelfed_nginx_site"
400
+
401
+    configure_php
402
+
403
+    cd "/var/www/$PIXELFED_DOMAIN_NAME/htdocs" || exit 36587357
404
+
405
+    cp "/var/www/$PIXELFED_DOMAIN_NAME/htdocs/.env.example" "/var/www/$PIXELFED_DOMAIN_NAME/htdocs/.env"
406
+
407
+    if [[ "$ONION_ONLY" != 'no' ]]; then
408
+        sed -i "s|APP_URL=http://.*|APP_URL=https://\$PIXELFED_DOMAIN_NAME|g" "/var/www/$PIXELFED_DOMAIN_NAME/htdocs/.env"
409
+    else
410
+        sed -i "s|APP_URL=http://.*|APP_URL=http://\$PIXELFED_ONION_HOSTNAME|g" "/var/www/$PIXELFED_DOMAIN_NAME/htdocs/.env"
411
+    fi
412
+    sed -i "s|DB_DATABASE=.*|DB_DATABASE=pixelfed|g" "/var/www/$PIXELFED_DOMAIN_NAME/htdocs/.env"
413
+    sed -i "s|DB_USERNAME=.*|DB_USERNAME=root|g" "/var/www/$PIXELFED_DOMAIN_NAME/htdocs/.env"
414
+    sed -i "s|DB_PASSWORD=.*|DB_PASSWORD=$MARIADB_PASSWORD|g" "/var/www/$PIXELFED_DOMAIN_NAME/htdocs/.env"
415
+    sed -i "s|MAIL_HOST=.*|MAIL_HOST=localhost|g" "/var/www/$PIXELFED_DOMAIN_NAME/htdocs/.env"
416
+    sed -i "s|MAIL_PORT=.*|MAIL_PORT=25|g" "/var/www/$PIXELFED_DOMAIN_NAME/htdocs/.env"
417
+
418
+    chown -R www-data:www-data "/var/www/$PIXELFED_DOMAIN_NAME/htdocs"
419
+
420
+    create_site_certificate "$PIXELFED_DOMAIN_NAME" 'yes'
421
+
422
+    nginx_ensite "$PIXELFED_DOMAIN_NAME"
423
+
424
+    systemctl restart mariadb
425
+
426
+    systemctl restart php7.0-fpm
427
+
428
+    systemctl restart nginx
429
+
430
+    "${PROJECT_NAME}-pass" -u "$MY_USERNAME" -a pixelfed -p "$PIXELFED_ADMIN_PASSWORD"
431
+    set_completion_param "pixelfed domain" "$PIXELFED_DOMAIN_NAME"
432
+
433
+    APP_INSTALLED=1
434
+}
435
+
436
+# NOTE: deliberately there is no "exit 0"

+ 5
- 2
src/freedombone-app-pleroma 查看文件

36
 PLEROMA_PORT=4000
36
 PLEROMA_PORT=4000
37
 PLEROMA_ONION_PORT=8011
37
 PLEROMA_ONION_PORT=8011
38
 PLEROMA_REPO="https://git.pleroma.social/pleroma/pleroma.git"
38
 PLEROMA_REPO="https://git.pleroma.social/pleroma/pleroma.git"
39
-PLEROMA_COMMIT='6b9a6838331210dd514d5ecda52783c183bd1bbf'
39
+PLEROMA_COMMIT='9d054d30bce383437b6bb07c869047f1cb8e164f'
40
 PLEROMA_ADMIN_PASSWORD=
40
 PLEROMA_ADMIN_PASSWORD=
41
 PLEROMA_DIR=/etc/pleroma
41
 PLEROMA_DIR=/etc/pleroma
42
 PLEROMA_SECRET_KEY=""
42
 PLEROMA_SECRET_KEY=""
1207
           echo '';
1207
           echo '';
1208
           echo '    proxy_cache pleroma_media_cache;';
1208
           echo '    proxy_cache pleroma_media_cache;';
1209
           echo '    proxy_cache_lock on;';
1209
           echo '    proxy_cache_lock on;';
1210
+          echo '    proxy_ignore_client_abort on;';
1210
           echo "    proxy_pass http://localhost:$PLEROMA_PORT;";
1211
           echo "    proxy_pass http://localhost:$PLEROMA_PORT;";
1211
           echo '  }';
1212
           echo '  }';
1212
           echo '  # include snippets/well-known.conf;';
1213
           echo '  # include snippets/well-known.conf;';
1268
       echo '';
1269
       echo '';
1269
       echo '    proxy_cache pleroma_media_cache;';
1270
       echo '    proxy_cache pleroma_media_cache;';
1270
       echo '    proxy_cache_lock on;';
1271
       echo '    proxy_cache_lock on;';
1272
+      echo '    proxy_ignore_client_abort on;';
1271
       echo "    proxy_pass http://localhost:$PLEROMA_PORT;";
1273
       echo "    proxy_pass http://localhost:$PLEROMA_PORT;";
1272
       echo '  }';
1274
       echo '  }';
1273
       echo '  # include snippets/well-known.conf;';
1275
       echo '  # include snippets/well-known.conf;';
1380
     systemctl start pleroma
1382
     systemctl start pleroma
1381
 
1383
 
1382
     cd $PLEROMA_DIR || exit 1935638
1384
     cd $PLEROMA_DIR || exit 1935638
1383
-    mix register_user "$MY_USERNAME" "$MY_USERNAME" "$MY_EMAIL_ADDRESS" $"Your bio goes here" "$PLEROMA_ADMIN_PASSWORD"
1385
+    sudo -u pleroma mix register_user "$MY_USERNAME" "$MY_USERNAME" "$MY_EMAIL_ADDRESS" $"Your bio goes here" "$PLEROMA_ADMIN_PASSWORD"
1386
+    sudo -u pleroma mix set_moderator "$MY_USERNAME" true
1384
 
1387
 
1385
     APP_INSTALLED=1
1388
     APP_INSTALLED=1
1386
 }
1389
 }

+ 14
- 4
src/freedombone-app-xmpp 查看文件

43
 XMPP_ECC_CURVE='"secp384r1"'
43
 XMPP_ECC_CURVE='"secp384r1"'
44
 
44
 
45
 prosody_latest_version='0.10'
45
 prosody_latest_version='0.10'
46
-prosody_nightly=478
47
-prosody_nightly_hash='884e773920dbcd0a748d05391235df3ff2b82285357b13cb347c99564512593e'
46
+prosody_nightly=485
47
+prosody_nightly_hash='1b1b6a0daf9fdd3a88c8762751f01f561714c0bd5d907af631d7d036c9e19d39'
48
 prosody_filename=prosody-${prosody_latest_version}-1nightly${prosody_nightly}
48
 prosody_filename=prosody-${prosody_latest_version}-1nightly${prosody_nightly}
49
 prosody_nightly_url="https://prosody.im/nightly/${prosody_latest_version}/latest/${prosody_filename}.tar.gz"
49
 prosody_nightly_url="https://prosody.im/nightly/${prosody_latest_version}/latest/${prosody_filename}.tar.gz"
50
 
50
 
51
 # From https://hg.prosody.im/prosody-modules
51
 # From https://hg.prosody.im/prosody-modules
52
-prosody_modules_filename='prosody-modules-20180322.tar.gz'
53
-prosody_modules_hash='982d0dfcef98e9cb9cee4cc3801b8ce9a503a32e44c32b99df6fe94545b90072'
52
+prosody_modules_filename='prosody-modules-20180602.tar.gz'
53
+prosody_modules_hash='c8ea99a3c9ed25e6471cd7de991a58715f1478e3bf3c5866b9f34a9ef8a863dd'
54
 xmpp_encryption_warning=$"For security reasons, OMEMO or PGP encryption is required for conversations on this server."
54
 xmpp_encryption_warning=$"For security reasons, OMEMO or PGP encryption is required for conversations on this server."
55
 
55
 
56
 XMPP_SHORT_DESCRIPTION=$'Chat system'
56
 XMPP_SHORT_DESCRIPTION=$'Chat system'
435
         sed -i '/"pep";/a "omemo_all_access"; -- Fix for PEP with OMEMO' /etc/prosody/conf.avail/xmpp.cfg.lua
435
         sed -i '/"pep";/a "omemo_all_access"; -- Fix for PEP with OMEMO' /etc/prosody/conf.avail/xmpp.cfg.lua
436
         sed -i 's|"omemo_all_access";|  "omemo_all_access";|g' /etc/prosody/conf.avail/xmpp.cfg.lua
436
         sed -i 's|"omemo_all_access";|  "omemo_all_access";|g' /etc/prosody/conf.avail/xmpp.cfg.lua
437
     fi
437
     fi
438
+
439
+    if ! grep -q "block_strangers" /etc/prosody/conf.avail/xmpp.cfg.lua; then
440
+        sed -i '/"pep";/a "block_strangers"; -- Dont allow messages from strangers' /etc/prosody/conf.avail/xmpp.cfg.lua
441
+        sed -i 's|"block_strangers";|  "block_strangers";|g' /etc/prosody/conf.avail/xmpp.cfg.lua
442
+    fi
443
+    if ! grep -q "block_strangers" /etc/prosody/conf.avail/xmpp.cfg.lua; then
444
+        sed -i '/"pep";/a "block_strangers"; -- Dont allow messages from strangers' /etc/prosody/conf.avail/xmpp.cfg.lua
445
+        sed -i 's|"block_strangers";|  "block_strangers";|g' /etc/prosody/conf.avail/xmpp.cfg.lua
446
+    fi
438
 }
447
 }
439
 
448
 
440
 function prosody_daemon_restart_script {
449
 function prosody_daemon_restart_script {
748
       echo '  "blocklist"; -- Privacy lists';
757
       echo '  "blocklist"; -- Privacy lists';
749
       echo '  "privacy_lists"; -- Privacy lists';
758
       echo '  "privacy_lists"; -- Privacy lists';
750
       echo '  "blocking"; -- Blocking command';
759
       echo '  "blocking"; -- Blocking command';
760
+      echo '  "block_strangers"; -- Dont allow messages from strangers';
751
       echo '  "roster"; -- Roster versioning';
761
       echo '  "roster"; -- Roster versioning';
752
       echo '  "offline_email"; -- If offline send to email';
762
       echo '  "offline_email"; -- If offline send to email';
753
       echo '  "offline"; -- Store offline messages';
763
       echo '  "offline"; -- Store offline messages';

+ 9
- 0
src/freedombone-controlpanel 查看文件

1999
             2) menu_backup_restore;;
1999
             2) menu_backup_restore;;
2000
             3) menu_app_settings;;
2000
             3) menu_app_settings;;
2001
             4) if ! /usr/local/bin/addremove; then
2001
             4) if ! /usr/local/bin/addremove; then
2002
+                   if [ -d /etc/matrix ]; then
2003
+                       systemctl restart matrix
2004
+                       systemctl restart nginx
2005
+                   fi
2002
                    any_key
2006
                    any_key
2007
+               else
2008
+                   if [ -d /etc/matrix ]; then
2009
+                       systemctl restart matrix
2010
+                       systemctl restart nginx
2011
+                   fi
2003
                fi
2012
                fi
2004
                ;;
2013
                ;;
2005
             5) logging_on_off;;
2014
             5) logging_on_off;;

+ 1
- 1
src/freedombone-template 查看文件

999
     echo "      echo 'StandardError=syslog';"
999
     echo "      echo 'StandardError=syslog';"
1000
     echo "      echo '';"
1000
     echo "      echo '';"
1001
     echo "      echo '[Install]';"
1001
     echo "      echo '[Install]';"
1002
-    echo "      echo 'WantedBy=multi-user.target'; } >> \"/etc/systemd/system/${app_name}.service\""
1002
+    echo "      echo 'WantedBy=multi-user.target'; } > \"/etc/systemd/system/${app_name}.service\""
1003
     echo "    systemctl enable ${app_name}"
1003
     echo "    systemctl enable ${app_name}"
1004
     if [ "$app_dir" ]; then
1004
     if [ "$app_dir" ]; then
1005
         echo "    chown -R ${app_name}:${app_name} \"${app_dir}\""
1005
         echo "    chown -R ${app_name}:${app_name} \"${app_dir}\""