From 2b41d29837d83af54cff0291bd9c35b106122697 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 13 Jan 2021 20:59:06 +0100 Subject: [PATCH] Open PeerTube Live port --- conf/message | 2 ++ conf/message_remove | 4 +++- conf/production.yaml | 2 +- manifest.json | 2 +- scripts/install | 12 +++++++++++- scripts/remove | 10 +++++++++- scripts/restore | 11 ++++++++++- scripts/upgrade | 14 +++++++++++++- 8 files changed, 50 insertions(+), 7 deletions(-) diff --git a/conf/message b/conf/message index 33e3a26..dc34d8d 100644 --- a/conf/message +++ b/conf/message @@ -5,4 +5,6 @@ Please open your __APP__ domain: https://__DOMAIN____PATH_URL__ The admin username is: root The admin password is: __ADMIN_PASS__ +To make PeerTube Live available, you also need to make the TCP port __RTMP_PORT__ available from internet (For example, opening the port on your ISP box if it's not automatically done). + If you are facing any problem or want to improve this app, please open a new issue here: https://github.com/YunoHost-Apps/peertube_ynh \ No newline at end of file diff --git a/conf/message_remove b/conf/message_remove index 367704b..8f8c84e 100644 --- a/conf/message_remove +++ b/conf/message_remove @@ -1,6 +1,8 @@ __APP__ was successfully removed :) -__APP__ was successfully removed. The domain https://__DOMAIN____PATH_URL__ is free for other apps to be installed on it. +The domain https://__DOMAIN____PATH_URL__ is free for other apps to be installed on it. + +You should close the PeerTube Live TCP port __RTMP_PORT__ available from internet (For example, closing the port on your ISP box if it's not automatically done). But a futher action is required from your side to completely remove the __APP__ data folder. If you have backup and plan to restore this app in the future DON'T RUN THIS COMMAND. And if you are going to migrate to othe server you will have to move __DATADIR__ to your new server. diff --git a/conf/production.yaml b/conf/production.yaml index ee1c9bd..2b79ab4 100644 --- a/conf/production.yaml +++ b/conf/production.yaml @@ -258,7 +258,7 @@ transcoding: enabled: false live: - enabled: false + enabled: true # Limit lives duration # Set null to disable duration limit diff --git a/manifest.json b/manifest.json index a903a67..66323d3 100644 --- a/manifest.json +++ b/manifest.json @@ -21,7 +21,7 @@ "requirements": { "yunohost": ">= 3.8.1" }, - "multi_instance": true, + "multi_instance": false, "services": [ "nginx" ], diff --git a/scripts/install b/scripts/install index e708c96..d417605 100644 --- a/scripts/install +++ b/scripts/install @@ -68,6 +68,15 @@ ynh_script_progression --message="Finding an available port..." port=$(ynh_find_port --port=9000) ynh_app_setting_set --app=$app --key=port --value=$port +# PeerTube Live port +rtmp_port=1935 +ynh_port_available --port=$rtmp_port || ynh_die "Port $rtmp_port is needs to be available for this app" +ynh_app_setting_set --app=$app --key=rtmp_port --value=$rtmp_port + +# Open the port +ynh_script_progression --message="Configuring firewall..." +ynh_exec_warn_less yunohost firewall allow TCP $rtmp_port + #================================================= # INSTALL DEPENDENCIES #================================================= @@ -214,7 +223,7 @@ ynh_use_logrotate --logfile="$datadir/logs/peertube.log" #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add $app --description "$app daemon for Peertube" --log "$datadir/logs/peertube.log" +yunohost service add $app --description "$app daemon for Peertube" --log "$datadir/logs/peertube.log" --needs_exposed_ports $rtmp_port #================================================= # START SYSTEMD SERVICE @@ -261,6 +270,7 @@ ynh_replace_string --match_string="__APP__" --replace_string="$app" --targ ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="../conf/message" ynh_replace_string --match_string="__PATH_URL__" --replace_string="$path_url" --target_file="../conf/message" ynh_replace_string --match_string="__ADMIN_PASS__" --replace_string="$admin_pass" --target_file="../conf/message" +ynh_replace_string --match_string="__RTMP_PORT__" --replace_string="$rtmp_port" --target_file="../conf/message" ynh_send_readme_to_admin --app_message="../conf/message" --recipients=$admin_email --type='install' diff --git a/scripts/remove b/scripts/remove index f99235d..a8a15b4 100644 --- a/scripts/remove +++ b/scripts/remove @@ -19,6 +19,7 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) port=$(ynh_app_setting_get --app=$app --key=port) +rtmp_port=$(ynh_app_setting_get --app=$app --key=rtmp_port) db_name=$(ynh_app_setting_get --app=$app --key=psql_db) db_user=$app final_path=$(ynh_app_setting_get --app=$app --key=final_path) @@ -34,7 +35,7 @@ datadir=$(ynh_app_setting_get --app=$app --key=datadir) # Remove the service from the list of services known by Yunohost (added from `yunohost service add`) if ynh_exec_warn_less yunohost service status $app >/dev/null then - ynh_script_progression --message="Removing $app service..." + ynh_script_progression --message="Removing $app service integration..." yunohost service remove $app fi @@ -98,6 +99,12 @@ then ynh_exec_warn_less yunohost firewall disallow TCP $port fi +if yunohost firewall list | grep -q "\- $rtmp_port$" +then + ynh_script_progression --message="Closing port $rtmp_port..." + ynh_exec_warn_less yunohost firewall disallow TCP $rtmp_port +fi + #================================================= # GENERIC FINALIZATION #================================================= @@ -117,6 +124,7 @@ ynh_replace_string --match_string="__APP__" --replace_string="$app" --targ ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="../conf/message_remove" ynh_replace_string --match_string="__PATH_URL__" --replace_string="$path_url" --target_file="../conf/message_remove" ynh_replace_string --match_string="__DATADIR__" --replace_string="$datadir" --target_file="../conf/message_remove" +ynh_replace_string --match_string="__RTMP_PORT__" --replace_string="$rtmp_port" --target_file="../conf/message" ynh_send_readme_to_admin --app_message="../conf/message_remove" --recipients=$admin_email --type='remove' diff --git a/scripts/restore b/scripts/restore index a0a1a34..adc0f06 100644 --- a/scripts/restore +++ b/scripts/restore @@ -31,6 +31,7 @@ domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) port=$(ynh_app_setting_get --app=$app --key=port) +rtmp_port=$(ynh_app_setting_get --app=$app --key=rtmp_port) db_name=$(ynh_app_setting_get --app=$app --key=psql_db) db_user=$app db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) @@ -123,6 +124,14 @@ ynh_psql_test_if_first_run ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name +#================================================= +# OPEN A PORT +#================================================= +ynh_script_progression --message="Configuring firewall..." + +# Open the port +ynh_exec_warn_less yunohost firewall allow TCP $rtmp_port + #================================================= # RESTORE SYSTEMD #================================================= @@ -136,7 +145,7 @@ systemctl enable $app.service --quiet #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add $app --description "$app daemon for Peertube" --log "$datadir/logs/peertube.log" +yunohost service add $app --description "$app daemon for Peertube" --log "$datadir/logs/peertube.log" --needs_exposed_ports $rtmp_port #================================================= # START SYSTEMD SERVICE diff --git a/scripts/upgrade b/scripts/upgrade index 878c18b..f4521d6 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -22,6 +22,7 @@ is_public=$(ynh_app_setting_get --app=$app --key=is_public) admin_email=$(ynh_app_setting_get --app=$app --key=admin_email) final_path=$(ynh_app_setting_get --app=$app --key=final_path) port=$(ynh_app_setting_get --app=$app --key=port) +rtmp_port=$(ynh_app_setting_get --app=$app --key=rtmp_port) db_name=$(ynh_app_setting_get --app=$app --key=psql_db) db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) datadir=$(ynh_app_setting_get --app=$app --key=datadir) @@ -68,6 +69,17 @@ ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS pg_trgm;" --datab ynh_secure_remove --file="/etc/apt/sources.list.d/jessie-backports.list" ynh_secure_remove --file="/etc/apt/sources.list.d/yarn.list" +if [ -z "$rtmp_port" ]; +then + rtmp_port=1935 + ynh_port_available --port=$rtmp_port || ynh_die "Port $rtmp_port is needs to be available for this app" + ynh_app_setting_set --app=$app --key=rtmp_port --value=$rtmp_port + + # Open the port + ynh_script_progression --message="Configuring firewall..." + ynh_exec_warn_less yunohost firewall allow TCP $rtmp_port +fi + #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= @@ -259,7 +271,7 @@ ynh_use_logrotate --non-append #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add $app --description "$app daemon for Peertube" --log "$datadir/logs/peertube.log" +yunohost service add $app --description "$app daemon for Peertube" --log "$datadir/logs/peertube.log" --needs_exposed_ports $rtmp_port #================================================= # START SYSTEMD SERVICE