浏览代码

Handle onion only installs of matrix

Bob Mottram 8 年前
父节点
当前提交
51ab10094e
共有 2 个文件被更改,包括 23 次插入2 次删除
  1. 18
    0
      src/freedombone-app-matrix
  2. 5
    2
      src/freedombone-utils-turn

+ 18
- 0
src/freedombone-app-matrix 查看文件

@@ -59,6 +59,19 @@ function matrix_nginx {
59 59
         proxy_buffering on; \
60 60
     }'
61 61
 
62
+    if [[ $ONION_ONLY != 'no' ]]; then
63
+        matrix_proxy_str=' \
64
+    location /matrix { \
65
+        proxy_pass http://localhost:8448; \
66
+        proxy_buffering on; \
67
+    }'
68
+        turn_proxy_str=' \
69
+    location /turn { \
70
+        proxy_pass http://localhost:3478; \
71
+        proxy_buffering on; \
72
+    }'
73
+    fi
74
+
62 75
     if [ ! -f /etc/nginx/sites-available/${DEFAULT_DOMAIN_NAME} ]; then
63 76
         matrix_nginx_site=/etc/nginx/sites-available/$DEFAULT_DOMAIN_NAME
64 77
         if [[ $ONION_ONLY == "no" ]]; then
@@ -450,6 +463,7 @@ function install_matrix {
450 463
     groupadd matrix
451 464
     useradd -c "Matrix system account" -d $MATRIX_DATA_DIR -m -r -g matrix matrix
452 465
 
466
+    chmod -R 700 /var/lib/matrix/homeserver.yaml
453 467
     chown -R matrix:matrix /etc/matrix
454 468
     chown -R matrix:matrix $MATRIX_DATA_DIR
455 469
 
@@ -471,6 +485,10 @@ function install_matrix {
471 485
     systemctl daemon-reload
472 486
     systemctl start matrix
473 487
 
488
+    if [ -f /var/lib/matrix/homeserver.db ]; then
489
+        chmod -R 700 /var/lib/matrix/homeserver.db
490
+    fi
491
+
474 492
     update_default_domain
475 493
 
476 494
     firewall_add matrix ${MATRIX_PORT}

+ 5
- 2
src/freedombone-utils-turn 查看文件

@@ -38,8 +38,10 @@ function generate_turn_key {
38 38
     echo "use-auth-secret" >> "${filepath}"
39 39
     echo "static-auth-secret=${turnkey}" >> "${filepath}"
40 40
     echo "realm=turn.${DEFAULT_DOMAIN_NAME}" >> "${filepath}"
41
-    echo "cert=$MATRIX_DATA_DIR/${DEFAULT_DOMAIN_NAME}.tls.crt" >> "${filepath}"
42
-    echo "pkey=$MATRIX_DATA_DIR/${DEFAULT_DOMAIN_NAME}.tls.key" >> "${filepath}"
41
+    if [[ $ONION_ONLY == 'no' ]]; then
42
+        echo "cert=$MATRIX_DATA_DIR/${DEFAULT_DOMAIN_NAME}.tls.crt" >> "${filepath}"
43
+        echo "pkey=$MATRIX_DATA_DIR/${DEFAULT_DOMAIN_NAME}.tls.key" >> "${filepath}"
44
+    fi
43 45
 }
44 46
 
45 47
 function remove_turn {
@@ -84,6 +86,7 @@ function install_turn {
84 86
     turnkey="$(create_password 30)"
85 87
     generate_turn_key $turnkey /var/lib/turn/turnserver.conf
86 88
 
89
+    chmod -R 700 /var/lib/turn/turnserver.conf
87 90
     chown -R matrix:matrix /var/lib/turn
88 91
 
89 92
     echo '[Unit]' > /etc/systemd/system/turn.service