freedomboneeee/src/freedombone-app-peertube

595 lines
23 KiB
Plaintext
Raw Normal View History

2017-11-29 15:23:07 +01:00
#!/bin/bash
#
# .---. . .
# | | |
# |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
# | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
# ' ' --' --' -' - -' ' ' -' -' -' ' - --'
#
# Freedom in the Cloud
#
# PeerTube server
#
# License
# =======
#
# Copyright (C) 2017 Bob Mottram <bob@freedombone.net>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
VARIANTS="full full-vim media"
IN_DEFAULT_INSTALL=0
SHOW_ON_ABOUT=1
PEERTUBE_DOMAIN_NAME=
PEERTUBE_CODE=
PEERTUBE_REPO="https://github.com/Chocobozzz/PeerTube"
2017-11-30 19:55:12 +01:00
PEERTUBE_COMMIT='fef2c7164e025b12a64185dbab058ef4129733c6'
2017-11-29 15:23:07 +01:00
PEERTUBE_ONION_PORT=8136
PEERTUBE_PORT=9000
PEERTUBE_DIR=/etc/peertube
peertube_variables=(PEERTUBE_DOMAIN_NAME
PEERTUBE_CODE
PEERTUBE_ADMIN_PASSWORD
ONION_ONLY
DDNS_PROVIDER
MY_USERNAME
MY_EMAIL_ADDRESS)
function peertube_create_database {
if [ -f $IMAGE_PASSWORD_FILE ]; then
PEERTUBE_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
else
if [ ! $PEERTUBE_ADMIN_PASSWORD ]; then
PEERTUBE_ADMIN_PASSWORD="$(create_password ${MINIMUM_PASSWORD_LENGTH})"
fi
fi
if [ ! $PEERTUBE_ADMIN_PASSWORD ]; then
return
fi
systemctl restart postgresql
2017-11-29 23:02:55 +01:00
run_system_query_postgresql "CREATE USER peertube WITH PASSWORD '$PEERTUBE_ADMIN_PASSWORD';"
run_system_query_postgresql "CREATE DATABASE peertube OWNER peertube;"
run_system_query_postgresql "GRANT ALL PRIVILEGES ON DATABASE peertube to peertube;"
2017-11-29 15:23:07 +01:00
run_system_query_postgresql "set statement_timeout to 40000;"
}
function logging_on_peertube {
echo -n ''
}
function logging_off_peertube {
echo -n ''
}
function remove_user_peertube {
remove_username="$1"
}
function add_user_peertube {
if [[ $(app_is_installed peertube) == "0" ]]; then
echo '0'
return
fi
new_username="$1"
new_user_password="$2"
echo '0'
}
function install_interactive_peertube {
if [ ! $ONION_ONLY ]; then
ONION_ONLY='no'
fi
if [[ $ONION_ONLY != "no" ]]; then
PEERTUBE_DOMAIN_NAME='peertube.local'
write_config_param "PEERTUBE_DOMAIN_NAME" "$PEERTUBE_DOMAIN_NAME"
else
function_check interactive_site_details
interactive_site_details "peertube" "PEERTUBE_DOMAIN_NAME" "PEERTUBE_CODE"
fi
APP_INSTALLED=1
}
function change_password_peertube {
PEERTUBE_USERNAME="$1"
PEERTUBE_PASSWORD="$2"
if [ ${#PEERTUBE_PASSWORD} -lt 8 ]; then
echo $'Peertube password is too short'
return
fi
#${PROJECT_NAME}-pass -u $PEERTUBE_USERNAME -a peertube -p "$PEERTUBE_PASSWORD"
}
function reconfigure_peertube {
echo -n ''
}
function upgrade_peertube {
CURR_PEERTUBE_COMMIT=$(get_completion_param "peertube commit")
if [[ "$CURR_PEERTUBE_COMMIT" == "$PEERTUBE_COMMIT" ]]; then
return
fi
read_config_param PEERTUBE_DOMAIN_NAME
systemctl stop peertube
cd $PEERTUBE_DIR
function_check set_repo_commit
set_repo_commit $PEERTUBE_DIR "peertube commit" "$PEERTUBE_COMMIT" $PEERTUBE_REPO
npm run upgrade-peertube
chown -R peertube:peertube $PEERTUBE_DIR
systemctl start peertube
}
function backup_local_peertube {
PEERTUBE_DOMAIN_NAME='peertube.local'
if grep -q "peertube domain" $COMPLETION_FILE; then
PEERTUBE_DOMAIN_NAME=$(get_completion_param "peertube domain")
fi
systemctl stop peertube
USE_POSTGRESQL=1
function_check backup_database_to_usb
backup_database_to_usb peertube
systemctl start peertube
peertube_path=$PEERTUBE_DIR/videos
if [ -d $peertube_path ]; then
suspend_site ${PEERTUBE_DOMAIN_NAME}
systemctl stop peertube
backup_directory_to_usb $peertube_path peertubevideos
systemctl start peertube
restart_site
fi
}
function restore_local_peertube {
PEERTUBE_DOMAIN_NAME='peertube.local'
if grep -q "peertube domain" $COMPLETION_FILE; then
PEERTUBE_DOMAIN_NAME=$(get_completion_param "peertube domain")
fi
if [ $PEERTUBE_DOMAIN_NAME ]; then
suspend_site ${PEERTUBE_DOMAIN_NAME}
systemctl stop peertube
USE_POSTGRESQL=1
restore_database peertube
temp_restore_dir=/root/temppeertubevideos
function_check restore_directory_from_usb
restore_directory_from_usb $temp_restore_dir peertubevideos
if [ -d $temp_restore_dir ]; then
if [ -d $temp_restore_dir$PEERTUBE_DIR/videos ]; then
cp -r $temp_restore_dir$PEERTUBE_DIR/videos/* $PEERTUBE_DIR/videos/
else
cp -r $temp_restore_dir/* $PEERTUBE_DIR/videos/
fi
chown -R peertube:peertube $PEERTUBE_DIR
rm -rf $temp_restore_dir
fi
systemctl start peertube
restart_site
fi
}
function backup_remote_peertube {
PEERTUBE_DOMAIN_NAME='peertube.local'
if grep -q "peertube domain" $COMPLETION_FILE; then
PEERTUBE_DOMAIN_NAME=$(get_completion_param "peertube domain")
fi
systemctl stop peertube
USE_POSTGRESQL=1
function_check backup_database_to_friend
backup_database_to_friend peertube
systemctl start peertube
temp_backup_dir=$PEERTUBE_DIR/videos
if [ -d $temp_backup_dir ]; then
systemctl stop peertube
suspend_site ${PEERTUBE_DOMAIN_NAME}
backup_directory_to_friend $temp_backup_dir peertubevideos
restart_site
systemctl start peertube
else
echo $"Peertube domain specified but not found in $temp_backup_dir"
exit 6383523
fi
}
function restore_remote_peertube {
PEERTUBE_DOMAIN_NAME='peertube.local'
if grep -q "peertube domain" $COMPLETION_FILE; then
PEERTUBE_DOMAIN_NAME=$(get_completion_param "peertube domain")
fi
suspend_site ${PEERTUBE_DOMAIN_NAME}
systemctl stop peertube
USE_POSTGRESQL=1
function_check restore_database_from_friend
restore_database_from_friend peertube
temp_restore_dir=/root/temppeertubevideos
function_check restore_directory_from_friend
restore_directory_from_friend $temp_restore_dir peertubevideos
if [ -d $temp_restore_dir ]; then
if [ -d $temp_restore_dir$PEERTUBE_DIR/videos ]; then
cp -r $temp_restore_dir$PEERTUBE_DIR/videos/* $PEERTUBE_DIR/videos/
else
cp -r $temp_restore_dir/* $PEERTUBE_DIR/videos/
fi
chown -R peertube: $PEERTUBE_DIR
rm -rf $temp_restore_dir
fi
systemctl start peertube
restart_site
}
function remove_peertube {
if [ ${#PEERTUBE_DOMAIN_NAME} -eq 0 ]; then
return
fi
systemctl stop peertube
systemctl disable peertube
rm /etc/systemd/system/peertube.service
systemctl daemon-reload
function_check remove_nodejs
remove_nodejs peertube
read_config_param "PEERTUBE_DOMAIN_NAME"
nginx_dissite $PEERTUBE_DOMAIN_NAME
remove_certs ${PEERTUBE_DOMAIN_NAME}
if [ -f /etc/nginx/sites-available/$PEERTUBE_DOMAIN_NAME ]; then
rm -f /etc/nginx/sites-available/$PEERTUBE_DOMAIN_NAME
fi
if [ -d /var/www/$PEERTUBE_DOMAIN_NAME ]; then
rm -rf /var/www/$PEERTUBE_DOMAIN_NAME
fi
remove_config_param PEERTUBE_DOMAIN_NAME
remove_config_param PEERTUBE_CODE
function_check remove_onion_service
remove_onion_service peertube ${PEERTUBE_ONION_PORT}
remove_completion_param "install_peertube"
sed -i '/peertube/d' $COMPLETION_FILE
function_check drop_database_postgresql
drop_database_postgresql peertube
2017-11-29 23:28:04 +01:00
remove_postgresql_user peertube
2017-11-29 15:23:07 +01:00
groupdel -f peertube
userdel -r peertube
if [ -d $PEERTUBE_DIR ]; then
rm -rf $PEERTUBE_DIR
fi
function_check remove_ddns_domain
remove_ddns_domain $PEERTUBE_DOMAIN_NAME
}
function peertube_setup_web {
peertube_nginx_file=/etc/nginx/sites-available/$PEERTUBE_DOMAIN_NAME
if [[ $ONION_ONLY == "no" ]]; then
echo 'server {' > $peertube_nginx_file
echo ' listen 80;' >> $peertube_nginx_file
2017-11-30 21:25:42 +01:00
echo ' listen [::]:80;' >> $peertube_nginx_file
2017-11-29 15:23:07 +01:00
echo " server_name $PEERTUBE_DOMAIN_NAME;" >> $peertube_nginx_file
echo ' rewrite ^ https://$server_name$request_uri? permanent;' >> $peertube_nginx_file
echo '}' >> $peertube_nginx_file
echo '' >> $peertube_nginx_file
echo 'server {' >> $peertube_nginx_file
2017-11-30 21:25:42 +01:00
echo ' listen 443 ssl http2;' >> $peertube_nginx_file
echo ' listen [::]:443 ssl http2;' >> $peertube_nginx_file
2017-11-29 15:23:07 +01:00
echo " server_name $PEERTUBE_DOMAIN_NAME;" >> $peertube_nginx_file
echo '' >> $peertube_nginx_file
function_check nginx_ssl
nginx_ssl $PEERTUBE_DOMAIN_NAME mobile
function_check nginx_disable_sniffing
nginx_disable_sniffing $PEERTUBE_DOMAIN_NAME
2017-11-29 21:25:01 +01:00
echo ' add_header Strict-Transport-Security max-age=15768000;' >> $peertube_nginx_file
2017-11-29 15:23:07 +01:00
echo '' >> $peertube_nginx_file
echo ' location / {' >> $peertube_nginx_file
echo " proxy_pass http://localhost:${PEERTUBE_PORT};" >> $peertube_nginx_file
echo ' proxy_set_header X-Real-IP $remote_addr;' >> $peertube_nginx_file
echo ' proxy_set_header Host $host;' >> $peertube_nginx_file
echo ' proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;' >> $peertube_nginx_file
echo '' >> $peertube_nginx_file
echo ' # For the video upload' >> $peertube_nginx_file
echo ' client_max_body_size 2G;' >> $peertube_nginx_file
echo ' }' >> $peertube_nginx_file
echo '' >> $peertube_nginx_file
echo ' location /static/webseed {' >> $peertube_nginx_file
echo " if (\$request_method = 'OPTIONS') {" >> $peertube_nginx_file
echo " add_header 'Access-Control-Allow-Origin' '*';" >> $peertube_nginx_file
echo " add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS';" >> $peertube_nginx_file
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
echo " add_header 'Access-Control-Max-Age' 1728000;" >> $peertube_nginx_file
echo " add_header 'Content-Type' 'text/plain charset=UTF-8';" >> $peertube_nginx_file
echo " add_header 'Content-Length' 0;" >> $peertube_nginx_file
echo ' return 204;' >> $peertube_nginx_file
echo ' }' >> $peertube_nginx_file
echo '' >> $peertube_nginx_file
echo " if (\$request_method = 'GET') {" >> $peertube_nginx_file
echo " add_header 'Access-Control-Allow-Origin' '*';" >> $peertube_nginx_file
echo " add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS';" >> $peertube_nginx_file
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
echo ' }' >> $peertube_nginx_file
echo '' >> $peertube_nginx_file
echo " alias $PEERTUBE_DIR/videos;" >> $peertube_nginx_file
echo ' }' >> $peertube_nginx_file
echo '' >> $peertube_nginx_file
echo ' # Websocket tracker' >> $peertube_nginx_file
echo ' location /tracker/socket {' >> $peertube_nginx_file
echo ' # Peers send a message to the tracker every 15 minutes' >> $peertube_nginx_file
echo ' # Dont close the websocket before this time' >> $peertube_nginx_file
echo ' proxy_read_timeout 1200s;' >> $peertube_nginx_file
echo ' proxy_set_header Upgrade $http_upgrade;' >> $peertube_nginx_file
echo ' proxy_set_header Connection "upgrade";' >> $peertube_nginx_file
echo ' proxy_http_version 1.1;' >> $peertube_nginx_file
echo ' proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;' >> $peertube_nginx_file
echo ' proxy_set_header Host $host;' >> $peertube_nginx_file
echo " proxy_pass http://localhost:${PEERTUBE_PORT};" >> $peertube_nginx_file
echo ' }' >> $peertube_nginx_file
echo '}' >> $peertube_nginx_file
else
echo -n '' > $peertube_nginx_file
fi
echo 'server {' >> $peertube_nginx_file
echo " listen 127.0.0.1:$PEERTUBE_ONION_PORT default_server;" >> $peertube_nginx_file
2017-11-29 21:25:01 +01:00
echo " server_name $PEERTUBE_ONION_HOSTNAME;" >> $peertube_nginx_file
2017-11-29 15:23:07 +01:00
echo '' >> $peertube_nginx_file
echo ' location / {' >> $peertube_nginx_file
echo " proxy_pass http://localhost:${PEERTUBE_PORT};" >> $peertube_nginx_file
echo ' proxy_set_header X-Real-IP $remote_addr;' >> $peertube_nginx_file
echo ' proxy_set_header Host $host;' >> $peertube_nginx_file
echo ' proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;' >> $peertube_nginx_file
echo '' >> $peertube_nginx_file
echo ' # For the video upload' >> $peertube_nginx_file
echo ' client_max_body_size 2G;' >> $peertube_nginx_file
echo ' }' >> $peertube_nginx_file
echo '' >> $peertube_nginx_file
echo ' location /static/webseed {' >> $peertube_nginx_file
echo " if (\$request_method = 'OPTIONS') {" >> $peertube_nginx_file
echo " add_header 'Access-Control-Allow-Origin' '*';" >> $peertube_nginx_file
echo " add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS';" >> $peertube_nginx_file
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
echo " add_header 'Access-Control-Max-Age' 1728000;" >> $peertube_nginx_file
echo " add_header 'Content-Type' 'text/plain charset=UTF-8';" >> $peertube_nginx_file
echo " add_header 'Content-Length' 0;" >> $peertube_nginx_file
echo ' return 204;' >> $peertube_nginx_file
echo ' }' >> $peertube_nginx_file
echo '' >> $peertube_nginx_file
echo " if (\$request_method = 'GET') {" >> $peertube_nginx_file
echo " add_header 'Access-Control-Allow-Origin' '*';" >> $peertube_nginx_file
echo " add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS';" >> $peertube_nginx_file
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
echo ' }' >> $peertube_nginx_file
echo '' >> $peertube_nginx_file
echo " alias $PEERTUBE_DIR/videos;" >> $peertube_nginx_file
echo ' }' >> $peertube_nginx_file
echo '' >> $peertube_nginx_file
echo ' # Websocket tracker' >> $peertube_nginx_file
echo ' location /tracker/socket {' >> $peertube_nginx_file
echo ' # Peers send a message to the tracker every 15 minutes' >> $peertube_nginx_file
echo ' # Dont close the websocket before this time' >> $peertube_nginx_file
echo ' proxy_read_timeout 1200s;' >> $peertube_nginx_file
echo ' proxy_set_header Upgrade $http_upgrade;' >> $peertube_nginx_file
echo ' proxy_set_header Connection "upgrade";' >> $peertube_nginx_file
echo ' proxy_http_version 1.1;' >> $peertube_nginx_file
echo ' proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;' >> $peertube_nginx_file
echo ' proxy_set_header Host $host;' >> $peertube_nginx_file
echo " proxy_pass http://localhost:${PEERTUBE_PORT};" >> $peertube_nginx_file
echo ' }' >> $peertube_nginx_file
echo '}' >> $peertube_nginx_file
# CSP currently causes an error
sed -i '/Content-Security-Policy/d' $peertube_nginx_file
2017-11-29 15:23:07 +01:00
function_check create_site_certificate
create_site_certificate $PEERTUBE_DOMAIN_NAME 'yes'
function_check nginx_ensite
nginx_ensite $PEERTUBE_DOMAIN_NAME
}
function peertube_create_config {
peertube_config_file=$PEERTUBE_DIR/config/production.yaml
echo 'listen:' > $peertube_config_file
echo " port: $PEERTUBE_PORT" >> $peertube_config_file
echo '' >> $peertube_config_file
echo '# Correspond to your reverse proxy "listen" configuration' >> $peertube_config_file
echo 'webserver:' >> $peertube_config_file
if [[ $ONION_ONLY == 'no' ]]; then
echo ' https: true' >> $peertube_config_file
2017-11-29 15:23:07 +01:00
echo " hostname: '$PEERTUBE_DOMAIN_NAME'" >> $peertube_config_file
echo ' port: 443' >> $peertube_config_file
else
echo ' https: false' >> $peertube_config_file
2017-11-29 15:23:07 +01:00
echo " hostname: '$PEERTUBE_ONION_HOSTNAME'" >> $peertube_config_file
echo ' port: 80' >> $peertube_config_file
fi
echo '' >> $peertube_config_file
echo '# Your database name will be "peertube"+database.suffix' >> $peertube_config_file
echo 'database:' >> $peertube_config_file
echo " hostname: 'localhost'" >> $peertube_config_file
echo ' port: 5432' >> $peertube_config_file
echo " suffix: ''" >> $peertube_config_file
echo " username: 'peertube'" >> $peertube_config_file
echo " password: '$PEERTUBE_ADMIN_PASSWORD'" >> $peertube_config_file
echo '' >> $peertube_config_file
echo '# From the project root directory' >> $peertube_config_file
echo 'storage:' >> $peertube_config_file
echo " certs: 'certs/'" >> $peertube_config_file
echo " videos: 'videos/'" >> $peertube_config_file
echo " logs: 'logs/'" >> $peertube_config_file
echo " previews: 'previews/'" >> $peertube_config_file
echo " thumbnails: 'thumbnails/'" >> $peertube_config_file
echo " torrents: 'torrents/'" >> $peertube_config_file
echo " cache: 'cache/'" >> $peertube_config_file
echo '' >> $peertube_config_file
echo 'cache:' >> $peertube_config_file
echo ' previews:' >> $peertube_config_file
echo ' size: 10 # Max number of previews you want to cache' >> $peertube_config_file
echo '' >> $peertube_config_file
echo 'admin:' >> $peertube_config_file
echo " email: '$MY_EMAIL_ADDRESS'" >> $peertube_config_file
echo '' >> $peertube_config_file
echo 'signup:' >> $peertube_config_file
2017-11-29 22:14:20 +01:00
echo ' enabled: true' >> $peertube_config_file
echo ' limit: 5 # When the limit is reached, registrations are disabled. -1 == unlimited' >> $peertube_config_file
2017-11-29 15:23:07 +01:00
echo '' >> $peertube_config_file
echo 'user:' >> $peertube_config_file
echo ' # Default value of maximum video BYTES the user can upload (does not take into account transcoded files).' >> $peertube_config_file
echo ' # -1 == unlimited' >> $peertube_config_file
echo ' video_quota: -1' >> $peertube_config_file
echo '' >> $peertube_config_file
echo '# If enabled, the video will be transcoded to mp4 (x264) with "faststart" flag' >> $peertube_config_file
echo '# Uses a lot of CPU!' >> $peertube_config_file
echo 'transcoding:' >> $peertube_config_file
echo ' enabled: false' >> $peertube_config_file
echo ' threads: 2' >> $peertube_config_file
echo ' resolutions: # Only created if the original video has a higher resolution' >> $peertube_config_file
echo ' 240p: true' >> $peertube_config_file
echo ' 360p: true' >> $peertube_config_file
echo ' 480p: true' >> $peertube_config_file
echo ' 720p: true' >> $peertube_config_file
echo ' 1080p: true' >> $peertube_config_file
}
function install_peertube {
if [ ! $ONION_ONLY ]; then
ONION_ONLY='no'
fi
if [ ! $PEERTUBE_DOMAIN_NAME ]; then
echo $'The peertube domain name was not specified'
exit 783523
fi
apt-get -yq install ffmpeg
function_check install_postgresql
install_postgresql
if [ ! -d /var/www/$PEERTUBE_DOMAIN_NAME/htdocs ]; then
mkdir -p /var/www/$PEERTUBE_DOMAIN_NAME/htdocs
fi
if [ -d $PEERTUBE_DIR ]; then
rm -rf $PEERTUBE_DIR
fi
groupadd peertube
useradd -c "PeerTube system account" -d $PEERTUBE_DIR -m -r -g peertube peertube
peertube_create_database
function_check install_nodejs
install_nodejs peertube
if [ -d /repos/peertube ]; then
mkdir -p $PEERTUBE_DIR
cp -r -p /repos/peertube/. $PEERTUBE_DIR
cd $PEERTUBE_DIR
git pull
else
function_check git_clone
git_clone $PEERTUBE_REPO $PEERTUBE_DIR
fi
cd $PEERTUBE_DIR
git checkout $PEERTUBE_COMMIT -b $PEERTUBE_COMMIT
set_completion_param "peertube commit" "$PEERTUBE_COMMIT"
npm install -g yarn
if [ ! "$?" = "0" ]; then
echo $'Failed to install yarn'
exit 79353234
fi
2017-11-29 21:16:29 +01:00
yarn add -D webpack --network-concurrency 1
2017-11-29 15:23:07 +01:00
yarn install
if [ ! "$?" = "0" ]; then
echo $'Failed to run yarn install'
exit 63754235
fi
2017-11-29 23:33:21 +01:00
npm install
if [ ! "$?" = "0" ]; then
echo $'Failed to install peertube'
exit 7835243
fi
2017-11-29 15:23:07 +01:00
npm run build
if [ ! "$?" = "0" ]; then
echo $'Failed to build peertube'
exit 5293593
fi
PEERTUBE_ONION_HOSTNAME=$(add_onion_service peertube 80 ${PEERTUBE_ONION_PORT})
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
echo 'After=network.target' >> /etc/systemd/system/peertube.service
echo '' >> /etc/systemd/system/peertube.service
echo '[Service]' >> /etc/systemd/system/peertube.service
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=/usr/local/bin/npm start" >> /etc/systemd/system/peertube.service
echo "ExecStop=/usr/local/bin/npm 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 PORT=${PEERTUBE_PORT}" >> /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
peertube_create_config
chown -R peertube:peertube $PEERTUBE_DIR
peertube_setup_web
${PROJECT_NAME}-pass -u $MY_USERNAME -a peertube -p "$PEERTUBE_ADMIN_PASSWORD"
function_check add_ddns_domain
add_ddns_domain $PEERTUBE_DOMAIN_NAME
systemctl enable peertube
systemctl daemon-reload
systemctl start peertube
systemctl restart nginx
set_completion_param "peertube domain" "$PEERTUBE_DOMAIN_NAME"
APP_INSTALLED=1
}
# NOTE: deliberately no exit 0