From f5cea90040450860a9fe109386db88e0b923f2f7 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 9 Feb 2018 21:02:28 +0000 Subject: [PATCH] More peertube fixes --- src/freedombone-app-peertube | 45 ++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/src/freedombone-app-peertube b/src/freedombone-app-peertube index a573795e..4659d2c0 100755 --- a/src/freedombone-app-peertube +++ b/src/freedombone-app-peertube @@ -39,11 +39,13 @@ SHOW_ON_ABOUT=1 PEERTUBE_DOMAIN_NAME= PEERTUBE_CODE= PEERTUBE_REPO="https://github.com/Chocobozzz/PeerTube" -PEERTUBE_COMMIT='c525c093751aba9f1152adbe405daae20a0dc400' +PEERTUBE_COMMIT='a7fea183f0f69104b209e7bfdd6435be28165f22' PEERTUBE_ONION_PORT=8136 PEERTUBE_PORT=9004 MESH_PEERTUBE_PORT=8500 PEERTUBE_DIR=/etc/peertube +peertube_npm_version='5.3.0' +peertube_node_version='8.6.0' peertube_variables=(PEERTUBE_DOMAIN_NAME PEERTUBE_CODE @@ -774,23 +776,23 @@ function install_peertube { git checkout $PEERTUBE_COMMIT -b $PEERTUBE_COMMIT set_completion_param "peertube commit" "$PEERTUBE_COMMIT" - npm install npm@5.6.0 + npm install npm@$peertube_npm_version if [ ! "$?" = "0" ]; then - echo $'Failed to install local npm version 5.6.0' + echo $"Failed to install local npm version $peertube_npm_version" exit 45465774 fi PREV_PATH=$PATH PATH=$(npm bin):$PATH - npm install node@9.5.0 + npm install node@$peertube_node_version if [ ! "$?" = "0" ]; then PATH=$PREV_PATH - echo $'Failed to install local nodejs version 9.5.0' + echo $"Failed to install local nodejs version $peertube_node_version" exit 54875459 fi PATH=$PREV_PATH - npm install npm@5.6.0 + npm install npm@$peertube_npm_version if [ ! "$?" = "0" ]; then - echo $'Failed to install local npm version 5.6.0' + echo $"Failed to install local npm version $peertube_npm_version" exit 678356845684 fi npm install yarn@1.3.2 @@ -818,9 +820,31 @@ function install_peertube { exit 5293593 fi PATH=$PREV_PATH + npm install npm@$peertube_npm_version + if [ ! "$?" = "0" ]; then + echo $"Failed to install local npm version $peertube_npm_version" + exit 678356845684 + fi + + # Hacky stuff to fix runtime errors + sed -i 's|const url_1 = require("url");|const url_1 = require("url").Url;|g' dist/server/helpers/core-utils.js + sed -i 's|const urlObject = new url_1.URL(url);|const urlObject = new url_1(url);|g' dist/server/helpers/core-utils.js + sed -i 's|return urlObject.href.replace(/\/$/, '');|return urlObject.href;|g' dist/server/helpers/core-utils.js PEERTUBE_ONION_HOSTNAME=$(add_onion_service peertube 80 ${PEERTUBE_ONION_PORT}) + echo '#!/bin/bash' > $PEERTUBE_DIR/start + echo "cd $PEERTUBE_DIR" >> $PEERTUBE_DIR/start + echo 'PATH=$(npm bin):$PATH' >> $PEERTUBE_DIR/start + echo 'npm start' >> $PEERTUBE_DIR/start + chmod +x $PEERTUBE_DIR/start + + echo '#!/bin/bash' > $PEERTUBE_DIR/stop + echo "cd $PEERTUBE_DIR" >> $PEERTUBE_DIR/stop + echo 'PATH=$(npm bin):$PATH' >> $PEERTUBE_DIR/stop + echo 'npm stop' >> $PEERTUBE_DIR/stop + chmod +x $PEERTUBE_DIR/stop + echo '[Unit]' > /etc/systemd/system/peertube.service echo 'Description=PeerTube Decentralized video streaming platform' >> /etc/systemd/system/peertube.service echo 'After=syslog.target' >> /etc/systemd/system/peertube.service @@ -830,13 +854,14 @@ function install_peertube { echo 'User=peertube' >> /etc/systemd/system/peertube.service echo 'Group=peertube' >> /etc/systemd/system/peertube.service echo "WorkingDirectory=$PEERTUBE_DIR" >> /etc/systemd/system/peertube.service - echo "ExecStart=$PEERTUBE_DIR/node_modules/.bin/npm start" >> /etc/systemd/system/peertube.service - echo "ExecStop=$PEERTUBE_DIR/node_modules/.bin/npm stop" >> /etc/systemd/system/peertube.service + echo "ExecStart=$PEERTUBE_DIR/start" >> /etc/systemd/system/peertube.service + echo "ExecStop=$PEERTUBE_DIR/stop" >> /etc/systemd/system/peertube.service echo 'StandardOutput=syslog' >> /etc/systemd/system/peertube.service echo 'StandardError=syslog' >> /etc/systemd/system/peertube.service echo 'SyslogIdentifier=peertube' >> /etc/systemd/system/peertube.service echo 'Restart=always' >> /etc/systemd/system/peertube.service - echo "Environment=NODE_ENV=production PATH=\$(npm bin):\$PATH" >> /etc/systemd/system/peertube.service + echo 'Environment=NODE_ENV=production' >> /etc/systemd/system/peertube.service + echo "Environment=NODE_CONFIG_DIR=$PEERTUBE_DIR/config" >> /etc/systemd/system/peertube.service echo '' >> /etc/systemd/system/peertube.service echo '[Install]' >> /etc/systemd/system/peertube.service echo 'WantedBy=multi-user.target' >> /etc/systemd/system/peertube.service