浏览代码

More peertube fixes

Bob Mottram 7 年前
父节点
当前提交
f5cea90040
共有 1 个文件被更改,包括 35 次插入10 次删除
  1. 35
    10
      src/freedombone-app-peertube

+ 35
- 10
src/freedombone-app-peertube 查看文件

@@ -39,11 +39,13 @@ SHOW_ON_ABOUT=1
39 39
 PEERTUBE_DOMAIN_NAME=
40 40
 PEERTUBE_CODE=
41 41
 PEERTUBE_REPO="https://github.com/Chocobozzz/PeerTube"
42
-PEERTUBE_COMMIT='c525c093751aba9f1152adbe405daae20a0dc400'
42
+PEERTUBE_COMMIT='a7fea183f0f69104b209e7bfdd6435be28165f22'
43 43
 PEERTUBE_ONION_PORT=8136
44 44
 PEERTUBE_PORT=9004
45 45
 MESH_PEERTUBE_PORT=8500
46 46
 PEERTUBE_DIR=/etc/peertube
47
+peertube_npm_version='5.3.0'
48
+peertube_node_version='8.6.0'
47 49
 
48 50
 peertube_variables=(PEERTUBE_DOMAIN_NAME
49 51
                     PEERTUBE_CODE
@@ -774,23 +776,23 @@ function install_peertube {
774 776
     git checkout $PEERTUBE_COMMIT -b $PEERTUBE_COMMIT
775 777
     set_completion_param "peertube commit" "$PEERTUBE_COMMIT"
776 778
 
777
-    npm install npm@5.6.0
779
+    npm install npm@$peertube_npm_version
778 780
     if [ ! "$?" = "0" ]; then
779
-        echo $'Failed to install local npm version 5.6.0'
781
+        echo $"Failed to install local npm version $peertube_npm_version"
780 782
         exit 45465774
781 783
     fi
782 784
     PREV_PATH=$PATH
783 785
     PATH=$(npm bin):$PATH
784
-    npm install node@9.5.0
786
+    npm install node@$peertube_node_version
785 787
     if [ ! "$?" = "0" ]; then
786 788
         PATH=$PREV_PATH
787
-        echo $'Failed to install local nodejs version 9.5.0'
789
+        echo $"Failed to install local nodejs version $peertube_node_version"
788 790
         exit 54875459
789 791
     fi
790 792
     PATH=$PREV_PATH
791
-    npm install npm@5.6.0
793
+    npm install npm@$peertube_npm_version
792 794
     if [ ! "$?" = "0" ]; then
793
-        echo $'Failed to install local npm version 5.6.0'
795
+        echo $"Failed to install local npm version $peertube_npm_version"
794 796
         exit 678356845684
795 797
     fi
796 798
     npm install yarn@1.3.2
@@ -818,9 +820,31 @@ function install_peertube {
818 820
         exit 5293593
819 821
     fi
820 822
     PATH=$PREV_PATH
823
+    npm install npm@$peertube_npm_version
824
+    if [ ! "$?" = "0" ]; then
825
+        echo $"Failed to install local npm version $peertube_npm_version"
826
+        exit 678356845684
827
+    fi
828
+
829
+    # Hacky stuff to fix runtime errors
830
+    sed -i 's|const url_1 = require("url");|const url_1 = require("url").Url;|g' dist/server/helpers/core-utils.js
831
+    sed -i 's|const urlObject = new url_1.URL(url);|const urlObject = new url_1(url);|g' dist/server/helpers/core-utils.js
832
+    sed -i 's|return urlObject.href.replace(/\/$/, '');|return urlObject.href;|g' dist/server/helpers/core-utils.js
821 833
 
822 834
     PEERTUBE_ONION_HOSTNAME=$(add_onion_service peertube 80 ${PEERTUBE_ONION_PORT})
823 835
 
836
+    echo '#!/bin/bash' > $PEERTUBE_DIR/start
837
+    echo "cd $PEERTUBE_DIR" >> $PEERTUBE_DIR/start
838
+    echo 'PATH=$(npm bin):$PATH' >> $PEERTUBE_DIR/start
839
+    echo 'npm start' >> $PEERTUBE_DIR/start
840
+    chmod +x $PEERTUBE_DIR/start
841
+
842
+    echo '#!/bin/bash' > $PEERTUBE_DIR/stop
843
+    echo "cd $PEERTUBE_DIR" >> $PEERTUBE_DIR/stop
844
+    echo 'PATH=$(npm bin):$PATH' >> $PEERTUBE_DIR/stop
845
+    echo 'npm stop' >> $PEERTUBE_DIR/stop
846
+    chmod +x $PEERTUBE_DIR/stop
847
+
824 848
     echo '[Unit]' > /etc/systemd/system/peertube.service
825 849
     echo 'Description=PeerTube Decentralized video streaming platform' >> /etc/systemd/system/peertube.service
826 850
     echo 'After=syslog.target' >> /etc/systemd/system/peertube.service
@@ -830,13 +854,14 @@ function install_peertube {
830 854
     echo 'User=peertube' >> /etc/systemd/system/peertube.service
831 855
     echo 'Group=peertube' >> /etc/systemd/system/peertube.service
832 856
     echo "WorkingDirectory=$PEERTUBE_DIR" >> /etc/systemd/system/peertube.service
833
-    echo "ExecStart=$PEERTUBE_DIR/node_modules/.bin/npm start" >> /etc/systemd/system/peertube.service
834
-    echo "ExecStop=$PEERTUBE_DIR/node_modules/.bin/npm stop" >> /etc/systemd/system/peertube.service
857
+    echo "ExecStart=$PEERTUBE_DIR/start" >> /etc/systemd/system/peertube.service
858
+    echo "ExecStop=$PEERTUBE_DIR/stop" >> /etc/systemd/system/peertube.service
835 859
     echo 'StandardOutput=syslog' >> /etc/systemd/system/peertube.service
836 860
     echo 'StandardError=syslog' >> /etc/systemd/system/peertube.service
837 861
     echo 'SyslogIdentifier=peertube' >> /etc/systemd/system/peertube.service
838 862
     echo 'Restart=always' >> /etc/systemd/system/peertube.service
839
-    echo "Environment=NODE_ENV=production PATH=\$(npm bin):\$PATH" >> /etc/systemd/system/peertube.service
863
+    echo 'Environment=NODE_ENV=production' >> /etc/systemd/system/peertube.service
864
+    echo "Environment=NODE_CONFIG_DIR=$PEERTUBE_DIR/config" >> /etc/systemd/system/peertube.service
840 865
     echo '' >> /etc/systemd/system/peertube.service
841 866
     echo '[Install]' >> /etc/systemd/system/peertube.service
842 867
     echo 'WantedBy=multi-user.target' >> /etc/systemd/system/peertube.service