diff --git a/README.md b/README.md index f3aa503..348858f 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ If installing on an ovh virtual machine or having `gyp ERR! configure error` ple 1. Install nodejs ``` -$ curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash - +$ curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash - $ sudo apt-get install -y nodejs ``` diff --git a/README_fr.md b/README_fr.md new file mode 100644 index 0000000..ad91989 --- /dev/null +++ b/README_fr.md @@ -0,0 +1,84 @@ +# PeerTube pour YunoHost + +[![Niveau d'intégration](https://dash.yunohost.org/integration/peertube.svg)](https://dash.yunohost.org/appci/app/peertube) ![](https://ci-apps.yunohost.org/ci/badges/peertube.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/peertube.maintain.svg) +[![Installer PeerTube pour YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=peertube) + +*[Read this readme in english.](./README.md)* + +> *Ce package vous permet d'installer PeerTube rapidement et simplement sur un serveur YunoHost. +Si vous n'avez pas YunoHost, consultez [le guide](https://yunohost.org/#/install) pour apprendre comment l'installer.* + +## Vue d'ensemble + +### Qu'est-ce que PeerTube ? +PeerTube est une plateforme de streaming vidéo fédérée (ActivityPub) utilisant P2P (BitTorrent) directement dans le navigateur Web, en utilisant WebTorrent . +### Why PeerTube? + +Nous ne pouvons pas créer d'alternatives de streaming vidéo FOSS à YouTube, Dailymotion, Vimeo... avec un logiciel centralisé. Une organisation seule ne peut pas avoir assez d'argent pour payer la bande passante et le stockage vidéo de son serveur. +Nous avons donc besoin d'un réseau décentralisé de serveurs « semant » des vidéos (comme [Hubzilla YunoHost](https://github.com/YunoHost-Apps/hubzilla_ynh), [Friendica YunoHost](https://github.com/YunoHost-Apps/friendica_ynh), [Mastodon YunoHost](https://github.com/YunoHost-Apps/mastodon_ynh)), [Diaspora](https://github.com/diaspora/diaspora) ([Diaspora YunoHost](https://github.com/YunoHost-Apps/diaspora_ynh)),[Funkwhale](https://funkwhale.audio) ([Funkwhale YunoHost](https://github.com/YunoHost-Apps/funkwhale_ynh)). +Mais ce n'est pas suffisant car une vidéo pourrait devenir célèbre et surcharger le serveur. C'est la raison pour laquelle nous devons utiliser un protocole P2P pour limiter la charge du serveur. Grâce à [WebTorrent](https://github.com/feross/webtorrent), nous pouvons faire du P2P (donc BitTorrent) dans le navigateur Web, dès aujourd'hui. + +### Pourquoi est-ce cool ? +Les serveurs sont gérés indépendamment par différentes personnes et organisations. Ils peuvent appliquer des politiques de modération extrêmement différentes, afin que vous puissiez en trouver ou en créer une qui correspond parfaitement à vos goûts. + +En regardant une vidéo, vous aidez l'hébergeur à la diffuser en devenant vous-même un diffuseur de la vidéo. Chaque instance n'a pas besoin de beaucoup d'argent pour diffuser les vidéos de ses utilisateurs. + +**Version incluse :** 3.0.1 + +## Points importants à lire avant l'installation + +1. Nécessite un **domaine dédié** comme **peertube.domain.tld**. +1. **Pas de support LDAP** (bloqué jusqu'à ce que le noyau PeerTube en amont l'implémente) +1. Le nom d'utilisateur de l'administrateur est: **root**. +1. **Le mot de passe administrateur** sera envoyé à l'adresse email indiquée au moment de l'installation. +1. L'URL ne peut pas être modifiée une fois sélectionnée. Choisissez judicieusement le domaine. +1. Vous avez besoin de plus de **1 Go** de RAM. Si vous ne l'avez pas, veuillez créer une **mémoire swap**. + + + $ dd if=/dev/zero of=/swapfile bs=1024 count=1048576 + $ mkswap /swapfile + $ swapon /swapfile + $ echo "/swapfile swap swap defaults 0 0" >> /etc/fstab + +1. Cette application est **multi-instance** (vous pouvez avoir plus d'une instance PeerTube en cours d'exécution sur un serveur YunoHost) +1. **Si vous êtes hébergé sur une machine virtuelle OVH ou rencontrez `gyp ERR! configure error`, veuillez passer à [ovh_fix](https://github.com/YunoHost-Apps/peertube_ynh/tree/ovh_fix)** + +## Captures d'écran + +![](https://framablog.org/wp-content/uploads/2018/03/Framatube-au-lancement.png) + +## Démo + + * [Démo](http://peertube.cpy.re) + +## Documentation + + * Documentation officielle : https://docs.joinpeertube.org/ + * Documentation YunoHost : https://yunohost.org/#/app_peertube_fr + +## Caractéristiques spécifiques YunoHost + +#### Architectures supportées + +* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/peertube%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/peertube/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/peertube%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/peertube/) + +## Liens + + * Signaler un bug : https://github.com/YunoHost-Apps/peertube_ynh/issues + * Site de l'application : https://joinpeertube.org/fr/ + * Dépôt de l'application principale : https://github.com/Chocobozzz/PeerTube/ + * Site web YunoHost : https://yunohost.org/ + +--- + +## Developer info + +Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/peertube_ynh/tree/testing). + +To try the testing branch, please proceed like that. +``` +sudo yunohost app install https://github.com/YunoHost-Apps/peertube_ynh/tree/testing --debug +or +sudo yunohost app upgrade peertube -u https://github.com/YunoHost-Apps/peertube_ynh/tree/testing --debug +``` diff --git a/check_process b/check_process index f81f2e0..efd30bf 100644 --- a/check_process +++ b/check_process @@ -18,20 +18,19 @@ setup_public=1 upgrade=1 # 2.1.0 - upgrade=1 from_commit=d049b71061d12ffab92bbf106af200e7d8a69572 + # upgrade=1 from_commit=d049b71061d12ffab92bbf106af200e7d8a69572 # 2.1.1~ynh1 - upgrade=1 from_commit=63f076db215f8f438dbdcd2966c12d9ee7976121 + # upgrade=1 from_commit=63f076db215f8f438dbdcd2966c12d9ee7976121 # 2.2.0~ynh1 - upgrade=1 from_commit=2b24ab443dc95fc78654e8232351933491cf04b4 + # upgrade=1 from_commit=2b24ab443dc95fc78654e8232351933491cf04b4 + # 2.3.0~ynh1 + upgrade=1 from_commit=141e5a370e552760b83066fbfe044ca3e5283a72 + # 2.4.0~ynh1 + upgrade=1 from_commit=10d79175a8a45137d271931cbd6d14e927400729 backup_restore=1 - multi_instance=1 - # This test is no longer necessary since the version 2.7 (PR: https://github.com/YunoHost/yunohost/pull/304), you can still do it if your app could be installed with this version. - # incorrect_path=1 + multi_instance=0 port_already_use=0 change_url=0 -;;; Levels - # If the level 5 (Package linter) is forced to 1. Please add justifications here. - Level 5=auto ;;; Options Email=anmol@datamol.org;yalh@yahoo.com Notification=yes @@ -42,3 +41,8 @@ Notification=yes name=2.1.1~ynh1 ; commit=2b24ab443dc95fc78654e8232351933491cf04b4 name=2.2.0~ynh1 + ; commit=141e5a370e552760b83066fbfe044ca3e5283a72 + name=2.3.0~ynh1 + ; commit=10d79175a8a45137d271931cbd6d14e927400729 + name=2.4.0~ynh1 + \ No newline at end of file diff --git a/conf/app.src b/conf/app.src index ae11e2d..02cbf3c 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,6 +1,7 @@ -SOURCE_URL=https://github.com/Chocobozzz/PeerTube/releases/download/v2.3.0/peertube-v2.3.0.tar.xz -SOURCE_SUM=ebab03ac28b9a22a3ba5868964678e8a30815479a83733c959c79587dbeed787 +SOURCE_URL=https://github.com/Chocobozzz/PeerTube/releases/download/v3.0.1/peertube-v3.0.1.tar.xz +SOURCE_SUM=85d2a99d3bc30eeafc9201bb4f760e37c0132500ce03909669157e66f813f8e9 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.xz SOURCE_IN_SUBDIR=true SOURCE_FILENAME= +SOURCE_EXTRACT=true diff --git a/conf/message b/conf/message_install similarity index 60% rename from conf/message rename to conf/message_install index 33e3a26..dc34d8d 100644 --- a/conf/message +++ b/conf/message_install @@ -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 d0cdb68..8f8c84e 100644 --- a/conf/message_remove +++ b/conf/message_remove @@ -1,14 +1,16 @@ __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 /home/yunohost.app/__APP__ to your new server. +And if you are going to migrate to othe server you will have to move __DATADIR__ to your new server. -You need to run this command to remove the data (warning all your videos will be removed) : +You need to run this command to remove the data (warning all your videos will be removed): -rm -R /home/yunohost.app/__APP__ -f +rm -R __DATADIR__ -f If you 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/nginx.conf b/conf/nginx.conf index 719ebe8..f0306bb 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -26,7 +26,7 @@ location ~ ^/static/(thumbnails|avatars)/ { # Cache 2 hours more_set_headers "Cache-Control : public, max-age=7200"; - root /home/yunohost.app/__NAME__/storage; + root __DATADIR__; rewrite ^/static/(thumbnails|avatars)/(.*)$ /$1/$2 break; try_files $uri /; @@ -97,7 +97,7 @@ location ~ ^/static/(webseed|redundancy|streaming-playlists)/ { access_log off; } - root /home/yunohost.app/__NAME__/storage; + root __DATADIR__; rewrite ^/static/webseed/(.*)$ /videos/$1 break; rewrite ^/static/redundancy/(.*)$ /redundancy/$1 break; diff --git a/conf/production.yaml b/conf/production.yaml index 5dab156..2b79ab4 100644 --- a/conf/production.yaml +++ b/conf/production.yaml @@ -2,7 +2,7 @@ listen: hostname: 'localhost' port: __PORT__ -# Correspond to your reverse proxy server_name/listen configuration +# Correspond to your reverse proxy server_name/listen configuration (i.e., your public PeerTube instance URL) webserver: https: true hostname: '__DOMAIN__' @@ -36,6 +36,7 @@ trust_proxy: database: hostname: 'localhost' port: 5432 + ssl: false suffix: '___DB_NAME__' username: '__DB_NAME__' password: '__DB_PWD__' @@ -53,6 +54,10 @@ redis: # SMTP server to send emails smtp: + # smtp or sendmail + transport: smtp + # Path to sendmail command. Required if you use sendmail transport + sendmail: null hostname: 'localhost' port: 25 # If you use StartTLS: 587 username: null @@ -70,18 +75,23 @@ email: # From the project root directory storage: - tmp: '/home/yunohost.app/__APP__/storage/tmp/' # Use to download data (imports etc), store uploaded files before processing... - avatars: '/home/yunohost.app/__APP__/storage/avatars/' - videos: '/home/yunohost.app/__APP__/storage/videos/' - streaming_playlists: '/home/yunohost.app/__APP__/storage/streaming-playlists/' - redundancy: '/home/yunohost.app/__APP__/storage/videos/' - logs: '/home/yunohost.app/__APP__/storage/logs/' - previews: '/home/yunohost.app/__APP__/storage/previews/' - thumbnails: '/home/yunohost.app/__APP__/storage/thumbnails/' - torrents: '/home/yunohost.app/__APP__/storage/torrents/' - captions: '/home/yunohost.app/__APP__/storage/captions/' - cache: '/home/yunohost.app/__APP__/storage/cache/' - plugins: '/home/yunohost.app/__APP__/storage/plugins/' + tmp: '__DATADIR__/tmp/' # Use to download data (imports etc), store uploaded files before processing... + avatars: '__DATADIR__/avatars/' + videos: '__DATADIR__/videos/' + streaming_playlists: '__DATADIR__/streaming-playlists/' + redundancy: '__DATADIR__/redundancy/' + logs: '__DATADIR__/logs/' + previews: '__DATADIR__/previews/' + thumbnails: '__DATADIR__/thumbnails/' + torrents: '__DATADIR__/torrents/' + captions: '__DATADIR__/captions/' + cache: '__DATADIR__/cache/' + plugins: '__DATADIR__/plugins/' + # Overridable client files : logo.svg, favicon.png and icons/*.png (PWA) in client/dist/assets/images + # Could contain for example assets/images/favicon.png + # If the file exists, peertube will serve it + # If not, peertube will fallback to the default fil + client_overrides: '__DATADIR__/client-overrides/' log: level: 'info' # debug/info/warning/error @@ -157,7 +167,7 @@ views: # -1 means no cleanup # Other values could be '6 months' or '30 days' etc (PeerTube will periodically delete old entries from database) remote: - max_age: -1 + max_age: '30 days' plugins: # The website PeerTube will ask for available PeerTube plugins and themes @@ -169,7 +179,7 @@ plugins: federation: videos: - federate_unlisted: true + federate_unlisted: false ############################################################################### @@ -218,7 +228,7 @@ user: # Please, do not disable transcoding since many uploaded videos will not work transcoding: enabled: true - # Allow your users to upload .mkv, .mov, .avi, .flv videos + # Allow your users to upload .mkv, .mov, .avi, .wmv, .flv, .f4v, .3g2, .3gp, .mts, m2ts, .mxf, .nut videos allow_additional_extensions: true # If a user uploads an audio file, PeerTube will create a video by merging the preview file and the audio file allow_audio_files: true @@ -247,11 +257,53 @@ transcoding: hls: enabled: false +live: + enabled: true + + # Limit lives duration + # Set null to disable duration limit + max_duration: -1 # For example: '5 hours' + + # Limit max number of live videos created on your instance + # -1 == unlimited + max_instance_lives: 20 + + # Limit max number of live videos created by a user on your instance + # -1 == unlimited + max_user_lives: 3 + + # Allow your users to save a replay of their live + # PeerTube will transcode segments in a video file + # If the user daily/total quota is reached, PeerTube will stop the live + # /!\ transcoding.enabled (and not live.transcoding.enabled) has to be true to create a replay + allow_replay: true + + # Your firewall should accept traffic from this port in TCP if you enable live + rtmp: + port: 1935 + + # Allow to transcode the live streaming in multiple live resolutions + transcoding: + enabled: true + threads: 2 + + resolutions: + 240p: false + 360p: false + 480p: false + 720p: false + 1080p: false + 2160p: false + import: # Add ability for your users to import remote videos (from YouTube, torrent...) videos: http: # Classic HTTP or all sites supported by youtube-dl https://rg3.github.io/youtube-dl/supportedsites.html enabled: false + + # IPv6 is very strongly rate-limited on most sites supported by youtube-dl + force_ipv4: false + # You can use an HTTP/HTTPS/SOCKS proxy with youtube-dl proxy: enabled: false @@ -277,16 +329,16 @@ instance: moderation_information: '' # Supports markdown # Why did you create this instance? - creation_reason: '' + creation_reason: '' # Supports Markdown # Who is behind the instance? A single person? A non profit? - administrator: '' + administrator: '' # Supports Markdown # How long do you plan to maintain this instance? - maintenance_lifetime: '' + maintenance_lifetime: '' # Supports Markdown # How will you pay the PeerTube instance server? With your own funds? With users donations? Advertising? - business_model: '' + business_model: '' # Supports Markdown # If you want to explain on what type of hardware your PeerTube instance runs # Example: "2 vCore, 2GB RAM..." diff --git a/conf/systemd.service b/conf/systemd.service index 5ad4d90..ee30548 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -1,5 +1,5 @@ [Unit] -Description=__APP__ daemon +Description=PeerTube: video streaming platform using P2P After=network.target postgresql.service redis-server.service [Service] diff --git a/issue_template.md b/issue_template.md index 08aaad7..b695583 100644 --- a/issue_template.md +++ b/issue_template.md @@ -7,8 +7,8 @@ about: Create a report to help us debug, it would be nice to fill the template a **How to post a meaningful bug report** 1. *Read this whole template first.* 2. *Determine if you are on the right place:* - - *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change url...), you are on the right place!* - - *Otherwise, the issue may be due to peertube itself. Refer to its documentation or repository for help.* + - *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change_url...), you are on the right place!* + - *Otherwise, the issue may be due to PeerTube itself. Refer to its documentation or repository for help.* - *If you have a doubt, post here, we will figure it out together.* 3. *Delete the italic comments as you write over them below, and remove this guide.* --- @@ -34,8 +34,8 @@ about: Create a report to help us debug, it would be nice to fill the template a - *If you used the webadmin, please perform the equivalent command from the CLI first.* - *If the error occurs in your browser, explain what you did:* 1. *Go to '...'* - 2. *Click on '....'* - 3. *Scroll down to '....'* + 2. *Click on '...'* + 3. *Scroll down to '...'* 4. *See error* **Expected behavior** diff --git a/manifest.json b/manifest.json index 894a693..66323d3 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Video streaming platform using P2P directly in the web browser, connected to a federated network", "fr": "Plateforme de diffusion vidéo par P2P directement dans le navigateur, et connectée à un réseau fédéralisé" }, - "version": "2.3.0~ynh1", + "version": "3.0.1~ynh1", "url": "https://github.com/Chocobozzz/PeerTube", "license": "AGPL-3.0-only", "maintainer": [ @@ -21,7 +21,7 @@ "requirements": { "yunohost": ">= 3.8.1" }, - "multi_instance": true, + "multi_instance": false, "services": [ "nginx" ], @@ -31,14 +31,17 @@ "name": "domain", "type": "domain", "ask": { - "en": "Choose a domain name for PeerTube" + "en": "Choose a domain name for PeerTube", + "fr": "Choisissez un nom de domaine pour PeerTube" }, "example": "example.com" }, { "name": "email", + "type": "string", "ask": { - "en": "Choose an admin email (can be changed after installation)" + "en": "Choose an admin email (can be changed after installation)", + "fr": "Choisissez une adresse e-mail d'administrateur (peut être modifiée après l'installation)" }, "example": "johndoe@example.com" }, @@ -46,7 +49,8 @@ "name": "is_public", "type": "boolean", "ask": { - "en": "Is it a public application?" + "en": "Is it a public application?", + "fr": "Est-ce une application publique ?" }, "default": true } diff --git a/scripts/backup b/scripts/backup index 65a1d11..7837123 100644 --- a/scripts/backup +++ b/scripts/backup @@ -30,6 +30,7 @@ app=$YNH_APP_INSTANCE_NAME final_path=$(ynh_app_setting_get --app=$app --key=final_path) domain=$(ynh_app_setting_get --app=$app --key=domain) db_name=$(ynh_app_setting_get --app=$app --key=psql_db) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= # DECLARE DATA AND CONF FILES TO BACKUP @@ -69,6 +70,13 @@ ynh_print_info --message="Backing up the PostgreSQL database..." ynh_psql_dump_db --database="$db_name" > db.sql +#================================================= +# BACKUP THE DATA DIRECTORY +#================================================= +ynh_print_info --message="Backing up data directory..." + +ynh_backup --src_path="$datadir" --is_big + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/install b/scripts/install index 601410a..280f09b 100644 --- a/scripts/install +++ b/scripts/install @@ -32,6 +32,9 @@ is_public=$YNH_APP_ARG_IS_PUBLIC app=$YNH_APP_INSTANCE_NAME +# Define app's data directory +datadir="/home/yunohost.app/${app}/storage" + #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= @@ -52,18 +55,28 @@ ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=admin_email --value=$admin_email ynh_app_setting_set --app=$app --key=admin_pass --value=$admin_pass ynh_app_setting_set --app=$app --key=is_public --value=$is_public +ynh_app_setting_set --app=$app --key=datadir --value=$datadir #================================================= # STANDARD MODIFICATIONS #================================================= # FIND AND OPEN A PORT #================================================= -ynh_script_progression --message="Configuring firewall..." +ynh_script_progression --message="Finding an available port..." # Find 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 #================================================= @@ -113,10 +126,10 @@ ynh_setup_source --dest_dir="$final_path" #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Configuring nginx web server..." +ynh_script_progression --message="Configuring NGINX web server..." # Create a dedicated nginx config -ynh_add_nginx_config +ynh_add_nginx_config "datadir" #================================================= # CREATE DEDICATED USER @@ -133,9 +146,6 @@ ynh_system_user_create --username=$app --home_dir=$final_path #================================================= ynh_script_progression --message="Creating the data directory..." -# Define app's data directory -datadir="/home/yunohost.app/${app}/storage" - # Create app folders mkdir -p "$datadir" @@ -155,6 +165,7 @@ ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_fil ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$config" ynh_replace_string --match_string="__EMAIL__" --replace_string="$admin_email" --target_file="$config" ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$config" +ynh_replace_string --match_string="__DATADIR__" --replace_string="$datadir" --target_file="$config" #Create the admin settings file local_config="$final_path/config/local-production.json" @@ -172,7 +183,7 @@ ynh_store_file_checksum --file="$local_config" #================================================= # BUILD YARN DEPENDENCIES #================================================= -ynh_script_progression --message="Building yarn dependencies..." +ynh_script_progression --message="Building Yarn dependencies..." chown -R "$app":"$app" $final_path @@ -205,14 +216,14 @@ chown -R $app:$app $final_path ynh_script_progression --message="Configuring log rotation..." # Use logrotate to manage application logfile(s) -ynh_use_logrotate --logfile="/home/yunohost.app/${app}/storage/logs/peertube.log" +ynh_use_logrotate --logfile="$datadir/logs/peertube.log" #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add $app --description "$app daemon for Peertube" --log "/home/yunohost.app/${app}/storage/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 @@ -237,7 +248,7 @@ fi #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." +ynh_script_progression --message="Reloading NGINX web server..." ynh_systemd_action --service_name=nginx --action=reload @@ -255,12 +266,13 @@ popd #================================================= ynh_script_progression --message="Sending a readme for the admin..." -ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../conf/message" -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="__APP__" --replace_string="$app" --target_file="../conf/message_install" +ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="../conf/message_install" +ynh_replace_string --match_string="__PATH_URL__" --replace_string="$path_url" --target_file="../conf/message_install" +ynh_replace_string --match_string="__ADMIN_PASS__" --replace_string="$admin_pass" --target_file="../conf/message_install" +ynh_replace_string --match_string="__RTMP_PORT__" --replace_string="$rtmp_port" --target_file="../conf/message_install" -ynh_send_readme_to_admin --app_message="../conf/message" --recipients=$admin_email --type='install' +ynh_send_readme_to_admin --app_message="../conf/message_install" --recipients=$admin_email --type='install' #================================================= # END OF SCRIPT diff --git a/scripts/remove b/scripts/remove index 2d5b9d5..a8a15b4 100644 --- a/scripts/remove +++ b/scripts/remove @@ -19,10 +19,12 @@ 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) admin_email=$(ynh_app_setting_get --app=$app --key=admin_email) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= # STANDARD REMOVE @@ -33,7 +35,7 @@ admin_email=$(ynh_app_setting_get --app=$app --key=admin_email) # 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 @@ -60,6 +62,7 @@ ynh_script_progression --message="Removing dependencies..." # Remove metapackage and its dependencies ynh_remove_app_dependencies + ynh_remove_nodejs #================================================= @@ -73,7 +76,7 @@ ynh_secure_remove --file="$final_path" #================================================= # REMOVE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Removing nginx web server configuration..." +ynh_script_progression --message="Removing NGINX web server configuration..." # Remove the dedicated nginx config ynh_remove_nginx_config @@ -96,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 #================================================= @@ -114,6 +123,8 @@ ynh_script_progression --message="Sending a readme for the admin..." ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../conf/message_remove" 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 cf78b19..adc0f06 100644 --- a/scripts/restore +++ b/scripts/restore @@ -31,9 +31,11 @@ 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) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= # CHECK IF THE APP CAN BE RESTORED @@ -50,7 +52,7 @@ test ! -d $final_path \ #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Restoring the nginx configuration..." +ynh_script_progression --message="Restoring the NGINX configuration..." ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" @@ -80,18 +82,14 @@ chown -R $app:$app $final_path #================================================= # SPECIFIC RESTORATION #================================================= -# CREATE THE DATA DIRECTORY +# RESTORE THE DATA DIRECTORY #================================================= -ynh_script_progression --message="Creating the data directory..." +ynh_script_progression --message="Restoring data directory..." -# Define app's data directory -datadir="/home/yunohost.app/${app}/storage" +# Use --not_mandatory for the data directory, because if the backup has been made with BACKUP_CORE_ONLY, there's no data into the backup. +ynh_restore_file --origin_path="$datadir" --not_mandatory -if [ ! -d "$datadir" ] -then - # Create app folders - mkdir -p "$datadir" -fi +mkdir -p "$datadir" # Give permission to the datadir chown -R "$app":"$app" "$datadir" @@ -126,20 +124,28 @@ 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 #================================================= ynh_script_progression --message="Restoring the systemd configuration..." ynh_restore_file --origin_path="/etc/systemd/system/$app.service" -systemctl enable $app.service +systemctl enable $app.service --quiet #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add $app --description "$app daemon for Peertube" --log "/home/yunohost.app/${app}/storage/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 @@ -160,7 +166,7 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." +ynh_script_progression --message="Reloading NGINX web server..." ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/upgrade b/scripts/upgrade index 436cfcb..48380ff 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -22,8 +22,10 @@ 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) #================================================= # CHECK VERSION @@ -46,6 +48,12 @@ elif [ "$is_public" = "No" ]; then is_public=0 fi +if [ -z "$datadir" ]; +then + datadir="/home/yunohost.app/${app}/storage" + ynh_app_setting_set --app=$app --key=datadir --value=$datadir +fi + # Close a port if yunohost firewall list | grep -q "\- $port$" then @@ -61,13 +69,32 @@ 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 #================================================= ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." +# Inform the backup/restore process that it should not save the data directory +# Use only for the previous backup script that doesn't set 'is_big' +ynh_app_setting_set --app=$app --key=backup_core_only --value=1 + # Backup the current version of the app ynh_backup_before_upgrade + +# Remove the option backup_core_only after the backup. +ynh_app_setting_delete --app=$app --key=backup_core_only + ynh_clean_setup () { # restore it if the upgrade fails ynh_clean_check_starting @@ -133,10 +160,10 @@ fi #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading nginx web server configuration..." +ynh_script_progression --message="Upgrading NGINX web server configuration..." # Create a dedicated nginx config -ynh_add_nginx_config +ynh_add_nginx_config "datadir" #================================================= # UPGRADE DEPENDENCIES @@ -178,9 +205,6 @@ ynh_system_user_create --username=$app #================================================= ynh_script_progression --message="Creating the data directory..." -# Define app's data directory -datadir="/home/yunohost.app/${app}/storage" - if [ ! -d "$datadir" ] then # Create app folders @@ -204,6 +228,7 @@ ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_fil ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$config" ynh_replace_string --match_string="__EMAIL__" --replace_string="$admin_email" --target_file="$config" ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$config" +ynh_replace_string --match_string="__DATADIR__" --replace_string="$datadir" --target_file="$config" ynh_store_file_checksum --file="$config" local_config="$final_path/config/local-production.json" @@ -213,7 +238,7 @@ ynh_store_file_checksum --file="$local_config" #================================================= # BUILD YARN DEPENDENCIES #================================================= -ynh_script_progression --message="Building yarn dependencies..." +ynh_script_progression --message="Building Yarn dependencies..." chown -R "$app":"$app" $final_path @@ -222,14 +247,6 @@ pushd "$final_path" #sudo -u $app env PATH=$PATH yarn install --production --pure-lockfile popd -#================================================= -# SETUP LOGROTATE -#================================================= -ynh_script_progression --message="Upgrading logrotate configuration..." - -# Use logrotate to manage app-specific logfile(s) -ynh_use_logrotate --non-append - #================================================= # SETUP SYSTEMD #================================================= @@ -248,6 +265,28 @@ ynh_script_progression --message="Securing files and directories..." # Set permissions on app files chown -R $app:$app $final_path +#================================================= +# SETUP LOGROTATE +#================================================= +ynh_script_progression --message="Upgrading logrotate configuration..." + +# Use logrotate to manage app-specific logfile(s) +ynh_use_logrotate --non-append + +#================================================= +# INTEGRATE SERVICE IN YUNOHOST +#================================================= +ynh_script_progression --message="Integrating service in YunoHost..." + +yunohost service add $app --description "$app daemon for Peertube" --log "$datadir/logs/peertube.log" --needs_exposed_ports $rtmp_port + +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a systemd service..." + +ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Server listening on localhost" + #================================================= # SETUP SSOWAT #================================================= @@ -260,17 +299,10 @@ then ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" fi -#================================================= -# START SYSTEMD SERVICE -#================================================= -ynh_script_progression --message="Starting a systemd service..." - -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Server listening on localhost" - #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." +ynh_script_progression --message="Reloading NGINX web server..." ynh_systemd_action --service_name=nginx --action=reload