浏览代码

Fixing cryptpad

Bob Mottram 6 年前
父节点
当前提交
a3a46febe4
共有 1 个文件被更改,包括 29 次插入11 次删除
  1. 29
    11
      src/freedombone-app-cryptpad

+ 29
- 11
src/freedombone-app-cryptpad 查看文件

@@ -103,8 +103,9 @@ function upgrade_cryptpad {
103 103
     cryptpad_create_config
104 104
     npm upgrade
105 105
     npm install
106
-    su -c 'echo "2" | bower update' - cryptpad
107
-    su -c 'bower install --config.interactive=false' - cryptpad
106
+    rm -rf $CRYPTPAD_DIR/.cache/bower
107
+    su -c './node_modules/bower/bin/bower install --config.interactive=false' - cryptpad
108
+    su -c './node_modules/bower/bin/bower update --config.interactive=false' - cryptpad
108 109
     cryptpad_generate_api_config
109 110
     chown -R cryptpad:cryptpad $CRYPTPAD_DIR
110 111
 
@@ -407,11 +408,19 @@ function mesh_install_cryptpad {
407 408
       echo "    try_files /customize/\$uri /customize.dist/\$uri;";
408 409
       echo '  }';
409 410
       echo '  location = /api/config {';
410
-      echo '    default_type text/javascript;';
411
-      echo '    rewrite ^.*$ /customize/api/config break;';
411
+      echo "    proxy_pass http://localhost:$CRYPTPAD_PORT;";
412
+      echo "    proxy_set_header X-Real-IP \$remote_addr;";
413
+      echo "    proxy_set_header Host \$host;";
414
+      echo "    proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;";
412 415
       echo '  }';
413 416
       echo '';
414 417
       echo '  location ^~ /blob/ {';
418
+      echo '    add_header Cache-Control max-age=31536000;';
419
+      echo "    try_files \$uri =404;";
420
+      echo '  }';
421
+      echo '';
422
+      echo '  location ^~ /datastore/ {';
423
+      echo '    add_header Cache-Control max-age=0;';
415 424
       echo "    try_files \$uri =404;";
416 425
       echo '  }';
417 426
       echo '';
@@ -448,11 +457,11 @@ function mesh_install_cryptpad {
448 457
 
449 458
     cat <<EOF > "$rootdir/usr/bin/install_cryptpad"
450 459
 #!/bin/bash
451
-cd $CRYPTPAD_DIR
460
+cd $CRYPTPAD_DIR || exit 358735
452 461
 npm install --arch=$NPM_ARCH --build-from-source
453
-npm install --arch=$NPM_ARCH -g bower@1.8.0
462
+npm install --arch=$NPM_ARCH bower@1.8.4
454 463
 chown -R cryptpad:cryptpad $CRYPTPAD_DIR
455
-su -c 'bower install' - cryptpad
464
+su -c './node_modules/bower/bin/bower install --config.interactive=false' - cryptpad
456 465
 cp config.example.js config.js
457 466
 EOF
458 467
     chmod +x "$rootdir/usr/bin/install_cryptpad"
@@ -575,11 +584,19 @@ function install_cryptpad_main {
575 584
       echo "    try_files /customize/\$uri /customize.dist/\$uri;";
576 585
       echo '  }';
577 586
       echo '  location = /api/config {';
578
-      echo '    default_type text/javascript;';
579
-      echo '    rewrite ^.*$ /customize/api/config break;';
587
+      echo "    proxy_pass http://localhost:$CRYPTPAD_PORT;";
588
+      echo "    proxy_set_header X-Real-IP \$remote_addr;";
589
+      echo "    proxy_set_header Host \$host;";
590
+      echo "    proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;";
580 591
       echo '  }';
581 592
       echo '';
582 593
       echo '  location ^~ /blob/ {';
594
+      echo '    add_header Cache-Control max-age=31536000;';
595
+      echo "    try_files \$uri =404;";
596
+      echo '  }';
597
+      echo '';
598
+      echo '  location ^~ /datastore/ {';
599
+      echo '    add_header Cache-Control max-age=0;';
583 600
       echo "    try_files \$uri =404;";
584 601
       echo '  }';
585 602
       echo '';
@@ -625,9 +642,10 @@ function install_cryptpad {
625 642
     cd $CRYPTPAD_DIR || exit 35483548
626 643
 
627 644
     npm install
628
-    npm install -g bower@1.8.0
645
+    npm install bower@1.8.4
629 646
     chown -R cryptpad:cryptpad $CRYPTPAD_DIR
630
-    su -c 'bower install' - cryptpad
647
+    su -c './node_modules/bower/bin/bower install --config.interactive=false' - cryptpad
648
+    su -c './node_modules/bower/bin/bower update --config.interactive=false' - cryptpad
631 649
     cp config.example.js config.js
632 650
     if [ ! -f config.js ]; then
633 651
         echo $'Cryptpad config file not found'