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

Applying example_ynh

This commit is contained in:
yalh76 2020-02-23 19:42:08 +01:00
parent 2bb6445d0c
commit a2149a69cb
7 changed files with 139 additions and 120 deletions

View file

@ -60,7 +60,6 @@ Want to see in action?
* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/peertube%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/peertube/) * x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/peertube%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/peertube/)
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/peertube%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/peertube/) * ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/peertube%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/peertube/)
* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/peertube%20%28Apps%29.svg)](https://ci-stretch.nohost.me/ci/apps/peertube/)
## Links ## Links

View file

@ -4,6 +4,7 @@
alias __FINALPATH__/client/dist/$1; alias __FINALPATH__/client/dist/$1;
} }
# Bypass PeerTube for performance reasons. Could be removed # Bypass PeerTube for performance reasons. Could be removed
location ~ ^/static/(thumbnails|avatars)/ { location ~ ^/static/(thumbnails|avatars)/ {
if ($request_method = 'OPTIONS') { if ($request_method = 'OPTIONS') {
@ -88,8 +89,6 @@
rewrite ^/static/redundancy/(.*)$ /redundancy/$1 break; rewrite ^/static/redundancy/(.*)$ /redundancy/$1 break;
try_files $uri /; try_files $uri /;
} }
# Websocket tracker # Websocket tracker
@ -116,6 +115,3 @@ location /socket.io {
proxy_set_header Upgrade $http_upgrade; proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade"; proxy_set_header Connection "upgrade";
} }

View file

@ -13,6 +13,7 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_print_info --message="Managing script failure..."
ynh_clean_setup () { ynh_clean_setup () {
ynh_clean_check_starting ynh_clean_check_starting
@ -38,7 +39,7 @@ db_name=$(ynh_app_setting_get --app=$app --key=psql_db)
#================================================= #=================================================
ynh_print_info --message="Stopping a systemd service..." ynh_print_info --message="Stopping a systemd service..."
ynh_systemd_action --service_name=$app --action="stop" ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd"
#================================================= #=================================================
# BACKUP THE APP MAIN DIR # BACKUP THE APP MAIN DIR

View file

@ -14,6 +14,7 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_print_info --message="Managing script failure..."
ynh_clean_setup () { ynh_clean_setup () {
ynh_clean_check_starting ynh_clean_check_starting
@ -24,6 +25,7 @@ ynh_abort_if_errors
#================================================= #=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST # RETRIEVE ARGUMENTS FROM THE MANIFEST
#================================================= #=================================================
ynh_print_info --message="Retrieving arguments from the manifest..."
domain=$YNH_APP_ARG_DOMAIN domain=$YNH_APP_ARG_DOMAIN
path_url="/" path_url="/"
@ -61,7 +63,7 @@ ynh_app_setting_set --app=$app --key=is_public --value=$is_public
#================================================= #=================================================
ynh_print_info --message="Configuring firewall..." ynh_print_info --message="Configuring firewall..."
# Find a free port # Find an available port
port=$(ynh_find_port --port=9000) port=$(ynh_find_port --port=9000)
ynh_app_setting_set --app=$app --key=port --value=$port ynh_app_setting_set --app=$app --key=port --value=$port
@ -132,7 +134,7 @@ ynh_system_user_create --username=$app --home_dir=$final_path
#================================================= #=================================================
# CREATE THE DATA DIRECTORY # CREATE THE DATA DIRECTORY
#================================================= #=================================================
ynh_print_info --message="Create the data directory..." ynh_print_info --message="Creating the data directory..."
# Define app's data directory # Define app's data directory
datadir="/home/yunohost.app/${app}/storage" datadir="/home/yunohost.app/${app}/storage"
@ -146,6 +148,7 @@ chown -R "$app":"$app" "$datadir"
#================================================= #=================================================
# MODIFY A CONFIG FILE # MODIFY A CONFIG FILE
#================================================= #=================================================
ynh_print_info --message="Modifying a config file..."
cp ../conf/production.yaml "$final_path/config/production.yaml" cp ../conf/production.yaml "$final_path/config/production.yaml"
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/config/production.yaml" ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/config/production.yaml"
@ -161,6 +164,7 @@ cp ../conf/local-production.json "$final_path/config/local-production.json"
#================================================= #=================================================
# FIX NGINX DOMAIN CONFIGURATION # FIX NGINX DOMAIN CONFIGURATION
#================================================= #=================================================
ynh_print_info --message="Fixing nginx domain configuration..."
cp -R ../conf/nginx_regen_conf.hook /usr/share/yunohost/hooks/conf_regen/15-nginx_$app cp -R ../conf/nginx_regen_conf.hook /usr/share/yunohost/hooks/conf_regen/15-nginx_$app
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="/usr/share/yunohost/hooks/conf_regen/15-nginx_$app" ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="/usr/share/yunohost/hooks/conf_regen/15-nginx_$app"
@ -169,6 +173,7 @@ yunohost tools regen-conf nginx
#================================================= #=================================================
# STORE THE CHECKSUM OF THE CONFIG FILE # STORE THE CHECKSUM OF THE CONFIG FILE
#================================================= #=================================================
ynh_print_info --message="Storing the config file checksum..."
# Calculate and store the config file checksum into the app settings # Calculate and store the config file checksum into the app settings
ynh_store_file_checksum --file="$final_path/config/production.yaml" ynh_store_file_checksum --file="$final_path/config/production.yaml"
@ -177,6 +182,7 @@ ynh_store_file_checksum --file="$final_path/config/local-production.json"
#================================================= #=================================================
# BUILD YARN DEPENDENCIES # BUILD YARN DEPENDENCIES
#================================================= #=================================================
ynh_print_info --message="Building yarn dependencies..."
chown -R "$app":"$app" $final_path chown -R "$app":"$app" $final_path
@ -188,6 +194,7 @@ popd
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
#================================================= #=================================================
ynh_print_info --message="Configuring a systemd service..."
ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/systemd.service" ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/systemd.service"
# Create a dedicated systemd config # Create a dedicated systemd config
@ -198,6 +205,7 @@ ynh_add_systemd_config
#================================================= #=================================================
# SECURE FILES AND DIRECTORIES # SECURE FILES AND DIRECTORIES
#================================================= #=================================================
ynh_print_info --message="Securing files and directories..."
# Set permissions to app files # Set permissions to app files
chown -R "$app":"$app" $final_path chown -R "$app":"$app" $final_path
@ -211,10 +219,10 @@ ynh_print_info --message="Configuring log rotation..."
ynh_use_logrotate --logfile="/home/yunohost.app/${app}/storage/logs/peertube.log" ynh_use_logrotate --logfile="/home/yunohost.app/${app}/storage/logs/peertube.log"
#================================================= #=================================================
# ADVERTISE SERVICE IN ADMIN PANEL # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
ynh_print_info --message="Integrating service in YunoHost..."
# if using yunohost version 3.2 or more in the 'manifest.json', a description can be added
yunohost service add $app --description "$app daemon for Peertube" --log "/home/yunohost.app/${app}/storage/logs/peertube.log" yunohost service add $app --description "$app daemon for Peertube" --log "/home/yunohost.app/${app}/storage/logs/peertube.log"
#================================================= #=================================================
@ -222,6 +230,7 @@ yunohost service add $app --description "$app daemon for Peertube" --log "/home/
#================================================= #=================================================
ynh_print_info --message="Starting a systemd service..." ynh_print_info --message="Starting a systemd service..."
# Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Server listening on localhost" ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Server listening on localhost"
#================================================= #=================================================

View file

@ -27,11 +27,12 @@ admin_email=$(ynh_app_setting_get --app=$app --key=admin_email)
#================================================= #=================================================
# STANDARD REMOVE # STANDARD REMOVE
#================================================= #=================================================
# REMOVE SERVICE FROM ADMIN PANEL # REMOVE SERVICE INTEGRATION IN YUNOHOST
#================================================= #=================================================
ynh_print_info --message="Removing service integration in YunoHost..."
# Remove a service from the admin panel, added by `yunohost service add` # Remove the service from the list of services known by Yunohost (added from `yunohost service add`)
if ynh_exec_warn_less yunohost service status $app >/dev/null 2>&1 if ynh_exec_warn_less yunohost service status $app >/dev/null
then then
ynh_print_info --message="Removing $app service..." ynh_print_info --message="Removing $app service..."
yunohost service remove $app yunohost service remove $app
@ -89,6 +90,7 @@ ynh_remove_logrotate
#================================================= #=================================================
# CLOSE A PORT # CLOSE A PORT
#================================================= #=================================================
ynh_print_info --message="Closing a port..."
if yunohost firewall list | grep -q "\- $port$" if yunohost firewall list | grep -q "\- $port$"
then then
@ -101,6 +103,7 @@ fi
#================================================= #=================================================
# RESTORE ORIGINAL NGINX DOMAIN CONFIGURATION # RESTORE ORIGINAL NGINX DOMAIN CONFIGURATION
#================================================= #=================================================
ynh_print_info --message="Restoring original nginx domain configuration..."
ynh_secure_remove --file="/usr/share/yunohost/hooks/conf_regen/15-nginx_$app" ynh_secure_remove --file="/usr/share/yunohost/hooks/conf_regen/15-nginx_$app"
yunohost tools regen-conf nginx yunohost tools regen-conf nginx

View file

@ -13,6 +13,7 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_print_info --message="Managing script failure..."
ynh_clean_setup () { ynh_clean_setup () {
ynh_clean_check_starting ynh_clean_check_starting
@ -50,6 +51,7 @@ test ! -d $final_path \
#================================================= #=================================================
# RESTORE THE NGINX CONFIGURATION # RESTORE THE NGINX CONFIGURATION
#================================================= #=================================================
ynh_print_info --message="Restoring the nginx configuration..."
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
@ -71,6 +73,7 @@ ynh_system_user_create --username=$app --home_dir=$final_path
#================================================= #=================================================
# RESTORE USER RIGHTS # RESTORE USER RIGHTS
#================================================= #=================================================
ynh_print_info --message="Restoring user rights..."
# Set right permissions # Set right permissions
if [ ! -d "/home/yunohost.app/$app" ]; then if [ ! -d "/home/yunohost.app/$app" ]; then
@ -104,6 +107,7 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st
#================================================= #=================================================
# FIX NGINX DOMAIN CONFIGURATION # FIX NGINX DOMAIN CONFIGURATION
#================================================= #=================================================
ynh_print_info --message="Fixing nginx domain configuration..."
ynh_restore_file --origin_path="/usr/share/yunohost/hooks/conf_regen/15-nginx_$app" ynh_restore_file --origin_path="/usr/share/yunohost/hooks/conf_regen/15-nginx_$app"
yunohost tools regen-conf nginx yunohost tools regen-conf nginx
@ -126,8 +130,9 @@ ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
systemctl enable $app.service systemctl enable $app.service
#================================================= #=================================================
# ADVERTISE SERVICE IN ADMIN PANEL # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
ynh_print_info --message="Integrating service in YunoHost..."
yunohost service add $app --description "$app daemon for Peertube" --log "/home/yunohost.app/${app}/storage/logs/peertube.log" yunohost service add $app --description "$app daemon for Peertube" --log "/home/yunohost.app/${app}/storage/logs/peertube.log"
@ -141,6 +146,7 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --l
#================================================= #=================================================
# RESTORE THE LOGROTATE CONFIGURATION # RESTORE THE LOGROTATE CONFIGURATION
#================================================= #=================================================
ynh_print_info --message="Restoring the logrotate configuration..."
ynh_restore_file --origin_path="/etc/logrotate.d/$app" ynh_restore_file --origin_path="/etc/logrotate.d/$app"

View file

@ -29,6 +29,7 @@ db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
#================================================= #=================================================
# CHECK VERSION # CHECK VERSION
#================================================= #=================================================
ynh_print_info --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed) upgrade_type=$(ynh_check_app_version_changed)
@ -88,7 +89,7 @@ ynh_abort_if_errors
#================================================= #=================================================
ynh_print_info --message="Stopping a systemd service..." ynh_print_info --message="Stopping a systemd service..."
ynh_systemd_action --service_name=$app --action="stop" ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd"
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
@ -163,14 +164,15 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st
#================================================= #=================================================
ynh_print_info --message="Making sure dedicated system user exists..." ynh_print_info --message="Making sure dedicated system user exists..."
# Create a system user # Create a dedicated user (if not existing)
ynh_system_user_create "$app" ynh_system_user_create --username=$app
#================================================= #=================================================
# SPECIFIC UPGRADE # SPECIFIC UPGRADE
#================================================= #=================================================
# MODIFY A CONFIG FILE # MODIFY A CONFIG FILE
#================================================= #=================================================
ynh_print_info --message="Modifying a config file..."
ynh_backup_if_checksum_is_different --file="$final_path/config/local-production.json" ynh_backup_if_checksum_is_different --file="$final_path/config/local-production.json"
ynh_backup_if_checksum_is_different --file="$final_path/config/production.yaml" ynh_backup_if_checksum_is_different --file="$final_path/config/production.yaml"
@ -190,6 +192,7 @@ ynh_store_file_checksum --file="$final_path/config/production.yaml"
#================================================= #=================================================
# FIX NGINX DOMAIN CONFIGURATION # FIX NGINX DOMAIN CONFIGURATION
#================================================= #=================================================
ynh_print_info --message="Fixing nginx domain configuration..."
cp -R ../conf/nginx_regen_conf.hook /usr/share/yunohost/hooks/conf_regen/15-nginx_$app cp -R ../conf/nginx_regen_conf.hook /usr/share/yunohost/hooks/conf_regen/15-nginx_$app
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="/usr/share/yunohost/hooks/conf_regen/15-nginx_$app" ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="/usr/share/yunohost/hooks/conf_regen/15-nginx_$app"
@ -198,6 +201,7 @@ yunohost tools regen-conf nginx
#================================================= #=================================================
# BUILD YARN DEPENDENCIES # BUILD YARN DEPENDENCIES
#================================================= #=================================================
ynh_print_info --message="Building yarn dependencies..."
chown -R "$app":"$app" $final_path chown -R "$app":"$app" $final_path
@ -228,6 +232,7 @@ ynh_add_systemd_config
#================================================= #=================================================
# SECURE FILES AND DIRECTORIES # SECURE FILES AND DIRECTORIES
#================================================= #=================================================
ynh_print_info --message="Securing files and directories..."
# Set permissions on app files # Set permissions on app files
chown -R "$app":"$app" "$final_path" chown -R "$app":"$app" "$final_path"
@ -248,7 +253,7 @@ fi
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_print_info --message="Start $app service..." ynh_print_info --message="Starting a systemd service..."
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Server listening on localhost" ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Server listening on localhost"