Bob Mottram 8 лет назад
Родитель
Сommit
f1ae5ddd38
1 измененных файлов: 17 добавлений и 12 удалений
  1. 17
    12
      src/freedombone-app-matrix

+ 17
- 12
src/freedombone-app-matrix Просмотреть файл

@@ -86,11 +86,11 @@ function matrix_nginx {
86 86
         echo '  index index.html;' >> $matrix_nginx_site
87 87
         echo '' >> $matrix_nginx_site
88 88
         echo '  # Location' >> $matrix_nginx_site
89
-        echo '  location / {' >> $matrix_nginx_site
89
+        echo '  location /_matrix {' >> $matrix_nginx_site
90 90
         function_check nginx_limits
91 91
         nginx_limits ${MATRIX_DOMAIN_NAME} '15m'
92
-        echo "      proxy_pass http://localhost:${MATRIX_PORT}/_matrix;" >> $matrix_nginx_site
93
-        echo '      proxy_set_header X-Forwarded-For $remote_addr;' >> $matrix_nginx_site
92
+        echo '    proxy_pass http://localhost:8008;' >> $matrix_nginx_site
93
+        echo '    proxy_set_header X-Forwarded-For $remote_addr;' >> $matrix_nginx_site
94 94
         echo '  }' >> $matrix_nginx_site
95 95
         echo '}' >> $matrix_nginx_site
96 96
         echo '' >> $matrix_nginx_site
@@ -116,11 +116,11 @@ function matrix_nginx {
116 116
         echo '  index index.html;' >> $matrix_nginx_site
117 117
         echo '' >> $matrix_nginx_site
118 118
         echo '  # Location' >> $matrix_nginx_site
119
-        echo '  location / {' >> $matrix_nginx_site
119
+        echo '  location /_matrix {' >> $matrix_nginx_site
120 120
         function_check nginx_limits
121 121
         nginx_limits ${MATRIX_DOMAIN_NAME} '15m'
122
-        echo "      proxy_pass http://localhost:${MATRIX_ID_PORT};" >> $matrix_nginx_site
123
-        echo '      proxy_set_header X-Forwarded-For $remote_addr;' >> $matrix_nginx_site
122
+        echo '    proxy_pass http://localhost:8008;' >> $matrix_nginx_site
123
+        echo '    proxy_set_header X-Forwarded-For $remote_addr;' >> $matrix_nginx_site
124 124
         echo '  }' >> $matrix_nginx_site
125 125
         echo '}' >> $matrix_nginx_site
126 126
         echo '' >> $matrix_nginx_site
@@ -300,13 +300,18 @@ function remove_user_matrix {
300 300
 function add_user_matrix {
301 301
     new_username="$1"
302 302
     new_user_password="$2"
303
+    is_admin_user='-a'
304
+
305
+    if [[ "$new_username" != "$MY_USERNAME" ]]; then
306
+        is_admin_user=''
307
+    fi
303 308
 
304 309
     ${PROJECT_NAME}-pass -u $new_username -a matrix -p "$new_user_password"
305 310
 
306 311
     if [[ $ONION_ONLY == 'no' ]]; then
307
-        retval=$(register_new_matrix_user -c ${MATRIX_DATA_DIR}/homeserver.yaml -u "${new_username}" -p "${new_user_password}" -a https://${MATRIX_DOMAIN_NAME})
312
+        retval=$(register_new_matrix_user -c ${MATRIX_DATA_DIR}/homeserver.yaml -u "${new_username}" -p "${new_user_password}" $is_admin_user https://${MATRIX_DOMAIN_NAME})
308 313
     else
309
-        retval=$(register_new_matrix_user -c ${MATRIX_DATA_DIR}/homeserver.yaml -u "${new_username}" -p "${new_user_password}" -a http://${MATRIX_DOMAIN_NAME})
314
+        retval=$(register_new_matrix_user -c ${MATRIX_DATA_DIR}/homeserver.yaml -u "${new_username}" -p "${new_user_password}" $is_admin_user http://${MATRIX_DOMAIN_NAME})
310 315
     fi
311 316
     echo "0"
312 317
 }
@@ -783,10 +788,10 @@ function install_matrix {
783 788
     function_check matrix_nginx
784 789
     matrix_nginx
785 790
 
786
-    #if [[ $(add_user_matrix "${MY_USERNAME}" "${MATRIX_PASSWORD}" | tail -n 1) != "0" ]]; then
787
-    #    echo $'Failed to add matrix admin user';
788
-    #    exit 879352
789
-    #fi
791
+    if [[ $(add_user_matrix "${MY_USERNAME}" "${MATRIX_PASSWORD}" | tail -n 1) != "0" ]]; then
792
+        echo $'Failed to add matrix admin user';
793
+        exit 879352
794
+    fi
790 795
 
791 796
     APP_INSTALLED=1
792 797
 }