Browse Source

Try building peertube locally with a recent node version

Bob Mottram 7 years ago
parent
commit
12b95f0e76
1 changed files with 31 additions and 13 deletions
  1. 31
    13
      src/freedombone-app-peertube

+ 31
- 13
src/freedombone-app-peertube View File

@@ -200,7 +200,9 @@ function upgrade_peertube {
200 200
     function_check set_repo_commit
201 201
     set_repo_commit $PEERTUBE_DIR "peertube commit" "$PEERTUBE_COMMIT" $PEERTUBE_REPO
202 202
 
203
-    npm run upgrade-peertube
203
+    alias npm-exec='PATH=$(npm bin):$PATH'
204
+    npm-exec npm run upgrade-peertube
205
+
204 206
     chown -R peertube:peertube $PEERTUBE_DIR
205 207
     systemctl start peertube
206 208
 }
@@ -770,23 +772,39 @@ function install_peertube {
770 772
     git checkout $PEERTUBE_COMMIT -b $PEERTUBE_COMMIT
771 773
     set_completion_param "peertube commit" "$PEERTUBE_COMMIT"
772 774
 
773
-    npm install -g yarn
775
+    npm install npm@5.6.0
774 776
     if [ ! "$?" = "0" ]; then
775
-        echo $'Failed to install yarn'
776
-        exit 79353234
777
+        echo $'Failed to install local npm version 5.6.0'
778
+        exit 45465774
779
+    fi
780
+    alias npm-exec='PATH=$(npm bin):$PATH'
781
+    npm-exec install node@9.5.0
782
+    if [ ! "$?" = "0" ]; then
783
+        echo $'Failed to install local nodejs version 9.5.0'
784
+        exit 54875459
777 785
     fi
778
-    yarn add -D webpack --network-concurrency 1
779
-    yarn install
786
+    npm install npm@5.6.0
780 787
     if [ ! "$?" = "0" ]; then
781
-        echo $'Failed to run yarn install'
782
-        exit 63754235
788
+        echo $'Failed to install local npm version 5.6.0'
789
+        exit 678356845684
783 790
     fi
784
-    npm install
791
+    npm install yarn@1.3.2
792
+    if [ ! "$?" = "0" ]; then
793
+        echo $'Failed to install yarn'
794
+        exit 578947946
795
+    fi
796
+    npm-exec yarn add -D webpack --network-concurrency 1
797
+    #npm-exec yarn install --non-interactive
798
+    #if [ ! "$?" = "0" ]; then
799
+    #    echo $'Failed to run yarn install'
800
+    #    exit 63754235
801
+    #fi
802
+    npm-exec npm install
785 803
     if [ ! "$?" = "0" ]; then
786 804
         echo $'Failed to install peertube'
787 805
         exit 7835243
788 806
     fi
789
-    npm run build
807
+    npm-exec npm run build
790 808
     if [ ! "$?" = "0" ]; then
791 809
         echo $'Failed to build peertube'
792 810
         exit 5293593
@@ -803,13 +821,13 @@ function install_peertube {
803 821
     echo 'User=peertube' >> /etc/systemd/system/peertube.service
804 822
     echo 'Group=peertube' >> /etc/systemd/system/peertube.service
805 823
     echo "WorkingDirectory=$PEERTUBE_DIR" >> /etc/systemd/system/peertube.service
806
-    echo "ExecStart=/usr/local/bin/npm start" >> /etc/systemd/system/peertube.service
807
-    echo "ExecStop=/usr/local/bin/npm stop" >> /etc/systemd/system/peertube.service
824
+    echo "ExecStart=$PEERTUBE_DIR/node_modules/.bin/npm start" >> /etc/systemd/system/peertube.service
825
+    echo "ExecStop=$PEERTUBE_DIR/node_modules/.bin/npm stop" >> /etc/systemd/system/peertube.service
808 826
     echo 'StandardOutput=syslog' >> /etc/systemd/system/peertube.service
809 827
     echo 'StandardError=syslog' >> /etc/systemd/system/peertube.service
810 828
     echo 'SyslogIdentifier=peertube' >> /etc/systemd/system/peertube.service
811 829
     echo 'Restart=always' >> /etc/systemd/system/peertube.service
812
-    echo "Environment=NODE_ENV=production" >> /etc/systemd/system/peertube.service
830
+    echo "Environment=NODE_ENV=production PATH=\$(npm bin):\$PATH" >> /etc/systemd/system/peertube.service
813 831
     echo '' >> /etc/systemd/system/peertube.service
814 832
     echo '[Install]' >> /etc/systemd/system/peertube.service
815 833
     echo 'WantedBy=multi-user.target' >> /etc/systemd/system/peertube.service