From 2032d0f83a389d1a7e64c609fb58d33c29aaf35f Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 30 Jan 2022 21:34:03 +0100 Subject: [PATCH 01/23] Install PEERTUBE LIVECHAT PLUGIN Fix #278 --- doc/DISCLAIMER.md | 23 +++++++++++++---------- doc/DISCLAIMER_fr.md | 29 ++++++++++------------------- scripts/install | 25 ++++++++++++++++++++++--- scripts/restore | 5 +++++ scripts/upgrade | 26 ++++++++++++++++++++------ 5 files changed, 70 insertions(+), 38 deletions(-) diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md index f7d823e..a1c7156 100644 --- a/doc/DISCLAIMER.md +++ b/doc/DISCLAIMER.md @@ -12,19 +12,22 @@ Servers are run independently by different people and organizations. They can ap By watching a video, you help the hosting provider to broadcast it by becoming a broadcaster of the video yourself. Each instance doesn't need much money to broadcast the videos of its users. -* Any known limitations, constrains or stuff not working, such as (but not limited to): - * Require **dedicated domain** like **peertube.domain.tld**. - * Admin username is: **root**. - * **Admin password and LDAP configuration** will be sent to the email address given at the time of the installation. - * URL can not be changed once selected. Choose the domain wisely. - * You need more then **1 GB** of RAM. If you don't have it, please create a **swap memory**. +### IMPORTANT POINT TO READ BEFORE INSTALLING +* Require **dedicated domain** like **peertube.domain.tld**. +* Admin username is: **root**. +* **Admin password and LDAP configuration** will be sent to the email address given at the time of the installation. +* URL can not be changed once selected. Choose the domain wisely. +* You need more then **1 GB** of RAM. If you don't have it, please create a **swap memory**. $ dd if=/dev/zero of=/swapfile bs=1024 count=1048576 $ mkswap /swapfile $ swapon /swapfile $ echo "/swapfile swap swap defaults 0 0" >> /etc/fstab - * This app is **multi-instance** (you can have more then one PeerTube instance running on a YunoHost server) - * **If you are hosted on OVH virtual machine or experiencing `gyp ERR! configure error`, please switch to [ovh_fix](https://github.com/YunoHost-Apps/peertube_ynh/tree/ovh_fix)** - * LDAP auth is supported, LDAP configuration will be sent to the email address given at the time of the installation. - * HTTP auth is not supported +* This app is **multi-instance** (you can have more then one PeerTube instance running on a YunoHost server) +* **If you are hosted on OVH virtual machine or experiencing `gyp ERR! configure error`, please switch to [ovh_fix](https://github.com/YunoHost-Apps/peertube_ynh/tree/ovh_fix)** +* HTTP auth is not supported + +### PLUGINS +* LDAP auth is supported, LDAP configuration will be sent to the email address given at the time of the installation. +* PeerTube plugin livechat is installed with Prosody. To enable, just select «Prosody server controlled by Peertube» as chat mode in the plugin configutation of the PeerTube admin page diff --git a/doc/DISCLAIMER_fr.md b/doc/DISCLAIMER_fr.md index acc6ba9..9d0fe38 100644 --- a/doc/DISCLAIMER_fr.md +++ b/doc/DISCLAIMER_fr.md @@ -1,8 +1,3 @@ -## 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 . - ### Pourquoi 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. @@ -15,26 +10,22 @@ Les serveurs sont gérés indépendamment par différentes personnes et organisa 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. -## Points importants à lire avant l'installation - -1. Nécessite un **domaine dédié** comme **peertube.domain.tld**. -1. Le nom d'utilisateur de l'administrateur est: **root**. -1. **Le mot de passe administrateur et la configuration LDAP** seront envoyés à 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**. - +### Points importants à lire avant l'installation +* Nécessite un **domaine dédié** comme **peertube.domain.tld**. +* Le nom d'utilisateur de l'administrateur est: **root**. +* **Le mot de passe administrateur et la configuration LDAP** seront envoyés à l'adresse email indiquée au moment de l'installation. +* L'URL ne peut pas être modifiée une fois sélectionnée. Choisissez judicieusement le domaine. +* 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)** +* Cette application est **multi-instance** (vous pouvez avoir plus d'une instance PeerTube en cours d'exécution sur un serveur YunoHost) +* **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)** -## Caractéristiques spécifiques YunoHost - -#### Support multi-utilisateur +#### PLUGINS * L'authentification LDAP est prise en charge, les instructions de configuration sont envoyées à l'adresse email indiquée au moment de l'installation -* L'authentification HTTP n'est pas prise en charge +* le plugin PeerTube livechat est installé ainsi que Prosody. pour l'activer, sélectionner «Prosody server controlled by Peertube» dans le paramétre chat mode du plugin dans la page d'administration de PeerTube. diff --git a/scripts/install b/scripts/install index 0bd23d1..63b226d 100644 --- a/scripts/install +++ b/scripts/install @@ -91,6 +91,11 @@ 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 app install prosody --args "domain=$domain&admin=$admin&language=$language&password=$password" +fi + #================================================= # CREATE DEDICATED USER #================================================= @@ -165,7 +170,7 @@ ynh_script_progression --message="Building Yarn dependencies..." pushd "$final_path" ynh_use_nodejs - ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH yarn install --production --pure-lockfile + ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn install --production --pure-lockfile popd #================================================= @@ -205,7 +210,21 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --l ynh_script_progression --message="Installing LDAP plugin..." pushd "$final_path" - ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH NODE_CONFIG_DIR="$final_path/config" NODE_ENV=production $ynh_npm run plugin:install -- --npm-name peertube-plugin-auth-ldap + ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH NODE_CONFIG_DIR="$final_path/config" NODE_ENV=production $ynh_npm run plugin:install -- --npm-name peertube-plugin-auth-ldap +popd + +#================================================= +# INSTALL PEERTUBE LIVECHAT PLUGIN +#================================================= +ynh_script_progression --message="Installing PeerTube livechat plugin..." + +if ! yunohost app list | grep -q "prosody" +then + yunohost app install prosody --args "domain=$domain&admin=$admin&language=$language&password=$password" +fi + +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_npm run plugin:install -- --npm-name peertube-plugin-livechat popd #================================================= @@ -214,7 +233,7 @@ popd ynh_script_progression --message="Changing PeerTube admin password..." pushd "$final_path" - echo $admin_pass | ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH NODE_CONFIG_DIR="$final_path/config" NODE_ENV=production $ynh_npm run reset-password -- -u root + echo $admin_pass | ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH NODE_CONFIG_DIR="$final_path/config" NODE_ENV=production $ynh_npm run reset-password -- -u root popd #================================================= diff --git a/scripts/restore b/scripts/restore index a5050e3..ea26709 100644 --- a/scripts/restore +++ b/scripts/restore @@ -102,6 +102,11 @@ 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 app install prosody --args "domain=$domain&admin=$admin&language=$language&password=$password" +fi + #================================================= # RESTORE THE POSTGRESQL DATABASE #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 6c956f8..8cd267c 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -139,6 +139,10 @@ if ! ynh_permission_exists --permission="api"; then ynh_permission_create --permission="api" --url="/api" --allowed="visitors" --auth_header="false" --show_tile="false" --protected="true" fi +# Remove hook +ynh_secure_remove --file="/usr/share/yunohost/hooks/conf_regen/15-nginx_$app" +yunohost tools regen-conf nginx + #================================================= # CREATE DEDICATED USER #================================================= @@ -212,9 +216,10 @@ 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" -# Remove hook -ynh_secure_remove --file="/usr/share/yunohost/hooks/conf_regen/15-nginx_$app" -yunohost tools regen-conf nginx +if ! yunohost app list | grep -q "prosody" +then + yunohost app install prosody --args "domain=$domain&admin=$admin&language=$language&password=$password" +fi #================================================= # SPECIFIC UPGRADE @@ -249,7 +254,7 @@ ynh_script_progression --message="Building Yarn dependencies..." pushd "$final_path" ynh_use_nodejs - ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH yarn install --production --pure-lockfile + ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn install --production --pure-lockfile popd #================================================= @@ -274,7 +279,16 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --l ynh_script_progression --message="Installing LDAP plugin..." pushd "$final_path" - ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH NODE_CONFIG_DIR="$final_path/config" NODE_ENV=production $ynh_npm run plugin:install -- --npm-name peertube-plugin-auth-ldap + ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH NODE_CONFIG_DIR="$final_path/config" NODE_ENV=production $ynh_npm run plugin:install -- --npm-name peertube-plugin-auth-ldap +popd + +#================================================= +# INSTALL PEERTUBE LIVECHAT PLUGIN +#================================================= +ynh_script_progression --message="Installing PeerTube livechat plugin..." + +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_npm run plugin:install -- --npm-name peertube-plugin-livechat popd #================================================= @@ -284,7 +298,7 @@ popd if ynh_compare_current_package_version --comparison lt --version 4.0.0~ynh1; then ynh_script_progression --message="Running Peertube 4.0.0 migration script..." pushd "$final_path" - ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH NODE_CONFIG_DIR="$final_path/config" NODE_ENV=production $ynh_node dist/scripts/migrations/peertube-4.0.js + 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.0.js popd fi From d4375be93f0fe8037662ae6702caf80e63a31194 Mon Sep 17 00:00:00 2001 From: Yunohost-Bot <> Date: Sun, 30 Jan 2022 20:34:10 +0000 Subject: [PATCH 02/23] Auto-update README --- README.md | 23 +++++++++++++---------- README_fr.md | 29 ++++++++++------------------- 2 files changed, 23 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 599b5ba..236647a 100644 --- a/README.md +++ b/README.md @@ -42,22 +42,25 @@ Servers are run independently by different people and organizations. They can ap By watching a video, you help the hosting provider to broadcast it by becoming a broadcaster of the video yourself. Each instance doesn't need much money to broadcast the videos of its users. -* Any known limitations, constrains or stuff not working, such as (but not limited to): - * Require **dedicated domain** like **peertube.domain.tld**. - * Admin username is: **root**. - * **Admin password and LDAP configuration** will be sent to the email address given at the time of the installation. - * URL can not be changed once selected. Choose the domain wisely. - * You need more then **1 GB** of RAM. If you don't have it, please create a **swap memory**. +### IMPORTANT POINT TO READ BEFORE INSTALLING +* Require **dedicated domain** like **peertube.domain.tld**. +* Admin username is: **root**. +* **Admin password and LDAP configuration** will be sent to the email address given at the time of the installation. +* URL can not be changed once selected. Choose the domain wisely. +* You need more then **1 GB** of RAM. If you don't have it, please create a **swap memory**. $ dd if=/dev/zero of=/swapfile bs=1024 count=1048576 $ mkswap /swapfile $ swapon /swapfile $ echo "/swapfile swap swap defaults 0 0" >> /etc/fstab - * This app is **multi-instance** (you can have more then one PeerTube instance running on a YunoHost server) - * **If you are hosted on OVH virtual machine or experiencing `gyp ERR! configure error`, please switch to [ovh_fix](https://github.com/YunoHost-Apps/peertube_ynh/tree/ovh_fix)** - * LDAP auth is supported, LDAP configuration will be sent to the email address given at the time of the installation. - * HTTP auth is not supported +* This app is **multi-instance** (you can have more then one PeerTube instance running on a YunoHost server) +* **If you are hosted on OVH virtual machine or experiencing `gyp ERR! configure error`, please switch to [ovh_fix](https://github.com/YunoHost-Apps/peertube_ynh/tree/ovh_fix)** +* HTTP auth is not supported + +### PLUGINS +* LDAP auth is supported, LDAP configuration will be sent to the email address given at the time of the installation. +* PeerTube plugin livechat is installed with Prosody. To enable, just select «Prosody server controlled by Peertube» as chat mode in the plugin configutation of the PeerTube admin page ## Documentation and resources diff --git a/README_fr.md b/README_fr.md index ebc54c4..d998376 100644 --- a/README_fr.md +++ b/README_fr.md @@ -24,11 +24,6 @@ Plateforme de streaming vidéo fédérée (ActivityPub) utilisant P2P (BitTorren ## Avertissements / informations importantes -## 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 . - ### Pourquoi 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. @@ -41,29 +36,25 @@ Les serveurs sont gérés indépendamment par différentes personnes et organisa 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. -## Points importants à lire avant l'installation - -1. Nécessite un **domaine dédié** comme **peertube.domain.tld**. -1. Le nom d'utilisateur de l'administrateur est: **root**. -1. **Le mot de passe administrateur et la configuration LDAP** seront envoyés à 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**. - +### Points importants à lire avant l'installation +* Nécessite un **domaine dédié** comme **peertube.domain.tld**. +* Le nom d'utilisateur de l'administrateur est: **root**. +* **Le mot de passe administrateur et la configuration LDAP** seront envoyés à l'adresse email indiquée au moment de l'installation. +* L'URL ne peut pas être modifiée une fois sélectionnée. Choisissez judicieusement le domaine. +* 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)** +* Cette application est **multi-instance** (vous pouvez avoir plus d'une instance PeerTube en cours d'exécution sur un serveur YunoHost) +* **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)** -## Caractéristiques spécifiques YunoHost - -#### Support multi-utilisateur +#### PLUGINS * L'authentification LDAP est prise en charge, les instructions de configuration sont envoyées à l'adresse email indiquée au moment de l'installation -* L'authentification HTTP n'est pas prise en charge +* le plugin PeerTube livechat est installé ainsi que Prosody. pour l'activer, sélectionner «Prosody server controlled by Peertube» dans le paramétre chat mode du plugin dans la page d'administration de PeerTube. ## Documentations et ressources From 0e570c97c3f7ddd975e7cc2278282924f499a7b5 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 3 Feb 2022 21:18:56 +0100 Subject: [PATCH 03/23] Improving prosody --- scripts/install | 5 ----- scripts/upgrade | 2 ++ 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/scripts/install b/scripts/install index 63b226d..4badc73 100644 --- a/scripts/install +++ b/scripts/install @@ -218,11 +218,6 @@ popd #================================================= ynh_script_progression --message="Installing PeerTube livechat plugin..." -if ! yunohost app list | grep -q "prosody" -then - yunohost app install prosody --args "domain=$domain&admin=$admin&language=$language&password=$password" -fi - 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_npm run plugin:install -- --npm-name peertube-plugin-livechat popd diff --git a/scripts/upgrade b/scripts/upgrade index 8cd267c..b5e6c97 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -219,6 +219,8 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st if ! yunohost app list | grep -q "prosody" then yunohost app install prosody --args "domain=$domain&admin=$admin&language=$language&password=$password" +elfi + yunohost app upgrade fi #================================================= From 1a4f04275fb680c0125acbdb54984e7ae49b1b7c Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 6 Feb 2022 02:01:51 +0100 Subject: [PATCH 04/23] Implementing prosody --- scripts/install | 6 +++++- scripts/remove | 25 +++++++++++++++++++++++++ scripts/restore | 6 +++++- scripts/upgrade | 8 +++++--- 4 files changed, 40 insertions(+), 5 deletions(-) diff --git a/scripts/install b/scripts/install index 4badc73..37eff8e 100644 --- a/scripts/install +++ b/scripts/install @@ -93,9 +93,13 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st if ! yunohost app list | grep -q "prosody" then - yunohost app install prosody --args "domain=$domain&admin=$admin&language=$language&password=$password" + yunohost app install prosody --force +else + yunohost app upgrade prosody --force fi +ynh_app_setting_set --app=$app --key=require_prosody --value="1" + #================================================= # CREATE DEDICATED USER #================================================= diff --git a/scripts/remove b/scripts/remove index fc5a63d..b88efa1 100644 --- a/scripts/remove +++ b/scripts/remove @@ -110,6 +110,31 @@ ynh_script_progression --message="Removing 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 + #================================================= # CLOSE A PORT #================================================= diff --git a/scripts/restore b/scripts/restore index ea26709..cbca928 100644 --- a/scripts/restore +++ b/scripts/restore @@ -104,9 +104,13 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st if ! yunohost app list | grep -q "prosody" then - yunohost app install prosody --args "domain=$domain&admin=$admin&language=$language&password=$password" + yunohost app install prosody --force +else + yunohost app upgrade prosody --force fi +ynh_app_setting_set --app=$app --key=require_prosody --value="1" + #================================================= # RESTORE THE POSTGRESQL DATABASE #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index b5e6c97..f96472a 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -218,11 +218,13 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st if ! yunohost app list | grep -q "prosody" then - yunohost app install prosody --args "domain=$domain&admin=$admin&language=$language&password=$password" -elfi - yunohost app upgrade + yunohost app install prosody --force +else + yunohost app upgrade prosody --force fi +ynh_app_setting_set --app=$app --key=require_prosody --value="1" + #================================================= # SPECIFIC UPGRADE #================================================= From f3f8a6533ec19e48d6ec336af5404a42212d4f3a Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 6 Feb 2022 15:30:20 +0100 Subject: [PATCH 05/23] fetch last apps.json --- scripts/install | 6 ++++-- scripts/restore | 6 ++++-- scripts/upgrade | 6 ++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/scripts/install b/scripts/install index 37eff8e..65885a7 100644 --- a/scripts/install +++ b/scripts/install @@ -93,9 +93,11 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st if ! yunohost app list | grep -q "prosody" then - yunohost app install prosody --force + yunohost tools update + yunohost app install prosody else - yunohost app upgrade prosody --force + yunohost tools update + yunohost app upgrade prosody fi ynh_app_setting_set --app=$app --key=require_prosody --value="1" diff --git a/scripts/restore b/scripts/restore index cbca928..08d1ae6 100644 --- a/scripts/restore +++ b/scripts/restore @@ -104,9 +104,11 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st if ! yunohost app list | grep -q "prosody" then - yunohost app install prosody --force + yunohost tools update + yunohost app install prosody else - yunohost app upgrade prosody --force + yunohost tools update + yunohost app upgrade prosody fi ynh_app_setting_set --app=$app --key=require_prosody --value="1" diff --git a/scripts/upgrade b/scripts/upgrade index f96472a..1782ea2 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -218,9 +218,11 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st if ! yunohost app list | grep -q "prosody" then - yunohost app install prosody --force + yunohost tools update + yunohost app install prosody else - yunohost app upgrade prosody --force + yunohost tools update + yunohost app upgrade prosody fi ynh_app_setting_set --app=$app --key=require_prosody --value="1" From 7b0573e657520e5a2e1c5ed55e7f2ffb79dfbdb3 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 8 Feb 2022 01:41:44 +0100 Subject: [PATCH 06/23] Fix logs and .cache too big --- conf/production.yaml | 2 +- scripts/install | 16 ++++++++++------ scripts/remove | 10 ++++++++++ scripts/restore | 9 ++++----- scripts/upgrade | 16 +++++++++++----- 5 files changed, 36 insertions(+), 17 deletions(-) diff --git a/conf/production.yaml b/conf/production.yaml index 275c91f..3910e55 100644 --- a/conf/production.yaml +++ b/conf/production.yaml @@ -88,7 +88,7 @@ storage: videos: '__DATADIR__/videos/' streaming_playlists: '__DATADIR__/streaming-playlists/' redundancy: '__DATADIR__/redundancy/' - logs: '__DATADIR__/logs/' + logs: '/var/log/__APP__/' previews: '__DATADIR__/previews/' thumbnails: '__DATADIR__/thumbnails/' torrents: '__DATADIR__/torrents/' diff --git a/scripts/install b/scripts/install index 65885a7..c0e23e8 100644 --- a/scripts/install +++ b/scripts/install @@ -55,7 +55,6 @@ ynh_script_progression --message="Storing installation settings..." ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=admin --value=$admin -ynh_app_setting_set --app=$app --key=datadir --value=$datadir #================================================= # STANDARD MODIFICATIONS @@ -163,11 +162,13 @@ ynh_add_nginx_config #================================================= ynh_script_progression --message="Creating a data directory..." +ynh_app_setting_set --app=$app --key=datadir --value=$datadir + mkdir -p $datadir -chmod 750 "$datadir/.." -chmod -R o-rwx "$datadir/.." -chown -R $app:www-data "$datadir/.." +chmod 750 "$datadir" +chmod -R o-rwx "$datadir" +chown -R $app:www-data "$datadir" #================================================= # BUILD YARN DEPENDENCIES @@ -177,6 +178,7 @@ ynh_script_progression --message="Building Yarn dependencies..." pushd "$final_path" ynh_use_nodejs ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn install --production --pure-lockfile + ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn cache clean popd #================================================= @@ -207,6 +209,8 @@ ynh_add_systemd_config #================================================= ynh_script_progression --message="Starting a systemd service..." +mkdir -p "/var/log/$app" +chown -R $app:$app "/var/log/$app" # Start a systemd service ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="HTTP server listening on localhost" @@ -253,14 +257,14 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" ynh_script_progression --message="Configuring log rotation..." # Use logrotate to manage application logfile(s) -ynh_use_logrotate --logfile="$datadir/logs/peertube.log" +ynh_use_logrotate #================================================= # 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 +yunohost service add $app --description="$app daemon for Peertube" --log="/var/log/$app/$app.log" --needs_exposed_ports $rtmp_port #================================================= # START SYSTEMD SERVICE diff --git a/scripts/remove b/scripts/remove index b88efa1..e61e3c0 100644 --- a/scripts/remove +++ b/scripts/remove @@ -151,6 +151,16 @@ then ynh_exec_warn_less yunohost firewall disallow TCP $rtmp_port fi +#================================================= +# SPECIFIC REMOVE +#================================================= +# REMOVE VARIOUS FILES +#================================================= +ynh_script_progression --message="Removing various files..." + +# Remove the log files +ynh_secure_remove --file="/var/log/$app" + #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/restore b/scripts/restore index 08d1ae6..d12ada6 100644 --- a/scripts/restore +++ b/scripts/restore @@ -60,7 +60,7 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_script_progression --message="Recreating the dedicated system user..." # Create the dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir=$final_path +ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # RESTORE THE APP MAIN DIR @@ -99,9 +99,6 @@ 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 @@ -143,6 +140,8 @@ systemctl enable $app.service --quiet #================================================= ynh_script_progression --message="Restoring the logrotate configuration..." +mkdir -p "/var/log/$app" +chown -R $app:$app "/var/log/$app" ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= @@ -150,7 +149,7 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= 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 +yunohost service add $app --description="$app daemon for Peertube" --log="/var/log/$app/$app.log" --needs_exposed_ports $rtmp_port #================================================= # START SYSTEMD SERVICE diff --git a/scripts/upgrade b/scripts/upgrade index 1782ea2..83b35b5 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -143,13 +143,18 @@ fi ynh_secure_remove --file="/usr/share/yunohost/hooks/conf_regen/15-nginx_$app" yunohost tools regen-conf nginx +# Remove old log file +ynh_secure_remove --file="$datadir/logs" +mkdir -p "/var/log/$app" +chown -R $app:$app "/var/log/$app" + #================================================= # CREATE DEDICATED USER #================================================= ynh_script_progression --message="Making sure dedicated system user exists..." # Create a dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir=$final_path +ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -236,9 +241,9 @@ ynh_script_progression --message="Creating a data directory..." mkdir -p $datadir -chmod 750 "$datadir/.." -chmod -R o-rwx "$datadir/.." -chown -R $app:www-data "$datadir/.." +chmod 750 "$datadir" +chmod -R o-rwx "$datadir" +chown -R $app:www-data "$datadir" #================================================= # UPDATE A CONFIG FILE @@ -261,6 +266,7 @@ ynh_script_progression --message="Building Yarn dependencies..." pushd "$final_path" ynh_use_nodejs ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn install --production --pure-lockfile + ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn cache clean popd #================================================= @@ -331,7 +337,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" --needs_exposed_ports $rtmp_port +yunohost service add $app --description="$app daemon for Peertube" --log="/var/log/$app/$app.log" --needs_exposed_ports $rtmp_port #================================================= # START SYSTEMD SERVICE From fd4049c7b8669aae7fd8bea3f5dd6389bf6b6f66 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 8 Feb 2022 20:01:12 +0100 Subject: [PATCH 07/23] reduce tests made --- check_process | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/check_process b/check_process index 08c4b32..68a1f9d 100644 --- a/check_process +++ b/check_process @@ -13,13 +13,13 @@ setup_public=1 upgrade=1 # 3.2.1~ynh1 - upgrade=1 from_commit=f4b43fd85ad3a169d27c53865a13548e44f17ebf + # upgrade=1 from_commit=f4b43fd85ad3a169d27c53865a13548e44f17ebf # 3.2.1~ynh4 - upgrade=1 from_commit=08bf3fce3ad99e27e7f7d251838a9f9c63243e44 + # upgrade=1 from_commit=08bf3fce3ad99e27e7f7d251838a9f9c63243e44 # 3.3.0~ynh2 - upgrade=1 from_commit=f3bb02002c8fa28748744302475139b6fcf7c651 + # upgrade=1 from_commit=f3bb02002c8fa28748744302475139b6fcf7c651 # 3.3.0~ynh3 - upgrade=1 from_commit=ed59a268e93910f8b35b0f87399f91b8cad9ede0 + # upgrade=1 from_commit=ed59a268e93910f8b35b0f87399f91b8cad9ede0 # 3.4.0~ynh1 upgrade=1 from_commit=83a06ca4c96ccd941b49647b3698db2c6b771b79 # 4.0.0~ynh1 From fcc85163fbd0d45de6c89db7ad69146e172aa7d3 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Wed, 23 Feb 2022 14:55:14 +0100 Subject: [PATCH 08/23] 4.1.0 --- conf/app.src | 4 ++-- manifest.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/conf/app.src b/conf/app.src index 0f0bceb..a15100e 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/Chocobozzz/PeerTube/releases/download/v4.0.0/peertube-v4.0.0.tar.xz -SOURCE_SUM=afbc6ef1f950cb80fc1b61ef83e27ab25d2c7ec8f605e17bc59f8635848862da +SOURCE_URL=https://github.com/Chocobozzz/PeerTube/releases/download/v4.1.0/peertube-v4.1.0.tar.xz +SOURCE_SUM=4cdb022edb8087dcf2da3de53b450da396e391fe7976c7bb2d4ee021f2894428 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.xz SOURCE_IN_SUBDIR=true diff --git a/manifest.json b/manifest.json index 7235cae..43f5592 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.0.0~ynh2", + "version": "4.1.0~ynh1", "url": "https://github.com/Chocobozzz/PeerTube", "upstream": { "license": "AGPL-3.0-only", From bb5caf350b0fde0dc7a9088e8642441da336157e Mon Sep 17 00:00:00 2001 From: Yunohost-Bot <> Date: Wed, 23 Feb 2022 13:55:22 +0000 Subject: [PATCH 09/23] Auto-update README --- README.md | 2 +- README_fr.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 236647a..c21a78e 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ 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.0.0~ynh2 +**Shipped version:** 4.1.0~ynh1 **Demo:** http://peertube.cpy.re diff --git a/README_fr.md b/README_fr.md index d998376..3f9ec7c 100644 --- a/README_fr.md +++ b/README_fr.md @@ -14,7 +14,7 @@ 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.0.0~ynh2 +**Version incluse :** 4.1.0~ynh1 **Démo :** http://peertube.cpy.re From 35a0e035fdfcc0a1923bd6abf0f3b3504143a14e Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 23 Feb 2022 21:31:50 +0100 Subject: [PATCH 10/23] Update check_process --- check_process | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/check_process b/check_process index 68a1f9d..d64a386 100644 --- a/check_process +++ b/check_process @@ -24,6 +24,8 @@ upgrade=1 from_commit=83a06ca4c96ccd941b49647b3698db2c6b771b79 # 4.0.0~ynh1 upgrade=1 from_commit=7c2bb0bb6a91b6b957b734f684aa3d64da892f4c + # 4.0.0~ynh2 + upgrade=1 from_commit=6995b27972e27c6cf8ee3e1f23a2de5cc8c8e8ee backup_restore=1 multi_instance=0 port_already_use=0 @@ -31,16 +33,3 @@ ;;; Options Email=anmol@datamol.org;yalh@yahoo.com Notification=yes -;;; Upgrade options - ; commit=f4b43fd85ad3a169d27c53865a13548e44f17ebf - name=3.2.1~ynh1 - ; commit=08bf3fce3ad99e27e7f7d251838a9f9c63243e44 - name=3.2.1~ynh4 - ; commit=f3bb02002c8fa28748744302475139b6fcf7c651 - name=3.3.0~ynh2 - ; commit=ed59a268e93910f8b35b0f87399f91b8cad9ede0 - name=3.3.0~ynh3 - ; commit=83a06ca4c96ccd941b49647b3698db2c6b771b79 - name=3.4.0~ynh1 - ; commit=7c2bb0bb6a91b6b957b734f684aa3d64da892f4c - name=4.0.0~ynh1 From 1f64101d6c1391fb8a49c26af2323bb856878bb5 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 24 Feb 2022 19:55:29 +0100 Subject: [PATCH 11/23] remove patches-4.0.0 --- scripts/install | 1 - scripts/upgrade | 1 - .../patches-4.0.0/app-python-in-config.patch | 26 ------------------- 3 files changed, 28 deletions(-) delete mode 100644 sources/patches-4.0.0/app-python-in-config.patch diff --git a/scripts/install b/scripts/install index c0e23e8..cae6d2c 100644 --- a/scripts/install +++ b/scripts/install @@ -140,7 +140,6 @@ ynh_script_progression --message="Setting up source files..." ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src -[ -d "../sources/patches-$(ynh_app_upstream_version)" ] && cp -a "../sources/patches-$(ynh_app_upstream_version)" "../sources/patches" ynh_setup_source --dest_dir="$final_path" chmod 750 "$final_path" diff --git a/scripts/upgrade b/scripts/upgrade index 83b35b5..b55b0fa 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -178,7 +178,6 @@ then ynh_secure_remove --file="$final_path" # Download, check integrity, uncompress and patch the source from app.src - [ -d "../sources/patches-$(ynh_app_upstream_version)" ] && cp -a "../sources/patches-$(ynh_app_upstream_version)" "../sources/patches" ynh_setup_source --dest_dir="$final_path" #Copy the admin saved settings from tmp directory to final path diff --git a/sources/patches-4.0.0/app-python-in-config.patch b/sources/patches-4.0.0/app-python-in-config.patch deleted file mode 100644 index 6a2633c..0000000 --- a/sources/patches-4.0.0/app-python-in-config.patch +++ /dev/null @@ -1,26 +0,0 @@ -diff '--color=auto' -ru ./dist/server/helpers/youtube-dl/youtube-dl-cli.js ./dist/server/helpers/youtube-dl/youtube-dl-cli.js ---- ./dist/server/helpers/youtube-dl/youtube-dl-cli.js 2021-12-13 09:22:44.000000000 +0100 -+++ ./dist/server/helpers/youtube-dl/youtube-dl-cli.js 2022-01-11 22:35:52.992330841 +0100 -@@ -104,7 +104,8 @@ - let completeArgs = this.wrapWithProxyOptions(args); - completeArgs = this.wrapWithIPOptions(completeArgs); - completeArgs = this.wrapWithFFmpegOptions(completeArgs); -- const output = yield (0, execa_1.default)('python', [youtubeDLBinaryPath, ...completeArgs, url], processOptions); -+ const { PYTHON_PATH } = config_1.CONFIG.IMPORT.VIDEOS.HTTP.YOUTUBE_DL_RELEASE; -+ const output = yield (0, execa_1.default)(PYTHON_PATH, [youtubeDLBinaryPath, ...completeArgs, url], processOptions); - logger_1.logger.debug('Runned youtube-dl command.', Object.assign({ command: output.command }, lTags())); - return output.stdout - ? output.stdout.trim().split(/\r?\n/) -diff '--color=auto' -ru ./dist/server/initializers/config.js ./dist/server/initializers/config.js ---- ./dist/server/initializers/config.js 2021-12-13 09:22:43.000000000 +0100 -+++ ./dist/server/initializers/config.js 2022-01-11 22:35:51.812344562 +0100 -@@ -295,7 +295,8 @@ - get ENABLED() { return config.get('import.videos.http.enabled'); }, - YOUTUBE_DL_RELEASE: { - get URL() { return config.get('import.videos.http.youtube_dl_release.url'); }, -- get NAME() { return config.get('import.videos.http.youtube_dl_release.name'); } -+ get NAME() { return config.get('import.videos.http.youtube_dl_release.name'); }, -+ get PYTHON_PATH() { return config.get('import.videos.http.youtube_dl_release.python_path'); } - }, - get FORCE_IPV4() { return config.get('import.videos.http.force_ipv4'); } - }, From abdfabe85104ca6ff249325d082894718309305a Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 9 Mar 2022 23:20:23 +0100 Subject: [PATCH 12/23] Add auto upgrade --- .github/workflows/updater.sh | 133 ++++++++++++++++++++++++++++++++++ .github/workflows/updater.yml | 50 +++++++++++++ manifest.json | 6 +- 3 files changed, 186 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/updater.sh create mode 100644 .github/workflows/updater.yml diff --git a/.github/workflows/updater.sh b/.github/workflows/updater.sh new file mode 100644 index 0000000..b4f3d1e --- /dev/null +++ b/.github/workflows/updater.sh @@ -0,0 +1,133 @@ +#!/bin/bash + +#================================================= +# PACKAGE UPDATING HELPER +#================================================= + +# This script is meant to be run by GitHub Actions +# The YunoHost-Apps organisation offers a template Action to run this script periodically +# Since each app is different, maintainers can adapt its contents so as to perform +# automatic actions when a new upstream release is detected. + +# Remove this exit command when you are ready to run this Action +#exit 1 + +#================================================= +# FETCHING LATEST RELEASE AND ITS ASSETS +#================================================= + +# Fetching information +current_version=$(cat manifest.json | jq -j '.version|split("~")[0]') +repo=$(cat manifest.json | jq -j '.upstream.code|split("https://github.com/")[1]') +# Some jq magic is needed, because the latest upstream release is not always the latest version (e.g. security patches for older versions) +version=$(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '.[] | select( .prerelease != true ) | .tag_name' | sort -V | tail -1) +assets=($(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '[ .[] | select(.tag_name=="'$version'").assets[].browser_download_url ] | join(" ") | @sh' | tr -d "'")) + +# Later down the script, we assume the version has only digits and dots +# Sometimes the release name starts with a "v", so let's filter it out. +# You may need more tweaks here if the upstream repository has different naming conventions. +if [[ ${version:0:1} == "v" || ${version:0:1} == "V" ]]; then + version=${version:1} +fi + +# Setting up the environment variables +echo "Current version: $current_version" +echo "Latest release from upstream: $version" +echo "VERSION=$version" >> $GITHUB_ENV +# For the time being, let's assume the script will fail +echo "PROCEED=false" >> $GITHUB_ENV + +# Proceed only if the retrieved version is greater than the current one +if ! dpkg --compare-versions "$current_version" "lt" "$version" ; then + echo "::warning ::No new version available" + exit 0 +# Proceed only if a PR for this new version does not already exist +elif git ls-remote -q --exit-code --heads https://github.com/$GITHUB_REPOSITORY.git ci-auto-update-v$version ; then + echo "::warning ::A branch already exists for this update" + exit 0 +fi + +# Each release can hold multiple assets (e.g. binaries for different architectures, source code, etc.) +echo "${#assets[@]} available asset(s)" + +#================================================= +# UPDATE SOURCE FILES +#================================================= + +# Here we use the $assets variable to get the resources published in the upstream release. +# Here is an example for Grav, it has to be adapted in accordance with how the upstream releases look like. + +# Let's loop over the array of assets URLs +for asset_url in ${assets[@]}; do + +echo "Handling asset at $asset_url" + +# Assign the asset to a source file in conf/ directory +# Here we base the source file name upon a unique keyword in the assets url (admin vs. update) +# Leave $src empty to ignore the asset +case $asset_url in + *".tar.xz") + src="app" + ;; + *) + src="" + ;; +esac + +# If $src is not empty, let's process the asset +if [ ! -z "$src" ]; then + +# Create the temporary directory +tempdir="$(mktemp -d)" + +# Download sources and calculate checksum +filename=${asset_url##*/} +curl --silent -4 -L $asset_url -o "$tempdir/$filename" +checksum=$(sha256sum "$tempdir/$filename" | head -c 64) + +# Delete temporary directory +rm -rf $tempdir + +# Get extension +if [[ $filename == *.tar.gz ]]; then + extension=tar.gz +else + extension=${filename##*.} +fi + +# Rewrite source file +cat < conf/$src.src +SOURCE_URL=$asset_url +SOURCE_SUM=$checksum +SOURCE_SUM_PRG=sha256sum +SOURCE_FORMAT=$extension +SOURCE_IN_SUBDIR=true +SOURCE_EXTRACT=true +EOT +echo "... conf/$src.src updated" + +else +echo "... asset ignored" +fi + +done + +#================================================= +# SPECIFIC UPDATE STEPS +#================================================= + +# Any action on the app's source code can be done. +# The GitHub Action workflow takes care of committing all changes after this script ends. + +#================================================= +# GENERIC FINALIZATION +#================================================= + +# Replace new version in manifest +echo "$(jq -s --indent 4 ".[] | .version = \"$version~ynh1\"" manifest.json)" > manifest.json + +# No need to update the README, yunohost-bot takes care of it + +# The Action will proceed only if the PROCEED environment variable is set to true +echo "PROCEED=true" >> $GITHUB_ENV +exit 0 diff --git a/.github/workflows/updater.yml b/.github/workflows/updater.yml new file mode 100644 index 0000000..5f1dcc1 --- /dev/null +++ b/.github/workflows/updater.yml @@ -0,0 +1,50 @@ +# This workflow allows GitHub Actions to automagically update your app whenever a new upstream release is detected. +# You need to enable Actions in your repository settings, and fetch this Action from the YunoHost-Apps organization. +# This file should be enough by itself, but feel free to tune it to your needs. +# It calls updater.sh, which is where you should put the app-specific update steps. +name: Check for new upstream releases +on: + # Allow to manually trigger the workflow + workflow_dispatch: + # Run it every day at 6:00 UTC + schedule: + - cron: '0 6 * * *' +jobs: + updater: + runs-on: ubuntu-latest + steps: + - name: Fetch the source code + uses: actions/checkout@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + - name: Run the updater script + id: run_updater + run: | + # Setting up Git user + git config --global user.name 'yunohost-bot' + git config --global user.email 'yunohost-bot@users.noreply.github.com' + # Run the updater script + /bin/bash .github/workflows/updater.sh + - name: Commit changes + id: commit + if: ${{ env.PROCEED == 'true' }} + run: | + git commit -am "Upgrade to v$VERSION" + - name: Create Pull Request + id: cpr + if: ${{ env.PROCEED == 'true' }} + uses: peter-evans/create-pull-request@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + commit-message: Update to version ${{ env.VERSION }} + committer: 'yunohost-bot ' + author: 'yunohost-bot ' + signoff: false + base: testing + branch: ci-auto-update-v${{ env.VERSION }} + delete-branch: true + title: 'Upgrade to version ${{ env.VERSION }}' + body: | + Upgrade to v${{ env.VERSION }} + draft: false + diff --git a/manifest.json b/manifest.json index 43f5592..efdb4d6 100644 --- a/manifest.json +++ b/manifest.json @@ -10,10 +10,10 @@ "url": "https://github.com/Chocobozzz/PeerTube", "upstream": { "license": "AGPL-3.0-only", - "website": "https://joinpeertube.org/fr/", + "website": "https://joinpeertube.org/fr", "demo": "http://peertube.cpy.re", - "admindoc": "https://docs.joinpeertube.org/", - "code": "https://github.com/Chocobozzz/PeerTube/" + "admindoc": "https://docs.joinpeertube.org", + "code": "https://github.com/Chocobozzz/PeerTube" }, "license": "AGPL-3.0-only", "maintainer": [ From 3857827794088ceded1c18fd88c823da2da90684 Mon Sep 17 00:00:00 2001 From: Yunohost-Bot <> Date: Wed, 9 Mar 2022 22:20:30 +0000 Subject: [PATCH 13/23] Auto-update README --- README.md | 6 +++--- README_fr.md | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index c21a78e..9564aad 100644 --- a/README.md +++ b/README.md @@ -64,9 +64,9 @@ 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/ +* 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 diff --git a/README_fr.md b/README_fr.md index 3f9ec7c..7cab961 100644 --- a/README_fr.md +++ b/README_fr.md @@ -58,9 +58,9 @@ 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/ +* 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 From 5d99a720f1bbdfd2d659e414fc3e0eb4793e93fb Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 9 Mar 2022 23:25:17 +0100 Subject: [PATCH 14/23] fix extension --- .github/workflows/updater.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/updater.sh b/.github/workflows/updater.sh index b4f3d1e..3df60ca 100644 --- a/.github/workflows/updater.sh +++ b/.github/workflows/updater.sh @@ -89,8 +89,8 @@ checksum=$(sha256sum "$tempdir/$filename" | head -c 64) rm -rf $tempdir # Get extension -if [[ $filename == *.tar.gz ]]; then - extension=tar.gz +if [[ $filename == *.tar.xz ]]; then + extension=tar.xz else extension=${filename##*.} fi From 1a41b41dd547fcec26942e44bcb893fc8001e47a Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Wed, 9 Mar 2022 22:28:43 +0000 Subject: [PATCH 15/23] Upgrade to v4.1.1 --- conf/app.src | 4 ++-- manifest.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/conf/app.src b/conf/app.src index a15100e..66fc923 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/Chocobozzz/PeerTube/releases/download/v4.1.0/peertube-v4.1.0.tar.xz -SOURCE_SUM=4cdb022edb8087dcf2da3de53b450da396e391fe7976c7bb2d4ee021f2894428 +SOURCE_URL=https://github.com/Chocobozzz/PeerTube/releases/download/v4.1.1/peertube-v4.1.1.tar.xz +SOURCE_SUM=8a8cc31499cad2085ec997c8ae165b5777c89be17bc44d887c364e061d0964b4 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.xz SOURCE_IN_SUBDIR=true diff --git a/manifest.json b/manifest.json index efdb4d6..0749c5f 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.0~ynh1", + "version": "4.1.1~ynh1", "url": "https://github.com/Chocobozzz/PeerTube", "upstream": { "license": "AGPL-3.0-only", @@ -33,7 +33,7 @@ "nginx" ], "arguments": { - "install" : [ + "install": [ { "name": "domain", "type": "domain" From 5dff88320292d7fedda5cb2dd8d1f0b1d415f200 Mon Sep 17 00:00:00 2001 From: Yunohost-Bot <> Date: Wed, 9 Mar 2022 22:28:47 +0000 Subject: [PATCH 16/23] Auto-update README --- README.md | 2 +- README_fr.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9564aad..5bd5915 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ 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.0~ynh1 +**Shipped version:** 4.1.1~ynh1 **Demo:** http://peertube.cpy.re diff --git a/README_fr.md b/README_fr.md index 7cab961..fde0ad6 100644 --- a/README_fr.md +++ b/README_fr.md @@ -14,7 +14,7 @@ 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.0~ynh1 +**Version incluse :** 4.1.1~ynh1 **Démo :** http://peertube.cpy.re From dd79b4abb777cdd833f9b179075c76077b53b97b Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Tue, 7 Jun 2022 21:10:26 +0000 Subject: [PATCH 17/23] Upgrade to v4.2.0 --- conf/app.src | 4 ++-- manifest.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) 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/manifest.json b/manifest.json index 0749c5f..7b2be73 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", From e331252ed683cc9107b311b7ec70fc550d91ecb9 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Tue, 7 Jun 2022 21:10:30 +0000 Subject: [PATCH 18/23] Auto-update README --- README.md | 21 +++++++++++---------- README_fr.md | 27 ++++++++++++++++----------- 2 files changed, 27 insertions(+), 21 deletions(-) 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 :** From 184f4bc3d98972af9170b7b519264fc954f11ead Mon Sep 17 00:00:00 2001 From: Florent Date: Thu, 9 Jun 2022 09:09:57 +0200 Subject: [PATCH 19/23] Update nginx config for v4.2.0 --- conf/nginx.conf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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; From cc362656f463e40c2e0e0c0f81bb9dfdf3b9de14 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 10 Jun 2022 00:45:32 +0200 Subject: [PATCH 20/23] Peertube 4.2.0 migration script --- scripts/upgrade | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/upgrade b/scripts/upgrade index b55b0fa..0efe862 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -313,6 +313,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 #================================================= From 58529042024810871e458d71758ce789155e4efd Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 10 Jun 2022 01:21:56 +0200 Subject: [PATCH 21/23] Apply last example_ynh --- .travis.yml | 7 --- check_process | 5 +- conf/production.yaml | 112 +++++++++++++++++++++++++++++++++++++------ manifest.json | 8 ++-- scripts/_common.sh | 3 +- scripts/install | 37 +++++--------- scripts/remove | 37 ++------------ scripts/restore | 33 +++++-------- scripts/upgrade | 74 +++++++--------------------- scripts/ynh_apps | 110 ++++++++++++++++++++++++++++++++++++++++++ 10 files changed, 259 insertions(+), 167 deletions(-) delete mode 100644 .travis.yml create mode 100644 scripts/ynh_apps 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/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/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 7b2be73..821775e 100644 --- a/manifest.json +++ b/manifest.json @@ -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 0efe862..053fcb3 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 @@ -164,40 +165,24 @@ if [ "$upgrade_type" == "UPGRADE_APP" ] then ynh_script_progression --message="Upgrading source files..." - # Create a temporary directory - tmpdir="$(mktemp -d)" - - # Backup the config file in the temp dir - cp -af "$final_path/config/production.yaml" "$tmpdir/production.yaml" - if [ -s "$final_path/config/local-production.json" ] - then - cp -af "$final_path/config/local-production.json" "$tmpdir/local-production.json" - fi - - # Remove the app directory securely - ynh_secure_remove --file="$final_path" - # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$final_path" - - #Copy the admin saved settings from tmp directory to final path - cp -af "$tmpdir/production.yaml" "$final_path/config/production.yaml" - - if [ -s "$tmpdir/local-production.json" ] - then - cp -af "$tmpdir/local-production.json" "$final_path/config/local-production.json" - else - cp ../conf/local-production.json "$final_path/config/local-production.json" - fi - - # Remove the tmp directory securely - ynh_secure_remove --file="$tmpdir" + ynh_setup_source --dest_dir="$final_path" --keep="config/production.yaml config/local-production.json" fi 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 +191,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 +263,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 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 +} From 0ce7b9064ab79f9d0ee63e9a2f0652999b3f10d7 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 12 Jun 2022 21:25:05 +0200 Subject: [PATCH 22/23] Fix upgrade --- scripts/upgrade | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 053fcb3..1231db6 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -46,6 +46,7 @@ ynh_script_progression --message="Backing up the app before upgrading (may take # Backup the current version of the app ynh_backup_before_upgrade ynh_clean_setup () { + read -p "123" ynh_clean_check_starting # Restore it if the upgrade fails ynh_restore_upgradebackup @@ -165,8 +166,34 @@ if [ "$upgrade_type" == "UPGRADE_APP" ] then ynh_script_progression --message="Upgrading source files..." + # Create a temporary directory + tmpdir="$(mktemp -d)" + + # Backup the config file in the temp dir + cp -af "$final_path/config/production.yaml" "$tmpdir/production.yaml" + if [ -s "$final_path/config/local-production.json" ] + then + cp -af "$final_path/config/local-production.json" "$tmpdir/local-production.json" + fi + + # Remove the app directory securely + ynh_secure_remove --file="$final_path" + # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$final_path" --keep="config/production.yaml config/local-production.json" + ynh_setup_source --dest_dir="$final_path" + + #Copy the admin saved settings from tmp directory to final path + cp -af "$tmpdir/production.yaml" "$final_path/config/production.yaml" + + if [ -s "$tmpdir/local-production.json" ] + then + cp -af "$tmpdir/local-production.json" "$final_path/config/local-production.json" + else + cp ../conf/local-production.json "$final_path/config/local-production.json" + fi + + # Remove the tmp directory securely + ynh_secure_remove --file="$tmpdir" fi chmod 750 "$final_path" From 545902559014ee497d22dd2dd1a35e12d6ceaef2 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 12 Jun 2022 21:25:50 +0200 Subject: [PATCH 23/23] Cleanup --- scripts/upgrade | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 1231db6..07bd954 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -46,7 +46,6 @@ ynh_script_progression --message="Backing up the app before upgrading (may take # Backup the current version of the app ynh_backup_before_upgrade ynh_clean_setup () { - read -p "123" ynh_clean_check_starting # Restore it if the upgrade fails ynh_restore_upgradebackup