1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/peertube_ynh.git synced 2024-09-03 19:56:29 +02:00

Merge pull request #205 from YunoHost-Apps/testing

Apply example_ynh
This commit is contained in:
yalh76 2021-03-07 01:10:45 +01:00 committed by GitHub
commit 5a74f4033e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 108 additions and 130 deletions

View file

@ -72,7 +72,7 @@ Want to see in action?
* Report a bug: https://github.com/YunoHost-Apps/peertube_ynh/issues
* App website: https://joinpeertube.org/fr/
* GitHub App website: https://github.com/Chocobozzz/PeerTube/
* Upstream app repository: https://github.com/Chocobozzz/PeerTube/
* YunoHost website: https://yunohost.org/
---

View file

@ -1,7 +1,7 @@
# PeerTube pour YunoHost
[![Niveau d'intégration](https://dash.yunohost.org/integration/peertube.svg)](https://dash.yunohost.org/appci/app/peertube) ![](https://ci-apps.yunohost.org/ci/badges/peertube.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/peertube.maintain.svg)
[![Installer PeerTube pour YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=peertube)
[![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)*
@ -72,13 +72,13 @@ En regardant une vidéo, vous aidez l'hébergeur à la diffuser en devenant vous
---
## Developer info
## Informations pour les développeurs
Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/peertube_ynh/tree/testing).
Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/peertube_ynh/tree/testing).
To try the testing branch, please proceed like that.
Pour essayer la branche testing, procédez comme suit.
```
sudo yunohost app install https://github.com/YunoHost-Apps/peertube_ynh/tree/testing --debug
or
ou
sudo yunohost app upgrade peertube -u https://github.com/YunoHost-Apps/peertube_ynh/tree/testing --debug
```

View file

@ -37,8 +37,8 @@ database:
hostname: 'localhost'
port: 5432
ssl: false
suffix: '___DB_NAME__'
username: '__DB_NAME__'
suffix: '___APP__'
username: '__DB_USER__'
password: '__DB_PWD__'
pool:
max: 5
@ -203,7 +203,7 @@ cache:
admin:
# Used to generate the root user at first startup
# And to receive emails from the contact form
email: '__EMAIL__'
email: '__ADMIN_EMAIL__'
contact_form:
enabled: true

View file

@ -1,6 +1,6 @@
---
name: Bug report
about: Create a report to help us debug, it would be nice to fill the template as much as you can to help us, help you and help us all.
about: When creating a bug report, please use the following template to provide all the relevant information and help debugging efficiently.
---
@ -9,14 +9,16 @@ about: Create a report to help us debug, it would be nice to fill the template a
2. *Determine if you are on the right place:*
- *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change_url...), you are on the right place!*
- *Otherwise, the issue may be due to PeerTube itself. Refer to its documentation or repository for help.*
- *If you have a doubt, post here, we will figure it out together.*
- *When in doubt, post here and we will figure it out together.*
3. *Delete the italic comments as you write over them below, and remove this guide.*
---
**Describe the bug**
### Describe the bug
*A clear and concise description of what the bug is.*
**Versions**
### Context
- Hardware: *VPS bought online / Old laptop or computer / Raspberry Pi at home / Internet Cube with VPN / Other ARM board / ...*
- YunoHost version: x.x.x
- I have access to my server: *Through SSH | through the webadmin | direct access via keyboard / screen | ...*
@ -25,8 +27,8 @@ about: Create a report to help us debug, it would be nice to fill the template a
- Using, or trying to install package version/branch:
- If upgrading, current package version: *can be found in the admin, or with `yunohost app info $app_id`*
**To Reproduce**
*Steps to reproduce the behavior.*
### Steps to reproduce
- *If you performed a command from the CLI, the command itself is enough. For example:*
```sh
sudo yunohost app install peertube
@ -38,9 +40,16 @@ about: Create a report to help us debug, it would be nice to fill the template a
3. *Scroll down to '...'*
4. *See error*
**Expected behavior**
### Expected behavior
*A clear and concise description of what you expected to happen. You can remove this section if the command above is enough to understand your intent.*
**Logs**
*After a failed command, YunoHost makes the log available to you, but also to others, thanks to `yunohost log display [log name] --share`. The actual command, with the correct log name, is displayed at the end of the failed attempt in the CLI. Execute it and copy here the share link it outputs.*
### Logs
*When an operation fails, YunoHost provides a simple way to share the logs.*
- *In the webadmin, the error message contains a link to the relevant log page. On that page, you will be able to 'Share with Yunopaste'. If you missed it, the logs of previous operations are also available under Tools > Logs.*
- *In command line, the command to share the logs is displayed at the end of the operation and looks like `yunohost log display [log name] --share`. If you missed it, you can find the log ID of a previous operation using `yunohost log list`.*
*After sharing the log, please copypaste directly the link provided by YunoHost (to help readability, no need to copypaste the entire content of the log here, just the link is enough...)*
*If applicable and useful, add screenshots to help explain your problem.*

View file

@ -19,7 +19,7 @@
}
],
"requirements": {
"yunohost": ">= 3.8.1"
"yunohost": ">= 4.1.7.3"
},
"multi_instance": false,
"services": [
@ -37,13 +37,13 @@
"example": "example.com"
},
{
"name": "email",
"type": "string",
"name": "admin",
"type": "user",
"ask": {
"en": "Choose an admin email (can be changed after installation)",
"fr": "Choisissez une adresse e-mail d'administrateur (peut être modifiée après l'installation)"
"en": "Choose an admin user",
"fr": "Choisissez l'administrateur"
},
"example": "johndoe@example.com"
"example": "johndoe"
},
{
"name": "is_public",

View file

@ -13,6 +13,4 @@
## Package_check results
---
*If you have access to [App Continuous Integration for packagers](https://yunohost.org/#/packaging_apps_ci) you can provide a link to the package_check results like below, replacing '-NUM-' in this link by the PR number and USERNAME by your username on the ci-apps-dev. Or you provide a screenshot or a pastebin of the results*
[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/peertube_ynh%20PR-NUM-%20(USERNAME)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/peertube_ynh%20PR-NUM-%20(USERNAME)/)
* An automatic package_check will be launch at https://ci-apps-dev.yunohost.org/, when you add a specific comment to your Pull Request: "!testme", "!gogogadgetoci" or "By the power of systemd, I invoke The Great App CI to test this Pull Request!"*

View file

@ -29,7 +29,7 @@ app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
domain=$(ynh_app_setting_get --app=$app --key=domain)
db_name=$(ynh_app_setting_get --app=$app --key=psql_db)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#=================================================

View file

@ -26,9 +26,10 @@ ynh_abort_if_errors
domain=$YNH_APP_ARG_DOMAIN
path_url="/"
admin_email=$YNH_APP_ARG_EMAIL
admin_pass=$(ynh_string_random --length=24)
admin=$YNH_APP_ARG_ADMIN
is_public=$YNH_APP_ARG_IS_PUBLIC
admin_email=$(ynh_user_get_info --username=$admin --key="mail")
admin_pass=$(ynh_string_random --length=24)
app=$YNH_APP_INSTANCE_NAME
@ -52,9 +53,7 @@ ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
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_email --value=$admin_email
ynh_app_setting_set --app=$app --key=admin_pass --value=$admin_pass
ynh_app_setting_set --app=$app --key=is_public --value=$is_public
ynh_app_setting_set --app=$app --key=admin --value=$admin
ynh_app_setting_set --app=$app --key=datadir --value=$datadir
#=================================================
@ -106,8 +105,8 @@ ynh_script_progression --message="Creating a PostgreSQL database..."
db_name="peertube_${app}"
db_user=$app
db_pwd=$(ynh_string_random --length=30)
ynh_app_setting_set --app=$app --key=psql_db --value=$db_name
ynh_app_setting_set --app=$app --key=psqlpwd --value=$db_pwd
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
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
@ -157,28 +156,9 @@ chown -R "$app":"$app" "$datadir"
#=================================================
ynh_script_progression --message="Modifying a config file..."
config="$final_path/config/production.yaml"
cp ../conf/production.yaml "$config"
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$config"
ynh_replace_string --match_string="__DB_NAME__" --replace_string="$app" --target_file="$config"
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$config"
ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$config"
ynh_replace_string --match_string="__EMAIL__" --replace_string="$admin_email" --target_file="$config"
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$config"
ynh_replace_string --match_string="__DATADIR__" --replace_string="$datadir" --target_file="$config"
ynh_add_config --template="../conf/production.yaml" --destination="$final_path/config/production.yaml"
#Create the admin settings file
local_config="$final_path/config/local-production.json"
cp ../conf/local-production.json "$local_config"
#=================================================
# STORE THE CHECKSUM OF THE CONFIG FILE
#=================================================
ynh_script_progression --message="Storing the config file checksum..."
# Calculate and store the config file checksum into the app settings
ynh_store_file_checksum --file="$config"
ynh_store_file_checksum --file="$local_config"
ynh_add_config --template="../conf/local-production.json" --destination="$final_path/config/local-production.json"
#=================================================
# BUILD YARN DEPENDENCIES
@ -236,15 +216,18 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --l
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Configuring SSOwat..."
ynh_script_progression --message="Configuring permissions..."
# Make app public if necessary
if [ $is_public -eq 1 ]
then
# unprotected_uris allows SSO credentials to be passed anyway.
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
# Everyone can access the app.
# The "main" permission is automatically created before the install script.
ynh_permission_update --permission="main" --add="visitors"
fi
ynh_permission_create --permission="api" --url="/api" --allowed="visitors" --auth_header="false" --show_tile="false" --protected="true"
#=================================================
# RELOAD NGINX
#=================================================
@ -266,13 +249,8 @@ popd
#=================================================
ynh_script_progression --message="Sending a readme for the admin..."
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../conf/message_install"
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="../conf/message_install"
ynh_replace_string --match_string="__PATH_URL__" --replace_string="$path_url" --target_file="../conf/message_install"
ynh_replace_string --match_string="__ADMIN_PASS__" --replace_string="$admin_pass" --target_file="../conf/message_install"
ynh_replace_string --match_string="__RTMP_PORT__" --replace_string="$rtmp_port" --target_file="../conf/message_install"
ynh_send_readme_to_admin --app_message="../conf/message_install" --recipients=$admin_email --type='install'
ynh_add_config --template="../conf/message_install" --destination="../conf/msg_install"
ynh_send_readme_to_admin --app_message="../conf/msg_install" --recipients=$admin_email --type='install'
#=================================================
# END OF SCRIPT

View file

@ -20,11 +20,13 @@ app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
port=$(ynh_app_setting_get --app=$app --key=port)
rtmp_port=$(ynh_app_setting_get --app=$app --key=rtmp_port)
db_name=$(ynh_app_setting_get --app=$app --key=psql_db)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$app
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
admin_email=$(ynh_app_setting_get --app=$app --key=admin_email)
admin=$(ynh_app_setting_get --app=$app --key=admin)
admin_email=$(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)
#=================================================
# STANDARD REMOVE
@ -53,7 +55,7 @@ ynh_remove_systemd_config
ynh_script_progression --message="Removing the PostgreSQL database..."
# Remove a database if it exists, along with the associated user
ynh_psql_remove_db --db_user="$db_user" --db_name="$db_name"
ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
#=================================================
# REMOVE DEPENDENCIES
@ -61,9 +63,8 @@ ynh_psql_remove_db --db_user="$db_user" --db_name="$db_name"
ynh_script_progression --message="Removing dependencies..."
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
ynh_remove_nodejs
ynh_remove_app_dependencies
#=================================================
# REMOVE APP MAIN DIR
@ -120,13 +121,8 @@ ynh_system_user_delete --username=$app
#=================================================
ynh_script_progression --message="Sending a readme for the admin..."
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../conf/message_remove"
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="../conf/message_remove"
ynh_replace_string --match_string="__PATH_URL__" --replace_string="$path_url" --target_file="../conf/message_remove"
ynh_replace_string --match_string="__DATADIR__" --replace_string="$datadir" --target_file="../conf/message_remove"
ynh_replace_string --match_string="__RTMP_PORT__" --replace_string="$rtmp_port" --target_file="../conf/message"
ynh_send_readme_to_admin --app_message="../conf/message_remove" --recipients=$admin_email --type='remove'
ynh_add_config --template="../conf/message_remove" --destination="../conf/msg_remove"
ynh_send_readme_to_admin --app_message="../conf/msg_remove" --recipients=$admin_email --type='remove'
#=================================================
# END OF SCRIPT

View file

@ -32,9 +32,9 @@ path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
port=$(ynh_app_setting_get --app=$app --key=port)
rtmp_port=$(ynh_app_setting_get --app=$app --key=rtmp_port)
db_name=$(ynh_app_setting_get --app=$app --key=psql_db)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$app
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#=================================================

View file

@ -18,14 +18,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)
is_public=$(ynh_app_setting_get --app=$app --key=is_public)
admin_email=$(ynh_app_setting_get --app=$app --key=admin_email)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
port=$(ynh_app_setting_get --app=$app --key=port)
rtmp_port=$(ynh_app_setting_get --app=$app --key=rtmp_port)
db_name=$(ynh_app_setting_get --app=$app --key=psql_db)
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$app
db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
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")
#=================================================
# CHECK VERSION
@ -39,13 +40,19 @@ upgrade_type=$(ynh_check_app_version_changed)
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..."
# Fix is_public as a boolean value
if [ "$is_public" = "Yes" ]; then
ynh_app_setting_set --app=$app --key=is_public --value=1
is_public=1
elif [ "$is_public" = "No" ]; then
ynh_app_setting_set --app=$app --key=is_public --value=0
is_public=0
ynh_app_setting_delete --app=$app --key=admin_pass
ynh_app_setting_delete --app=$app --key=admin_email
# If db_name doesn't exist, create it
if [ -z "$db_name" ]; then
db_name="peertube_${app}"
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
fi
# If db_pwd doesn't exist, create it
if [ -z "$db_pwd" ]; then
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd
fi
if [ -z "$datadir" ];
@ -80,6 +87,18 @@ then
ynh_exec_warn_less yunohost firewall allow TCP $rtmp_port
fi
# Cleaning legacy permissions
if ynh_legacy_permissions_exists; then
ynh_legacy_permissions_delete_all
ynh_app_setting_delete --app=$app --key=is_public
fi
# Create a permission if needed
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
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
@ -212,17 +231,7 @@ chown -R "$app":"$app" "$datadir"
#=================================================
ynh_script_progression --message="Modifying a config file..."
config="$final_path/config/production.yaml"
ynh_backup_if_checksum_is_different --file="$config"
cp ../conf/production.yaml "$config"
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$config"
ynh_replace_string --match_string="__DB_NAME__" --replace_string="$app" --target_file="$config"
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$config"
ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$config"
ynh_replace_string --match_string="__EMAIL__" --replace_string="$admin_email" --target_file="$config"
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$config"
ynh_replace_string --match_string="__DATADIR__" --replace_string="$datadir" --target_file="$config"
ynh_store_file_checksum --file="$config"
ynh_add_config --template="../conf/production.yaml" --destination="$final_path/config/production.yaml"
local_config="$final_path/config/local-production.json"
ynh_backup_if_checksum_is_different --file="$local_config"
@ -280,18 +289,6 @@ ynh_script_progression --message="Starting a systemd service..."
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Server listening on localhost"
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Upgrading SSOwat configuration..."
# Make app public if necessary
if [ $is_public -eq 1 ]
then
# unprotected_uris allows SSO credentials to be passed anyway
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
fi
#=================================================
# RELOAD NGINX
#=================================================