diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 6133a24..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,7 +0,0 @@
-language: python
-
-before_install:
- - git clone https://github.com/YunoHost/package_linter /tmp/package_linter
-
-script:
-- /tmp/package_linter/package_linter.py ./
\ No newline at end of file
diff --git a/README.md b/README.md
index 5bd5915..9f536ab 100644
--- a/README.md
+++ b/README.md
@@ -5,7 +5,7 @@ It shall NOT be edited by hand.
# PeerTube for YunoHost
-[![Integration level](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)
+[![Integration level](https://dash.yunohost.org/integration/peertube.svg)](https://dash.yunohost.org/appci/app/peertube) ![Working status](https://ci-apps.yunohost.org/ci/badges/peertube.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/peertube.maintain.svg)
[![Install PeerTube with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=peertube)
*[Lire ce readme en français.](./README_fr.md)*
@@ -18,13 +18,13 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in
Federated (ActivityPub) video streaming platform using P2P (BitTorrent) directly in the web browser, using WebTorrent.
-**Shipped version:** 4.1.1~ynh1
+**Shipped version:** 4.2.0~ynh1
**Demo:** http://peertube.cpy.re
## Screenshots
-![](./doc/screenshots/screenshot1.png)
+![Screenshot of PeerTube](./doc/screenshots/screenshot1.png)
## Disclaimers / important information
@@ -64,21 +64,22 @@ By watching a video, you help the hosting provider to broadcast it by becoming a
## Documentation and resources
-* Official app website: https://joinpeertube.org/fr
-* Official admin documentation: https://docs.joinpeertube.org
-* Upstream app code repository: https://github.com/Chocobozzz/PeerTube
-* YunoHost documentation for this app: https://yunohost.org/app_peertube
-* Report a bug: https://github.com/YunoHost-Apps/peertube_ynh/issues
+* Official app website:
+* Official admin documentation:
+* Upstream app code repository:
+* YunoHost documentation for this app:
+* Report a bug:
## 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.
-```
+
+``` bash
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
```
-**More info regarding app packaging:** https://yunohost.org/packaging_apps
\ No newline at end of file
+**More info regarding app packaging:**
diff --git a/README_fr.md b/README_fr.md
index fde0ad6..6dd9fcf 100644
--- a/README_fr.md
+++ b/README_fr.md
@@ -1,10 +1,14 @@
+
+
# 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)
+[![Niveau d'intégration](https://dash.yunohost.org/integration/peertube.svg)](https://dash.yunohost.org/appci/app/peertube) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/peertube.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/peertube.maintain.svg)
[![Installer PeerTube avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=peertube)
*[Read this readme in english.](./README.md)*
-*[Lire ce readme en français.](./README_fr.md)*
> *Ce package vous permet d'installer PeerTube rapidement et simplement sur un serveur YunoHost.
Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l'installer et en profiter.*
@@ -14,13 +18,13 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour
Plateforme de streaming vidéo fédérée (ActivityPub) utilisant P2P (BitTorrent) directement dans le navigateur Web, en utilisant WebTorrent
-**Version incluse :** 4.1.1~ynh1
+**Version incluse :** 4.2.0~ynh1
**Démo :** http://peertube.cpy.re
## Captures d'écran
-![](./doc/screenshots/screenshot1.png)
+![Capture d'écran de PeerTube](./doc/screenshots/screenshot1.png)
## Avertissements / informations importantes
@@ -58,21 +62,22 @@ En regardant une vidéo, vous aidez l'hébergeur à la diffuser en devenant vous
## Documentations et ressources
-* Site officiel de l'app : https://joinpeertube.org/fr
-* Documentation officielle de l'admin : https://docs.joinpeertube.org
-* Dépôt de code officiel de l'app : https://github.com/Chocobozzz/PeerTube
-* Documentation YunoHost pour cette app : https://yunohost.org/app_peertube
-* Signaler un bug : https://github.com/YunoHost-Apps/peertube_ynh/issues
+* Site officiel de l'app :
+* Documentation officielle de l'admin :
+* Dépôt de code officiel de l'app :
+* Documentation YunoHost pour cette app :
+* Signaler un bug :
## Informations pour les développeurs
Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/peertube_ynh/tree/testing).
Pour essayer la branche testing, procédez comme suit.
-```
+
+``` bash
sudo yunohost app install https://github.com/YunoHost-Apps/peertube_ynh/tree/testing --debug
ou
sudo yunohost app upgrade peertube -u https://github.com/YunoHost-Apps/peertube_ynh/tree/testing --debug
```
-**Plus d'infos sur le packaging d'applications :** https://yunohost.org/packaging_apps
\ No newline at end of file
+**Plus d'infos sur le packaging d'applications :**
diff --git a/check_process b/check_process
index d64a386..15a7c9b 100644
--- a/check_process
+++ b/check_process
@@ -1,9 +1,8 @@
;; Test complet
; Manifest
domain="domain.tld"
- email="admin@example.com"
is_public=1
- port="9000"
+ admin="john"
; Checks
pkg_linter=1
setup_sub_dir=0
@@ -26,6 +25,8 @@
upgrade=1 from_commit=7c2bb0bb6a91b6b957b734f684aa3d64da892f4c
# 4.0.0~ynh2
upgrade=1 from_commit=6995b27972e27c6cf8ee3e1f23a2de5cc8c8e8ee
+ # 4.1.1~ynh1
+ upgrade=1 from_commit=24c8333d70312e9dcf8d278e64787ca561a10b2e
backup_restore=1
multi_instance=0
port_already_use=0
diff --git a/conf/app.src b/conf/app.src
index 66fc923..f50bdd6 100644
--- a/conf/app.src
+++ b/conf/app.src
@@ -1,5 +1,5 @@
-SOURCE_URL=https://github.com/Chocobozzz/PeerTube/releases/download/v4.1.1/peertube-v4.1.1.tar.xz
-SOURCE_SUM=8a8cc31499cad2085ec997c8ae165b5777c89be17bc44d887c364e061d0964b4
+SOURCE_URL=https://github.com/Chocobozzz/PeerTube/releases/download/v4.2.0/peertube-v4.2.0.tar.xz
+SOURCE_SUM=b655e52096fde65d72d5ff29f153c8d122fa253154a4bad127e6f392585fd3ab
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.xz
SOURCE_IN_SUBDIR=true
diff --git a/conf/nginx.conf b/conf/nginx.conf
index 7315d8b..0aaa6e8 100644
--- a/conf/nginx.conf
+++ b/conf/nginx.conf
@@ -26,14 +26,14 @@ location = /api/v1/videos/upload-resumable {
}
location / {
-
+
try_files /dev/null @api;
# Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc;
}
-location = /api/v1/videos/upload {
+location ~ ^/api/v1/videos/(upload|([^/]+/studio/edit))$ {
limit_except POST HEAD { deny all; }
# This is the maximum upload size, which roughly matches the maximum size of a video file.
@@ -119,7 +119,7 @@ tcp_nodelay on; # don't buffer data sent, good for small data burs
# Bypass PeerTube for performance reasons. Optional.
# Should be consistent with client-overrides assets list in /server/controllers/client.ts
-location ~ ^/client/(assets/images/(icons/icon-36x36\.png|icons/icon-48x48\.png|icons/icon-72x72\.png|icons/icon-96x96\.png|icons/icon-144x144\.png|icons/icon-192x192\.png|icons/icon-512x512\.png|logo\.svg|favicon\.png|default-playlist\.jpg|default-avatar-account\.png|default-avatar-video-channel\.png))$ {
+location ~ ^/client/(assets/images/(icons/icon-36x36\.png|icons/icon-48x48\.png|icons/icon-72x72\.png|icons/icon-96x96\.png|icons/icon-144x144\.png|icons/icon-192x192\.png|icons/icon-512x512\.png|logo\.svg|favicon\.png|default-playlist\.jpg|default-avatar-account\.png|default-avatar-account-48x48\.png|default-avatar-video-channel\.png|default-avatar-video-channel-48x48\.png))$ {
more_set_headers "Cache-Control : public, max-age=31536000, immutable"; # Cache 1 year
try_files __DATADIR__/client-overrides/$1 __FINALPATH__/client/dist/$1 @api;
diff --git a/conf/production.yaml b/conf/production.yaml
index 3910e55..ef9580a 100644
--- a/conf/production.yaml
+++ b/conf/production.yaml
@@ -45,7 +45,7 @@ database:
# Redis server for short time storage
# You can also specify a 'socket' path to a unix socket but first need to
-# comment out hostname and port
+# set 'hostname' and 'port' to null
redis:
hostname: 'localhost'
port: 6379
@@ -73,12 +73,31 @@ email:
subject:
prefix: '[PeerTube]'
-# PeerTube client/interface configuration
-client:
- videos:
- miniature:
- # By default PeerTube client displays author username
- prefer_author_display_name: false
+# Update default PeerTube values
+# Set by API when the field is not provided and put as default value in client
+defaults:
+ # Change default values when publishing a video (upload/import/go Live)
+ publish:
+ download_enabled: true
+
+ comments_enabled: true
+
+ # public = 1, unlisted = 2, private = 3, internal = 4
+ privacy: 1
+
+ # CC-BY = 1, CC-SA = 2, CC-ND = 3, CC-NC = 4, CC-NC-SA = 5, CC-NC-ND = 6, Public Domain = 7
+ # You can also choose a custom licence value added by a plugin
+ # No licence by default
+ licence: null
+
+ p2p:
+ # Enable P2P by default
+ # Can be enabled/disabled by anonymous users and logged in users
+ webapp:
+ enabled: true
+
+ embed:
+ enabled: true
# From the project root directory
storage:
@@ -115,6 +134,9 @@ object_storage:
region: 'us-east-1'
+ # Set this ACL on each uploaded object
+ upload_acl: 'public'
+
credentials:
# You can also use AWS_ACCESS_KEY_ID env variable
access_key_id: ''
@@ -155,7 +177,6 @@ trending:
interval_days: 7 # Compute trending videos for the last x days
algorithms:
enabled:
- - 'best' # adaptation of Reddit's 'Best' algorithm (Hot minus History)
- 'hot' # adaptation of Reddit's 'Hot' algorithm
- 'most-viewed' # default, used initially by PeerTube as the trending page
- 'most-liked'
@@ -235,6 +256,13 @@ views:
ip_view_expiration: '1 hour'
+# Used to get country location of views of local videos
+geo_ip:
+ enabled: true
+
+ country:
+ database_url: 'https://dbip.mirror.framasoft.org/files/dbip-country-lite-latest.mmdb'
+
plugins:
# The website PeerTube will ask for available PeerTube plugins and themes
# This is an unmoderated plugin index, so only install plugins/themes you trust
@@ -287,7 +315,7 @@ cache:
admin:
# Used to generate the root user at first startup
# And to receive emails from the contact form
- email: '__ADMIN_EMAIL__'
+ email: '__ADMIN_MAIL__'
contact_form:
enabled: true
@@ -381,19 +409,43 @@ live:
# /!\ transcoding.enabled (and not live.transcoding.enabled) has to be true to create a replay
allow_replay: true
+ # Allow your users to change latency settings (small latency/default/high latency)
+ # Small latency live streams cannot use P2P
+ # High latency live streams can increase P2P ratio
+ latency_setting:
+ enabled: true
+
# Your firewall should accept traffic from this port in TCP if you enable live
rtmp:
enabled: true
+
+ # Listening hostname/port for RTMP server
+ # '::' to listen on IPv6 and IPv4, '0.0.0.0' to listen on IPv4
+ # Use null to automatically listen on '::' if IPv6 is available, or '0.0.0.0' otherwise
+ hostname: null
port: 1935
+ # Public hostname of your RTMP server
+ # Use null to use the same value than `webserver.hostname`
+ public_hostname: null
+
rtmps:
enabled: false
+
+ # Listening hostname/port for RTMPS server
+ # '::' to listen on IPv6 and IPv4, '0.0.0.0' to listen on IPv4
+ # Use null to automatically listen on '::' if IPv6 is available, or '0.0.0.0' otherwise
+ hostname: null
port: 1936
- # Absolute path
+
+ # Absolute paths
key_file: ''
- # Absolute path
cert_file: ''
+ # Public hostname of your RTMPS server
+ # Use null to use the same value than `webserver.hostname`
+ public_hostname: null
+
# Allow to transcode the live streaming in multiple live resolutions
transcoding:
enabled: true
@@ -414,13 +466,21 @@ live:
1440p: false
2160p: false
+video_studio:
+ # Enable video edition by users (cut, add intro/outro, add watermark etc)
+ # If enabled, users can create transcoding tasks as they wish
+ enabled: false
+
import:
# Add ability for your users to import remote videos (from YouTube, torrent...)
videos:
# Amount of import jobs to execute in parallel
concurrency: 1
- http: # Classic HTTP or all sites supported by youtube-dl https://rg3.github.io/youtube-dl/supportedsites.html
+ # Classic HTTP or all sites supported by youtube-dl https://rg3.github.io/youtube-dl/supportedsites.html
+ http:
+ # We recommend to use a HTTP proxy if you enable HTTP import to prevent private URL access from this server
+ # See https://docs.joinpeertube.org/maintain-configuration?id=security for more information
enabled: false
youtube_dl_release:
@@ -429,18 +489,22 @@ import:
# Examples:
# * https://api.github.com/repos/ytdl-org/youtube-dl/releases
# * https://api.github.com/repos/yt-dlp/yt-dlp/releases
- url: 'https://api.github.com/repos/yt-dlp/yt-dlp/releases'
+ url: 'https://yt-dl.org/downloads/latest/youtube-dl'
# youtube-dl binary name
# yt-dlp is also supported
- name: 'yt-dlp'
+ name: 'youtube-dl'
+
# Path to the python binary to execute for youtube-dl or yt-dlp
python_path: '/usr/bin/python3'
# IPv6 is very strongly rate-limited on most sites supported by youtube-dl
force_ipv4: false
- torrent: # Magnet URI or torrent file (use classic TCP/UDP/WebSeed to download the file)
+ # Magnet URI or torrent file (use classic TCP/UDP/WebSeed to download the file)
+ torrent:
+ # We recommend to only enable magnet URI/torrent import if you trust your users
+ # See https://docs.joinpeertube.org/maintain-configuration?id=security for more information
enabled: false
auto_blacklist:
@@ -593,3 +657,21 @@ search:
disable_local_search: false
# If you did not disable local search, you can decide to use the search index by default
is_default_search: false
+
+# PeerTube client/interface configuration
+client:
+ videos:
+ miniature:
+ # By default PeerTube client displays author username
+ prefer_author_display_name: false
+ display_author_avatar: false
+ resumable_upload:
+ # Max size of upload chunks, e.g. '90MB'
+ # If null, it will be calculated based on network speed
+ max_chunk_size: null
+
+ menu:
+ login:
+ # If you enable only one external auth plugin
+ # You can automatically redirect your users on this external platform when they click on the login button
+ redirect_on_single_external_auth: false
diff --git a/manifest.json b/manifest.json
index 0749c5f..821775e 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": "4.1.1~ynh1",
+ "version": "4.2.0~ynh1",
"url": "https://github.com/Chocobozzz/PeerTube",
"upstream": {
"license": "AGPL-3.0-only",
@@ -38,14 +38,14 @@
"name": "domain",
"type": "domain"
},
- {
- "name": "admin",
- "type": "user"
- },
{
"name": "is_public",
"type": "boolean",
"default": true
+ },
+ {
+ "name": "admin",
+ "type": "user"
}
]
}
diff --git a/scripts/_common.sh b/scripts/_common.sh
index 5e43880..55f6125 100644
--- a/scripts/_common.sh
+++ b/scripts/_common.sh
@@ -6,8 +6,9 @@
# dependencies used by the app
pkg_dependencies="ffmpeg postgresql postgresql-contrib openssl g++ mailutils apt-transport-https"
+ynh_app_dependencies="prosody"
-NODEJS_VERSION=16
+nodejs_version=16
#=================================================
# PERSONAL HELPERS
diff --git a/scripts/install b/scripts/install
index cae6d2c..e06a16b 100644
--- a/scripts/install
+++ b/scripts/install
@@ -9,6 +9,7 @@
source _common.sh
source ynh_redis
source ynh_send_readme_to_admin__2
+source ynh_apps
source /usr/share/yunohost/helpers
#=================================================
@@ -27,9 +28,9 @@ ynh_abort_if_errors
domain=$YNH_APP_ARG_DOMAIN
path_url="/"
-admin=$YNH_APP_ARG_ADMIN
is_public=$YNH_APP_ARG_IS_PUBLIC
-admin_email=$(ynh_user_get_info --username=$admin --key="mail")
+admin=$YNH_APP_ARG_ADMIN
+admin_mail=$(ynh_user_get_info --username=$admin --key="mail")
admin_pass=$(ynh_string_random --length=24)
app=$YNH_APP_INSTANCE_NAME
@@ -64,7 +65,7 @@ ynh_app_setting_set --app=$app --key=admin --value=$admin
ynh_script_progression --message="Finding an available port..."
# Find an available port
-port=$(ynh_find_port --port=9000)
+port=$(ynh_find_port --port=8095)
ynh_app_setting_set --app=$app --key=port --value=$port
# PeerTube Live port
@@ -81,33 +82,18 @@ ynh_exec_warn_less yunohost firewall allow TCP $rtmp_port
#=================================================
ynh_script_progression --message="Installing dependencies..."
-# Install nodejs
-ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
-
-# Install dependencies
-ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
-
-# Install Yarn
+ynh_install_apps --apps="$ynh_app_dependencies"
+ynh_install_app_dependencies $pkg_dependencies
+ynh_install_nodejs --nodejs_version=$nodejs_version
ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
-if ! yunohost app list | grep -q "prosody"
-then
- yunohost tools update
- yunohost app install prosody
-else
- yunohost tools update
- yunohost app upgrade prosody
-fi
-
-ynh_app_setting_set --app=$app --key=require_prosody --value="1"
-
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..."
# Create a system user
-ynh_system_user_create --username=$app --home_dir=$final_path
+ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# CREATE A POSTGRESQL DATABASE
@@ -116,12 +102,11 @@ ynh_script_progression --message="Creating a PostgreSQL database..."
db_name="peertube_${app}"
db_user=$(ynh_sanitize_dbid --db_name=$app)
-db_pwd=$(ynh_string_random --length=30)
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
ynh_app_setting_set --app=$app --key=db_user --value=$db_user
-ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd
ynh_psql_test_if_first_run
-ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
+ynh_psql_setup_db --db_user=$db_user --db_name=$db_name
+db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS unaccent;" --database=$db_name
ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS pg_trgm;" --database=$db_name
@@ -300,7 +285,7 @@ ynh_systemd_action --service_name=nginx --action=reload
#=================================================
ynh_script_progression --message="Sending a readme for the admin..."
-ynh_send_readme_to_admin --app_message="../conf/msg_install" --recipients=$admin_email --type='install'
+ynh_send_readme_to_admin --app_message="../conf/msg_install" --recipients=$admin_mail --type='install'
#=================================================
# END OF SCRIPT
diff --git a/scripts/remove b/scripts/remove
index e61e3c0..aba1e6d 100644
--- a/scripts/remove
+++ b/scripts/remove
@@ -9,6 +9,7 @@
source _common.sh
source ynh_redis
source ynh_send_readme_to_admin__2
+source ynh_apps
source /usr/share/yunohost/helpers
#=================================================
@@ -25,7 +26,7 @@ db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$(ynh_app_setting_get --app=$app --key=db_user)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
admin=$(ynh_app_setting_get --app=$app --key=admin)
-admin_email=$(ynh_user_get_info --username=$admin --key="mail")
+admin_mail=$(ynh_user_get_info --username=$admin --key="mail")
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
path_url=$(ynh_app_setting_get --app=$app --key=path)
redis_db=$(ynh_app_setting_get --app=$app --key=redis_db)
@@ -109,42 +110,12 @@ ynh_script_progression --message="Removing dependencies..."
# Remove metapackage and its dependencies
ynh_remove_nodejs
ynh_remove_app_dependencies
-
-# Remove Prosody
-ynh_app_setting_delete --app=$app --key=require_prosody
-
-# List apps requiring Prosody
-installed_apps=$(yunohost app list | grep -oP 'id: \K.*$')
-required_by=""
-installed_app_required_by=""
-for installed_app in $installed_apps
-do
- installed_app_required_by=$(ynh_app_setting_get --app=$installed_app --key="require_prosody")
- if [[ $installed_app_required_by ]]
- then
- required_by="${installed_app_required_by}"
- fi
- installed_app_required_by=""
-done
-
-# If Prosody is no more required
-if [[ ! $required_by ]]
-then
- # Remove Prosody
- ynh_print_info --message="Removing of Prosody"
- yunohost app remove prosody --purge
-fi
+ynh_remove_apps
#=================================================
# CLOSE A PORT
#=================================================
-if yunohost firewall list | grep -q "\- $port$"
-then
- ynh_script_progression --message="Closing port $port..."
- 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..."
@@ -176,7 +147,7 @@ ynh_system_user_delete --username=$app
#=================================================
ynh_script_progression --message="Sending a readme for the admin..."
-ynh_send_readme_to_admin --app_message="../conf/msg_remove" --recipients=$admin_email --type='remove'
+ynh_send_readme_to_admin --app_message="../conf/msg_remove" --recipients=$admin_mail --type='remove'
#=================================================
# END OF SCRIPT
diff --git a/scripts/restore b/scripts/restore
index d12ada6..428a7f1 100644
--- a/scripts/restore
+++ b/scripts/restore
@@ -8,6 +8,7 @@
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
+source ../settings/scripts/ynh_apps
source /usr/share/yunohost/helpers
#=================================================
@@ -34,7 +35,6 @@ 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=db_name)
db_user=$(ynh_app_setting_get --app=$app --key=db_user)
-db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#=================================================
@@ -47,13 +47,6 @@ test ! -d $final_path \
#=================================================
# STANDARD RESTORATION STEPS
-#=================================================
-# RESTORE THE NGINX CONFIGURATION
-#=================================================
-ynh_script_progression --message="Restoring the NGINX web server configuration..."
-
-ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
-
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
@@ -93,22 +86,17 @@ chown -R $app:www-data "$datadir"
#=================================================
ynh_script_progression --message="Reinstalling dependencies..."
-# Install nodejs
-ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
+ynh_install_apps --apps="$ynh_app_dependencies"
+ynh_install_app_dependencies $pkg_dependencies
+ynh_install_nodejs --nodejs_version=$nodejs_version
+ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
-# Install dependencies
-ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
+#=================================================
+# RESTORE THE NGINX CONFIGURATION
+#=================================================
+ynh_script_progression --message="Restoring the NGINX web server configuration..."
-if ! yunohost app list | grep -q "prosody"
-then
- yunohost tools update
- yunohost app install prosody
-else
- yunohost tools update
- yunohost app upgrade prosody
-fi
-
-ynh_app_setting_set --app=$app --key=require_prosody --value="1"
+ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RESTORE THE POSTGRESQL DATABASE
@@ -116,6 +104,7 @@ ynh_app_setting_set --app=$app --key=require_prosody --value="1"
ynh_script_progression --message="Restoring the PostgreSQL database..."
ynh_psql_test_if_first_run
+db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
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
diff --git a/scripts/upgrade b/scripts/upgrade
index b55b0fa..07bd954 100644
--- a/scripts/upgrade
+++ b/scripts/upgrade
@@ -8,6 +8,7 @@
source _common.sh
source ynh_redis
+source ynh_apps
source /usr/share/yunohost/helpers
#=================================================
@@ -19,15 +20,15 @@ app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
+admin=$(ynh_app_setting_get --app=$app --key=admin)
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=db_name)
db_user=$(ynh_app_setting_get --app=$app --key=db_user)
-db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
+db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
-admin=$(ynh_app_setting_get --app=$app --key=admin)
-admin_email=$(ynh_user_get_info --username=$admin --key="mail")
+admin_mail=$(ynh_user_get_info --username=$admin --key="mail")
redis_db=$(ynh_app_setting_get --app=$app --key=redis_db)
#=================================================
@@ -67,7 +68,7 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd"
ynh_script_progression --message="Ensuring downward compatibility..."
ynh_app_setting_delete --app=$app --key=admin_pass
-ynh_app_setting_delete --app=$app --key=admin_email
+ynh_app_setting_delete --app=$app --key=admin_mail
# If db_name doesn't exist, create it
if [ -z "$db_name" ]; then
@@ -198,6 +199,16 @@ chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
+#=================================================
+# UPGRADE DEPENDENCIES
+#=================================================
+ynh_script_progression --message="Upgrading dependencies..."
+
+ynh_install_apps --apps="$ynh_app_dependencies"
+ynh_install_app_dependencies $pkg_dependencies
+ynh_install_nodejs --nodejs_version=$nodejs_version
+ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
+
#=================================================
# NGINX CONFIGURATION
#=================================================
@@ -206,31 +217,6 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..."
# Create a dedicated NGINX config
ynh_add_nginx_config
-#=================================================
-# UPGRADE DEPENDENCIES
-#=================================================
-ynh_script_progression --message="Upgrading dependencies..."
-
-# Install nodejs
-ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
-
-# Install dependencies
-ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
-
-# Install Yarn
-ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
-
-if ! yunohost app list | grep -q "prosody"
-then
- yunohost tools update
- yunohost app install prosody
-else
- yunohost tools update
- yunohost app upgrade prosody
-fi
-
-ynh_app_setting_set --app=$app --key=require_prosody --value="1"
-
#=================================================
# SPECIFIC UPGRADE
#=================================================
@@ -303,7 +289,7 @@ pushd "$final_path"
popd
#=================================================
-# PEERTUBE 4.0.0 UPGRADE MIGRATION SCRIPT
+# PEERTUBE UPGRADE MIGRATION SCRIPT
#=================================================
if ynh_compare_current_package_version --comparison lt --version 4.0.0~ynh1; then
@@ -313,6 +299,13 @@ if ynh_compare_current_package_version --comparison lt --version 4.0.0~ynh1; the
popd
fi
+if ynh_compare_current_package_version --comparison lt --version 4.2.0~ynh1; then
+ ynh_script_progression --message="Running Peertube 4.2.0 migration script..."
+ pushd "$final_path"
+ ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH NODE_CONFIG_DIR="$final_path/config" NODE_ENV=production $ynh_node dist/scripts/migrations/peertube-4.2.js
+ popd
+fi
+
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
diff --git a/scripts/ynh_apps b/scripts/ynh_apps
new file mode 100644
index 0000000..0faad86
--- /dev/null
+++ b/scripts/ynh_apps
@@ -0,0 +1,110 @@
+#!/bin/bash
+
+# Install others YunoHost apps
+#
+# usage: ynh_install_apps --apps="appfoo?domain=domain.foo&path=/foo appbar?domain=domain.bar&path=/bar&admin=USER&language=fr&is_public=1&pass?word=pass&port=666"
+# | arg: -a, --apps= - apps to install
+#
+# Requires YunoHost version *.*.* or higher.
+ynh_install_apps() {
+ # Declare an array to define the options of this helper.
+ local legacy_args=a
+ local -A args_array=([a]=apps=)
+ local apps
+ # Manage arguments with getopts
+ ynh_handle_getopts_args "$@"
+
+ # Split the list of apps in an array
+ local apps_list=($(echo $apps | tr " " "\n"))
+ local apps_dependencies=""
+
+ # For each app
+ for one_app_and_its_args in "${apps_list[@]}"
+ do
+ # Retrieve the name of the app (part before ?)
+ local one_app=$(cut -d "?" -f1 <<< "$one_app_and_its_args")
+ [ -z "$one_app" ] && ynh_die --message="You didn't provided a YunoHost app to install"
+
+ yunohost tools update apps
+
+ # Installing or upgrading the app depending if it's installed or not
+ if ! yunohost app list --output-as json --quiet | jq -e --arg id $one_app '.apps[] | select(.id == $id)' >/dev/null
+ then
+ # Retrieve the arguments of the app (part after ?)
+ local one_argument=$(cut -d "?" -f2- <<< "$one_app_and_its_args")
+ [ ! -z "$one_argument" ] && one_argument="--args $one_argument"
+
+ # Install the app with its arguments
+ yunohost app install $one_app $one_argument
+ else
+ # Upgrade the app
+ yunohost app upgrade $one_app
+ fi
+
+ if [ ! -z "$apps_dependencies" ]
+ then
+ apps_dependencies="$apps_dependencies, $one_app"
+ else
+ apps_dependencies="$one_app"
+ fi
+ done
+
+ ynh_app_setting_set --app=$app --key=apps_dependencies --value="$apps_dependencies"
+}
+
+# Remove other YunoHost apps
+#
+# Other YunoHost apps will be removed only if no other apps need them.
+#
+# usage: ynh_remove_apps
+#
+# Requires YunoHost version *.*.* or higher.
+ynh_remove_apps() {
+ # Retrieve the apps dependencies of the app
+ local apps_dependencies=$(ynh_app_setting_get --app=$app --key=apps_dependencies)
+ ynh_app_setting_delete --app=$app --key=apps_dependencies
+
+ if [ ! -z "$apps_dependencies" ]
+ then
+ # Split the list of apps dependencies in an array
+ local apps_dependencies_list=($(echo $apps_dependencies | tr ", " "\n"))
+
+ # For each apps dependencies
+ for one_app in "${apps_dependencies_list[@]}"
+ do
+ # Retrieve the list of installed apps
+ local installed_apps_list=$(yunohost app list --output-as json --quiet | jq -r .apps[].id)
+ local required_by=""
+ local installed_app_required_by=""
+
+ # For each other installed app
+ for one_installed_app in $installed_apps_list
+ do
+ # Retrieve the other apps dependencies
+ one_installed_apps_dependencies=$(ynh_app_setting_get --app=$one_installed_app --key=apps_dependencies)
+ if [ ! -z "$one_installed_apps_dependencies" ]
+ then
+ one_installed_apps_dependencies_list=($(echo $one_installed_apps_dependencies | tr ", " "\n"))
+
+ # For each dependency of the other apps
+ for one_installed_app_dependency in "${one_installed_apps_dependencies_list[@]}"
+ do
+ if [[ $one_installed_app_dependency == $one_app ]]; then
+ required_by="$required_by $one_installed_app"
+ fi
+ done
+ fi
+ done
+
+ # If $one_app is no more required
+ if [[ -z "$required_by" ]]
+ then
+ # Remove $one_app
+ ynh_print_info --message="Removing of $one_app"
+ yunohost app remove $one_app --purge
+ else
+ ynh_print_info --message="$one_app was not removed because it's still required by${required_by}"
+ fi
+ done
+ fi
+}