浏览代码

Restore matrix user creation

Bob Mottram 8 年前
父节点
当前提交
f1ae5ddd38
共有 1 个文件被更改,包括 17 次插入12 次删除
  1. 17
    12
      src/freedombone-app-matrix

+ 17
- 12
src/freedombone-app-matrix 查看文件

86
         echo '  index index.html;' >> $matrix_nginx_site
86
         echo '  index index.html;' >> $matrix_nginx_site
87
         echo '' >> $matrix_nginx_site
87
         echo '' >> $matrix_nginx_site
88
         echo '  # Location' >> $matrix_nginx_site
88
         echo '  # Location' >> $matrix_nginx_site
89
-        echo '  location / {' >> $matrix_nginx_site
89
+        echo '  location /_matrix {' >> $matrix_nginx_site
90
         function_check nginx_limits
90
         function_check nginx_limits
91
         nginx_limits ${MATRIX_DOMAIN_NAME} '15m'
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
         echo '  }' >> $matrix_nginx_site
94
         echo '  }' >> $matrix_nginx_site
95
         echo '}' >> $matrix_nginx_site
95
         echo '}' >> $matrix_nginx_site
96
         echo '' >> $matrix_nginx_site
96
         echo '' >> $matrix_nginx_site
116
         echo '  index index.html;' >> $matrix_nginx_site
116
         echo '  index index.html;' >> $matrix_nginx_site
117
         echo '' >> $matrix_nginx_site
117
         echo '' >> $matrix_nginx_site
118
         echo '  # Location' >> $matrix_nginx_site
118
         echo '  # Location' >> $matrix_nginx_site
119
-        echo '  location / {' >> $matrix_nginx_site
119
+        echo '  location /_matrix {' >> $matrix_nginx_site
120
         function_check nginx_limits
120
         function_check nginx_limits
121
         nginx_limits ${MATRIX_DOMAIN_NAME} '15m'
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
         echo '  }' >> $matrix_nginx_site
124
         echo '  }' >> $matrix_nginx_site
125
         echo '}' >> $matrix_nginx_site
125
         echo '}' >> $matrix_nginx_site
126
         echo '' >> $matrix_nginx_site
126
         echo '' >> $matrix_nginx_site
300
 function add_user_matrix {
300
 function add_user_matrix {
301
     new_username="$1"
301
     new_username="$1"
302
     new_user_password="$2"
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
     ${PROJECT_NAME}-pass -u $new_username -a matrix -p "$new_user_password"
309
     ${PROJECT_NAME}-pass -u $new_username -a matrix -p "$new_user_password"
305
 
310
 
306
     if [[ $ONION_ONLY == 'no' ]]; then
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
     else
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
     fi
315
     fi
311
     echo "0"
316
     echo "0"
312
 }
317
 }
783
     function_check matrix_nginx
788
     function_check matrix_nginx
784
     matrix_nginx
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
     APP_INSTALLED=1
796
     APP_INSTALLED=1
792
 }
797
 }