Bob Mottram пре 7 година
родитељ
комит
f5cea90040
1 измењених фајлова са 35 додато и 10 уклоњено
  1. 35
    10
      src/freedombone-app-peertube

+ 35
- 10
src/freedombone-app-peertube Прегледај датотеку

39
 PEERTUBE_DOMAIN_NAME=
39
 PEERTUBE_DOMAIN_NAME=
40
 PEERTUBE_CODE=
40
 PEERTUBE_CODE=
41
 PEERTUBE_REPO="https://github.com/Chocobozzz/PeerTube"
41
 PEERTUBE_REPO="https://github.com/Chocobozzz/PeerTube"
42
-PEERTUBE_COMMIT='c525c093751aba9f1152adbe405daae20a0dc400'
42
+PEERTUBE_COMMIT='a7fea183f0f69104b209e7bfdd6435be28165f22'
43
 PEERTUBE_ONION_PORT=8136
43
 PEERTUBE_ONION_PORT=8136
44
 PEERTUBE_PORT=9004
44
 PEERTUBE_PORT=9004
45
 MESH_PEERTUBE_PORT=8500
45
 MESH_PEERTUBE_PORT=8500
46
 PEERTUBE_DIR=/etc/peertube
46
 PEERTUBE_DIR=/etc/peertube
47
+peertube_npm_version='5.3.0'
48
+peertube_node_version='8.6.0'
47
 
49
 
48
 peertube_variables=(PEERTUBE_DOMAIN_NAME
50
 peertube_variables=(PEERTUBE_DOMAIN_NAME
49
                     PEERTUBE_CODE
51
                     PEERTUBE_CODE
774
     git checkout $PEERTUBE_COMMIT -b $PEERTUBE_COMMIT
776
     git checkout $PEERTUBE_COMMIT -b $PEERTUBE_COMMIT
775
     set_completion_param "peertube commit" "$PEERTUBE_COMMIT"
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
     if [ ! "$?" = "0" ]; then
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
         exit 45465774
782
         exit 45465774
781
     fi
783
     fi
782
     PREV_PATH=$PATH
784
     PREV_PATH=$PATH
783
     PATH=$(npm bin):$PATH
785
     PATH=$(npm bin):$PATH
784
-    npm install node@9.5.0
786
+    npm install node@$peertube_node_version
785
     if [ ! "$?" = "0" ]; then
787
     if [ ! "$?" = "0" ]; then
786
         PATH=$PREV_PATH
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
         exit 54875459
790
         exit 54875459
789
     fi
791
     fi
790
     PATH=$PREV_PATH
792
     PATH=$PREV_PATH
791
-    npm install npm@5.6.0
793
+    npm install npm@$peertube_npm_version
792
     if [ ! "$?" = "0" ]; then
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
         exit 678356845684
796
         exit 678356845684
795
     fi
797
     fi
796
     npm install yarn@1.3.2
798
     npm install yarn@1.3.2
818
         exit 5293593
820
         exit 5293593
819
     fi
821
     fi
820
     PATH=$PREV_PATH
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
     PEERTUBE_ONION_HOSTNAME=$(add_onion_service peertube 80 ${PEERTUBE_ONION_PORT})
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
     echo '[Unit]' > /etc/systemd/system/peertube.service
848
     echo '[Unit]' > /etc/systemd/system/peertube.service
825
     echo 'Description=PeerTube Decentralized video streaming platform' >> /etc/systemd/system/peertube.service
849
     echo 'Description=PeerTube Decentralized video streaming platform' >> /etc/systemd/system/peertube.service
826
     echo 'After=syslog.target' >> /etc/systemd/system/peertube.service
850
     echo 'After=syslog.target' >> /etc/systemd/system/peertube.service
830
     echo 'User=peertube' >> /etc/systemd/system/peertube.service
854
     echo 'User=peertube' >> /etc/systemd/system/peertube.service
831
     echo 'Group=peertube' >> /etc/systemd/system/peertube.service
855
     echo 'Group=peertube' >> /etc/systemd/system/peertube.service
832
     echo "WorkingDirectory=$PEERTUBE_DIR" >> /etc/systemd/system/peertube.service
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
     echo 'StandardOutput=syslog' >> /etc/systemd/system/peertube.service
859
     echo 'StandardOutput=syslog' >> /etc/systemd/system/peertube.service
836
     echo 'StandardError=syslog' >> /etc/systemd/system/peertube.service
860
     echo 'StandardError=syslog' >> /etc/systemd/system/peertube.service
837
     echo 'SyslogIdentifier=peertube' >> /etc/systemd/system/peertube.service
861
     echo 'SyslogIdentifier=peertube' >> /etc/systemd/system/peertube.service
838
     echo 'Restart=always' >> /etc/systemd/system/peertube.service
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
     echo '' >> /etc/systemd/system/peertube.service
865
     echo '' >> /etc/systemd/system/peertube.service
841
     echo '[Install]' >> /etc/systemd/system/peertube.service
866
     echo '[Install]' >> /etc/systemd/system/peertube.service
842
     echo 'WantedBy=multi-user.target' >> /etc/systemd/system/peertube.service
867
     echo 'WantedBy=multi-user.target' >> /etc/systemd/system/peertube.service