Bob Mottram пре 6 година
родитељ
комит
a3a46febe4
1 измењених фајлова са 29 додато и 11 уклоњено
  1. 29
    11
      src/freedombone-app-cryptpad

+ 29
- 11
src/freedombone-app-cryptpad Прегледај датотеку

103
     cryptpad_create_config
103
     cryptpad_create_config
104
     npm upgrade
104
     npm upgrade
105
     npm install
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
     cryptpad_generate_api_config
109
     cryptpad_generate_api_config
109
     chown -R cryptpad:cryptpad $CRYPTPAD_DIR
110
     chown -R cryptpad:cryptpad $CRYPTPAD_DIR
110
 
111
 
407
       echo "    try_files /customize/\$uri /customize.dist/\$uri;";
408
       echo "    try_files /customize/\$uri /customize.dist/\$uri;";
408
       echo '  }';
409
       echo '  }';
409
       echo '  location = /api/config {';
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
       echo '  }';
415
       echo '  }';
413
       echo '';
416
       echo '';
414
       echo '  location ^~ /blob/ {';
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
       echo "    try_files \$uri =404;";
424
       echo "    try_files \$uri =404;";
416
       echo '  }';
425
       echo '  }';
417
       echo '';
426
       echo '';
448
 
457
 
449
     cat <<EOF > "$rootdir/usr/bin/install_cryptpad"
458
     cat <<EOF > "$rootdir/usr/bin/install_cryptpad"
450
 #!/bin/bash
459
 #!/bin/bash
451
-cd $CRYPTPAD_DIR
460
+cd $CRYPTPAD_DIR || exit 358735
452
 npm install --arch=$NPM_ARCH --build-from-source
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
 chown -R cryptpad:cryptpad $CRYPTPAD_DIR
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
 cp config.example.js config.js
465
 cp config.example.js config.js
457
 EOF
466
 EOF
458
     chmod +x "$rootdir/usr/bin/install_cryptpad"
467
     chmod +x "$rootdir/usr/bin/install_cryptpad"
575
       echo "    try_files /customize/\$uri /customize.dist/\$uri;";
584
       echo "    try_files /customize/\$uri /customize.dist/\$uri;";
576
       echo '  }';
585
       echo '  }';
577
       echo '  location = /api/config {';
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
       echo '  }';
591
       echo '  }';
581
       echo '';
592
       echo '';
582
       echo '  location ^~ /blob/ {';
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
       echo "    try_files \$uri =404;";
600
       echo "    try_files \$uri =404;";
584
       echo '  }';
601
       echo '  }';
585
       echo '';
602
       echo '';
625
     cd $CRYPTPAD_DIR || exit 35483548
642
     cd $CRYPTPAD_DIR || exit 35483548
626
 
643
 
627
     npm install
644
     npm install
628
-    npm install -g bower@1.8.0
645
+    npm install bower@1.8.4
629
     chown -R cryptpad:cryptpad $CRYPTPAD_DIR
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
     cp config.example.js config.js
649
     cp config.example.js config.js
632
     if [ ! -f config.js ]; then
650
     if [ ! -f config.js ]; then
633
         echo $'Cryptpad config file not found'
651
         echo $'Cryptpad config file not found'