|
@@ -39,6 +39,7 @@ PEERTUBE_REPO="https://github.com/Chocobozzz/PeerTube"
|
39
|
39
|
PEERTUBE_COMMIT='fef2c7164e025b12a64185dbab058ef4129733c6'
|
40
|
40
|
PEERTUBE_ONION_PORT=8136
|
41
|
41
|
PEERTUBE_PORT=9004
|
|
42
|
+MESH_PEERTUBE_PORT=8500
|
42
|
43
|
PEERTUBE_DIR=/etc/peertube
|
43
|
44
|
|
44
|
45
|
peertube_variables=(PEERTUBE_DOMAIN_NAME
|
|
@@ -479,21 +480,83 @@ function peertube_setup_web {
|
479
|
480
|
nginx_ensite $PEERTUBE_DOMAIN_NAME
|
480
|
481
|
}
|
481
|
482
|
|
|
483
|
+function mesh_peertube_setup_web {
|
|
484
|
+ peertube_nginx_file=$rootdir/etc/nginx/sites-available/peertube
|
|
485
|
+
|
|
486
|
+ echo 'server {' >> $peertube_nginx_file
|
|
487
|
+ echo " listen $MESH_PEERTUBE_PORT http2;" >> $peertube_nginx_file
|
|
488
|
+ echo ' listen [::]:$MESH_PEERTUBE_PORT http2;' >> $peertube_nginx_file
|
|
489
|
+ echo ' server_name $HOSTNAME;' >> $peertube_nginx_file
|
|
490
|
+ echo '' >> $peertube_nginx_file
|
|
491
|
+ echo ' location / {' >> $peertube_nginx_file
|
|
492
|
+ echo " proxy_pass http://localhost:${PEERTUBE_PORT};" >> $peertube_nginx_file
|
|
493
|
+ echo ' proxy_set_header X-Real-IP $remote_addr;' >> $peertube_nginx_file
|
|
494
|
+ echo ' proxy_set_header Host $host;' >> $peertube_nginx_file
|
|
495
|
+ echo ' proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;' >> $peertube_nginx_file
|
|
496
|
+ echo '' >> $peertube_nginx_file
|
|
497
|
+ echo ' # For the video upload' >> $peertube_nginx_file
|
|
498
|
+ echo ' client_max_body_size 2G;' >> $peertube_nginx_file
|
|
499
|
+ echo ' }' >> $peertube_nginx_file
|
|
500
|
+ echo '' >> $peertube_nginx_file
|
|
501
|
+ echo ' location /static/webseed {' >> $peertube_nginx_file
|
|
502
|
+ echo " if (\$request_method = 'OPTIONS') {" >> $peertube_nginx_file
|
|
503
|
+ echo " add_header 'Access-Control-Allow-Origin' '*';" >> $peertube_nginx_file
|
|
504
|
+ echo " add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS';" >> $peertube_nginx_file
|
|
505
|
+ echo " add_header 'Access-Control-Allow-Headers' 'Range,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';" >> $peertube_nginx_file
|
|
506
|
+ echo " add_header 'Access-Control-Max-Age' 1728000;" >> $peertube_nginx_file
|
|
507
|
+ echo " add_header 'Content-Type' 'text/plain charset=UTF-8';" >> $peertube_nginx_file
|
|
508
|
+ echo " add_header 'Content-Length' 0;" >> $peertube_nginx_file
|
|
509
|
+ echo ' return 204;' >> $peertube_nginx_file
|
|
510
|
+ echo ' }' >> $peertube_nginx_file
|
|
511
|
+ echo '' >> $peertube_nginx_file
|
|
512
|
+ echo " if (\$request_method = 'GET') {" >> $peertube_nginx_file
|
|
513
|
+ echo " add_header 'Access-Control-Allow-Origin' '*';" >> $peertube_nginx_file
|
|
514
|
+ echo " add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS';" >> $peertube_nginx_file
|
|
515
|
+ echo " add_header 'Access-Control-Allow-Headers' 'Range,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';" >> $peertube_nginx_file
|
|
516
|
+ echo ' }' >> $peertube_nginx_file
|
|
517
|
+ echo '' >> $peertube_nginx_file
|
|
518
|
+ echo " alias $PEERTUBE_DIR/videos;" >> $peertube_nginx_file
|
|
519
|
+ echo ' }' >> $peertube_nginx_file
|
|
520
|
+ echo '' >> $peertube_nginx_file
|
|
521
|
+ echo ' # Websocket tracker' >> $peertube_nginx_file
|
|
522
|
+ echo ' location /tracker/socket {' >> $peertube_nginx_file
|
|
523
|
+ echo ' # Peers send a message to the tracker every 15 minutes' >> $peertube_nginx_file
|
|
524
|
+ echo ' # Dont close the websocket before this time' >> $peertube_nginx_file
|
|
525
|
+ echo ' proxy_read_timeout 1200s;' >> $peertube_nginx_file
|
|
526
|
+ echo ' proxy_set_header Upgrade $http_upgrade;' >> $peertube_nginx_file
|
|
527
|
+ echo ' proxy_set_header Connection "upgrade";' >> $peertube_nginx_file
|
|
528
|
+ echo ' proxy_http_version 1.1;' >> $peertube_nginx_file
|
|
529
|
+ echo ' proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;' >> $peertube_nginx_file
|
|
530
|
+ echo ' proxy_set_header Host $host;' >> $peertube_nginx_file
|
|
531
|
+ echo " proxy_pass http://localhost:${PEERTUBE_PORT};" >> $peertube_nginx_file
|
|
532
|
+ echo ' }' >> $peertube_nginx_file
|
|
533
|
+ echo '}' >> $peertube_nginx_file
|
|
534
|
+}
|
|
535
|
+
|
482
|
536
|
function peertube_create_config {
|
483
|
|
- peertube_config_file=$PEERTUBE_DIR/config/production.yaml
|
|
537
|
+ peertube_prefix=$1
|
|
538
|
+
|
|
539
|
+ peertube_config_file=$peertube_prefix$PEERTUBE_DIR/config/production.yaml
|
|
540
|
+
|
484
|
541
|
echo 'listen:' > $peertube_config_file
|
485
|
542
|
echo " port: $PEERTUBE_PORT" >> $peertube_config_file
|
486
|
543
|
echo '' >> $peertube_config_file
|
487
|
544
|
echo '# Correspond to your reverse proxy "listen" configuration' >> $peertube_config_file
|
488
|
545
|
echo 'webserver:' >> $peertube_config_file
|
489
|
|
- if [[ $ONION_ONLY == 'no' ]]; then
|
490
|
|
- echo ' https: true' >> $peertube_config_file
|
491
|
|
- echo " hostname: '$PEERTUBE_DOMAIN_NAME'" >> $peertube_config_file
|
492
|
|
- echo ' port: 443' >> $peertube_config_file
|
|
546
|
+ if [ ! $peertube_prefix ]; then
|
|
547
|
+ if [[ $ONION_ONLY == 'no' ]]; then
|
|
548
|
+ echo ' https: true' >> $peertube_config_file
|
|
549
|
+ echo " hostname: '$PEERTUBE_DOMAIN_NAME'" >> $peertube_config_file
|
|
550
|
+ echo ' port: 443' >> $peertube_config_file
|
|
551
|
+ else
|
|
552
|
+ echo ' https: false' >> $peertube_config_file
|
|
553
|
+ echo " hostname: '$PEERTUBE_ONION_HOSTNAME'" >> $peertube_config_file
|
|
554
|
+ echo ' port: 80' >> $peertube_config_file
|
|
555
|
+ fi
|
493
|
556
|
else
|
494
|
557
|
echo ' https: false' >> $peertube_config_file
|
495
|
|
- echo " hostname: '$PEERTUBE_ONION_HOSTNAME'" >> $peertube_config_file
|
496
|
|
- echo ' port: 80' >> $peertube_config_file
|
|
558
|
+ echo " hostname: ''" >> $peertube_config_file
|
|
559
|
+ echo " port: $MESH_PEERTUBE_PORT" >> $peertube_config_file
|
497
|
560
|
fi
|
498
|
561
|
echo '' >> $peertube_config_file
|
499
|
562
|
echo '# Your database name will be "peertube"+database.suffix' >> $peertube_config_file
|
|
@@ -502,7 +565,11 @@ function peertube_create_config {
|
502
|
565
|
echo ' port: 5432' >> $peertube_config_file
|
503
|
566
|
echo " suffix: ''" >> $peertube_config_file
|
504
|
567
|
echo " username: 'peertube'" >> $peertube_config_file
|
505
|
|
- echo " password: '$PEERTUBE_ADMIN_PASSWORD'" >> $peertube_config_file
|
|
568
|
+ if [ ! $peertube_prefix ]; then
|
|
569
|
+ echo " password: '$PEERTUBE_ADMIN_PASSWORD'" >> $peertube_config_file
|
|
570
|
+ else
|
|
571
|
+ echo " password: ''" >> $peertube_config_file
|
|
572
|
+ fi
|
506
|
573
|
echo '' >> $peertube_config_file
|
507
|
574
|
echo '# From the project root directory' >> $peertube_config_file
|
508
|
575
|
echo 'storage:' >> $peertube_config_file
|
|
@@ -519,7 +586,7 @@ function peertube_create_config {
|
519
|
586
|
echo ' size: 10 # Max number of previews you want to cache' >> $peertube_config_file
|
520
|
587
|
echo '' >> $peertube_config_file
|
521
|
588
|
echo 'admin:' >> $peertube_config_file
|
522
|
|
- echo " email: '$MY_EMAIL_ADDRESS'" >> $peertube_config_file
|
|
589
|
+ echo " email: 'root@local'" >> $peertube_config_file
|
523
|
590
|
echo '' >> $peertube_config_file
|
524
|
591
|
echo 'signup:' >> $peertube_config_file
|
525
|
592
|
echo ' enabled: true' >> $peertube_config_file
|
|
@@ -543,7 +610,93 @@ function peertube_create_config {
|
543
|
610
|
echo ' 1080p: false' >> $peertube_config_file
|
544
|
611
|
}
|
545
|
612
|
|
|
613
|
+function mesh_install_peertube {
|
|
614
|
+ if [[ $VARIANT != "meshclient" && $VARIANT != "meshusb" ]]; then
|
|
615
|
+ return
|
|
616
|
+ fi
|
|
617
|
+
|
|
618
|
+ chroot "$rootdir" apt-get -yq install ffmpeg
|
|
619
|
+
|
|
620
|
+ function_check install_postgresql
|
|
621
|
+ install_postgresql
|
|
622
|
+
|
|
623
|
+ if [ -d $rootdir$PEERTUBE_DIR ]; then
|
|
624
|
+ rm -rf $rootdir$PEERTUBE_DIR
|
|
625
|
+ fi
|
|
626
|
+
|
|
627
|
+ chroot "$rootdir" groupadd peertube
|
|
628
|
+ chroot "$rootdir" useradd -c "PeerTube system account" -d $PEERTUBE_DIR -m -r -g peertube peertube
|
|
629
|
+
|
|
630
|
+ #peertube_create_database
|
|
631
|
+
|
|
632
|
+ git clone $PEERTUBE_REPO $rootdir$PEERTUBE_DIR
|
|
633
|
+
|
|
634
|
+ cd $rootdir$PEERTUBE_DIR
|
|
635
|
+ git checkout $PEERTUBE_COMMIT -b $PEERTUBE_COMMIT
|
|
636
|
+
|
|
637
|
+ get_npm_arch
|
|
638
|
+
|
|
639
|
+ cat <<EOF > $rootdir/usr/bin/install_peertube
|
|
640
|
+#!/bin/bash
|
|
641
|
+cd $PEERTUBE_DIR
|
|
642
|
+npm install --arch=$NPM_ARCH -g yarn
|
|
643
|
+if [ ! "$?" = "0" ]; then
|
|
644
|
+ echo $'PeerTube Failed to install yarn'
|
|
645
|
+ exit 79353234
|
|
646
|
+fi
|
|
647
|
+yarn add -D webpack --network-concurrency 1
|
|
648
|
+yarn install
|
|
649
|
+if [ ! "$?" = "0" ]; then
|
|
650
|
+ echo $'PeerTube Failed to run yarn install'
|
|
651
|
+ exit 63754235
|
|
652
|
+fi
|
|
653
|
+npm install --arch=$NPM_ARCH
|
|
654
|
+if [ ! "$?" = "0" ]; then
|
|
655
|
+ echo $'PeerTube Failed to install peertube'
|
|
656
|
+ exit 7835243
|
|
657
|
+fi
|
|
658
|
+npm run build --arch=$NPM_ARCH
|
|
659
|
+if [ ! "$?" = "0" ]; then
|
|
660
|
+ echo $'PeerTube Failed to build peertube'
|
|
661
|
+ exit 5293593
|
|
662
|
+fi
|
|
663
|
+EOF
|
|
664
|
+ chmod +x $rootdir/usr/bin/install_peertube
|
|
665
|
+ chroot "$rootdir" /usr/bin/install_peertube
|
|
666
|
+
|
|
667
|
+ echo '[Unit]' > $rootdir/etc/systemd/system/peertube.service
|
|
668
|
+ echo 'Description=PeerTube Decentralized video streaming platform' >> $rootdir/etc/systemd/system/peertube.service
|
|
669
|
+ echo 'After=syslog.target' >> $rootdir/etc/systemd/system/peertube.service
|
|
670
|
+ echo 'After=network.target' >> $rootdir/etc/systemd/system/peertube.service
|
|
671
|
+ echo '' >> $rootdir/etc/systemd/system/peertube.service
|
|
672
|
+ echo '[Service]' >> $rootdir/etc/systemd/system/peertube.service
|
|
673
|
+ echo 'User=peertube' >> $rootdir/etc/systemd/system/peertube.service
|
|
674
|
+ echo 'Group=peertube' >> $rootdir/etc/systemd/system/peertube.service
|
|
675
|
+ echo "WorkingDirectory=$PEERTUBE_DIR" >> $rootdir/etc/systemd/system/peertube.service
|
|
676
|
+ echo "ExecStart=/usr/local/bin/npm start" >> $rootdir/etc/systemd/system/peertube.service
|
|
677
|
+ echo "ExecStop=/usr/local/bin/npm stop" >> $rootdir/etc/systemd/system/peertube.service
|
|
678
|
+ echo 'StandardOutput=syslog' >> $rootdir/etc/systemd/system/peertube.service
|
|
679
|
+ echo 'StandardError=syslog' >> $rootdir/etc/systemd/system/peertube.service
|
|
680
|
+ echo 'SyslogIdentifier=peertube' >> $rootdir/etc/systemd/system/peertube.service
|
|
681
|
+ echo 'Restart=always' >> $rootdir/etc/systemd/system/peertube.service
|
|
682
|
+ echo "Environment=NODE_ENV=production" >> $rootdir/etc/systemd/system/peertube.service
|
|
683
|
+ echo '' >> $rootdir/etc/systemd/system/peertube.service
|
|
684
|
+ echo '[Install]' >> $rootdir/etc/systemd/system/peertube.service
|
|
685
|
+ echo 'WantedBy=multi-user.target' >> $rootdir/etc/systemd/system/peertube.service
|
|
686
|
+
|
|
687
|
+ peertube_create_config $rootdir
|
|
688
|
+
|
|
689
|
+ chroot "$rootdir" chown -R peertube:peertube $PEERTUBE_DIR
|
|
690
|
+
|
|
691
|
+ mesh_peertube_setup_web
|
|
692
|
+}
|
|
693
|
+
|
546
|
694
|
function install_peertube {
|
|
695
|
+ if [[ $VARIANT == "mesh"* ]]; then
|
|
696
|
+ mesh_install_peertube
|
|
697
|
+ return
|
|
698
|
+ fi
|
|
699
|
+
|
547
|
700
|
if [ ! $ONION_ONLY ]; then
|
548
|
701
|
ONION_ONLY='no'
|
549
|
702
|
fi
|