1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/leed_ynh.git synced 2024-09-03 19:26:32 +02:00
This commit is contained in:
ericgaspar 2020-11-25 20:55:09 +01:00
parent 51fcab5500
commit c32a9f4562
No known key found for this signature in database
GPG key ID: 574F281483054D44
14 changed files with 49 additions and 187 deletions

View file

@ -39,9 +39,8 @@ Not supported.
#### Supported architectures
* x86-64b - [![](https://ci-apps.yunohost.org/ci/logs/leed%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/leed/)
* x86-64 - [![](https://ci-apps.yunohost.org/ci/logs/leed%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/leed/)
* ARMv8-A - [![](https://ci-apps-arm.yunohost.org/ci/logs/leed%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/leed/)
* Jessie x86-64b - [![](https://ci-stretch.nohost.me/ci/logs/leed%20%28Apps%29.svg)](https://ci-stretch.nohost.me/ci/apps/leed/)
## Limitations
@ -56,8 +55,7 @@ Not supported.
---
Developers infos
----------------
## Developers infos
Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/leed_ynh/tree/testing).

View file

@ -39,9 +39,8 @@ Non supportée.
#### Architectures supportées.
* x86-64b - [![](https://ci-apps.yunohost.org/ci/logs/leed%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/leed/)
* x86-64 - [![](https://ci-apps.yunohost.org/ci/logs/leed%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/leed/)
* ARMv8-A - [![](https://ci-apps-arm.yunohost.org/ci/logs/leed%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/leed/)
* Jessie x86-64b - [![](https://ci-stretch.nohost.me/ci/logs/leed%20%28Apps%29.svg)](https://ci-stretch.nohost.me/ci/apps/leed/)
## Informations additionnelles
@ -54,8 +53,7 @@ Non supportée.
---
Informations à l'intention des développeurs
----------------
## Informations à l'intention des développeurs
Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/leed_ynh/tree/testing).

View file

@ -14,7 +14,7 @@ location __PATH__/ {
try_files $uri $uri/ index.php;
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock;
fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param REMOTE_USER $remote_user;

View file

@ -8,7 +8,7 @@ name = "Leed configuration"
name = "Public access"
[main.is_public.is_public]
ask = "Is it a public website ?"
ask = "Is it a public website?"
type = "boolean"
default = true
help = "A public Leed will be accessible for third party apps.<br>By turning on 'anonymous readers' in Leed configuration, you can made your feeds public."
@ -18,13 +18,13 @@ name = "Leed configuration"
name = "Overwriting config files"
[main.overwrite_files.overwrite_nginx]
ask = "Overwrite the nginx config file ?"
ask = "Overwrite the nginx config file?"
type = "boolean"
default = true
help = "If the file is overwritten, a backup will be created."
[main.overwrite_files.overwrite_phpfpm]
ask = "Overwrite the php-fpm config file ?"
ask = "Overwrite the php-fpm config file?"
type = "boolean"
default = true
help = "If the file is overwritten, a backup will be created."
@ -34,7 +34,7 @@ name = "Leed configuration"
name = "Global configuration"
[main.global_config.email_type]
ask = "Send HTML email to admin ?"
ask = "Send HTML email to admin?"
type = "boolean"
default = true
help = "Allow app scripts to send HTML mails instead of plain text."
@ -44,19 +44,19 @@ name = "Leed configuration"
name = "PHP-FPM configuration"
[main.php_fpm_config.footprint]
ask = "Memory footprint of the service ?"
ask = "Memory footprint of the service?"
choices = ["low", "medium", "high", "specific"]
default = "low"
help = "low <= 20Mb per pool. medium between 20Mb and 40Mb per pool. high > 40Mb per pool.<br>Use specific to set a value with the following option."
[main.php_fpm_config.free_footprint]
ask = "Memory footprint of the service ?"
ask = "Memory footprint of the service?"
type = "number"
default = "0"
help = "Free field to specify exactly the footprint in Mb if you don't want to use one of the three previous values."
[main.php_fpm_config.usage]
ask = "Expected usage of the service ?"
ask = "Expected usage of the service?"
choices = ["low", "medium", "high"]
default = "low"
help = "low: Personal usage, behind the sso. No RAM footprint when not used, but the impact on the processor can be high if many users are using the service.<br>medium: Low usage, few people or/and publicly accessible. Low RAM footprint, medium processor footprint when used.<br>high: High usage, frequently visited website. High RAM footprint, but lower on processor usage and quickly responding."

View file

@ -3,8 +3,8 @@
"id": "leed",
"packaging_format": 1,
"description": {
"en": "A minimalistic RSS feed aggregator which allows quick and non-intrusive reading of feeds.",
"fr": "Un agrégateur RSS minimaliste qui permet la consultation de flux RSS de manière rapide et non intrusive."
"en": "Minimalistic RSS feed aggregator which allows quick and non-intrusive reading of feeds.",
"fr": "Agrégateur RSS minimaliste qui permet la consultation de flux RSS de manière rapide et non intrusive."
},
"version": "1.8.3~ynh9",
"url": "http://leed.idleman.fr/",
@ -18,7 +18,7 @@
"email": "maniackc_dev@crudelis.fr"
}],
"requirements": {
"yunohost": ">= 3.5"
"yunohost": ">= 3.8.1"
},
"multi_instance": true,
"services": [
@ -79,7 +79,7 @@
"name": "is_public",
"type": "boolean",
"ask": {
"en": "Is it a public website ?",
"en": "Is it a public website?",
"fr": "Est-ce un site public ?"
},
"default": false,

View file

@ -1,9 +1,12 @@
#!/bin/bash
#=================================================
# PERSONAL HELPERS
# COMMON VARIABLES
#=================================================
YNH_PHP_VERSION="7.3"
#=================================================
# BACKUP
#=================================================
@ -69,7 +72,7 @@ ynh_multimedia_build_main_dir () {
local checksum="806a827ba1902d6911095602a9221181"
# Download yunohost.multimedia scripts
wget -nv https://github.com/YunoHost-Apps/yunohost.multimedia/archive/${ynh_media_release}.tar.gz
wget -nv https://github.com/YunoHost-Apps/yunohost.multimedia/archive/${ynh_media_release}.tar.gz 2>&1
# Check the control sum
echo "${checksum} ${ynh_media_release}.tar.gz" | md5sum -c --status \

View file

@ -1,132 +0,0 @@
#!/bin/bash
# Create a dedicated php-fpm config
#
# usage 1: ynh_add_fpm_config [--phpversion=7.X] [--use_template]
# | arg: -v, --phpversion - Version of php to use.
# | arg: -t, --use_template - Use this helper in template mode.
#
# -----------------------------------------------------------------------------
#
# usage 2: ynh_add_fpm_config [--phpversion=7.X] --usage=usage --footprint=footprint
# | arg: -v, --phpversion - Version of php to use.#
# | arg: -f, --footprint - Memory footprint of the service (low/medium/high).
# low - Less than 20Mb of ram by pool.
# medium - Between 20Mb and 40Mb of ram by pool.
# high - More than 40Mb of ram by pool.
# Or specify exactly the footprint, the load of the service as Mb by pool instead of having a standard value.
# To have this value, use the following command and stress the service.
# watch -n0.5 ps -o user,cmd,%cpu,rss -u APP
#
# | arg: -u, --usage - Expected usage of the service (low/medium/high).
# low - Personal usage, behind the sso.
# medium - Low usage, few people or/and publicly accessible.
# high - High usage, frequently visited website.
#
# Requires YunoHost version 2.7.2 or higher.
ynh_add_fpm_config () {
# Declare an array to define the options of this helper.
local legacy_args=vtuf
declare -Ar args_array=( [v]=phpversion= [t]=use_template [u]=usage= [f]=footprint= )
local phpversion
local use_template
local usage
local footprint
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
# The default behaviour is to use the template.
use_template="${use_template:-1}"
usage="${usage:-}"
footprint="${footprint:-}"
if [ -n "$usage" ] || [ -n "$footprint" ]; then
use_template=0
fi
# Configure PHP-FPM 7.0 by default
phpversion="${phpversion:-7.0}"
local fpm_config_dir="/etc/php/$phpversion/fpm"
local fpm_service="php${phpversion}-fpm"
# Configure PHP-FPM 5 on Debian Jessie
if [ "$(ynh_get_debian_release)" == "jessie" ]; then
fpm_config_dir="/etc/php5/fpm"
fpm_service="php5-fpm"
fi
ynh_app_setting_set --app=$app --key=fpm_config_dir --value="$fpm_config_dir"
ynh_app_setting_set --app=$app --key=fpm_service --value="$fpm_service"
finalphpconf="$fpm_config_dir/pool.d/$app.conf"
ynh_backup_if_checksum_is_different --file="$finalphpconf"
if [ $use_template -eq 1 ]
then
# Usage 1, use the template in ../conf/php-fpm.conf
sudo cp ../conf/php-fpm.conf "$finalphpconf"
ynh_replace_string --match_string="__NAMETOCHANGE__" --replace_string="$app" --target_file="$finalphpconf"
ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$finalphpconf"
ynh_replace_string --match_string="__USER__" --replace_string="$app" --target_file="$finalphpconf"
ynh_replace_string --match_string="__PHPVERSION__" --replace_string="$phpversion" --target_file="$finalphpconf"
else
# Store settings
ynh_app_setting_set --app=$app --key=fpm_footprint --value=$footprint
ynh_app_setting_set --app=$app --key=fpm_usage --value=$usage
# Usage 2, generate a php-fpm config file with ynh_get_scalable_phpfpm
ynh_get_scalable_phpfpm --usage=$usage --footprint=$footprint
# Copy the default file
sudo cp "$fpm_config_dir/pool.d/www.conf" "$finalphpconf"
# Replace standard variables into the default file
ynh_replace_string --match_string="^\[www\]" --replace_string="[$app]" --target_file="$finalphpconf"
ynh_replace_string --match_string=".*listen = .*" --replace_string="listen = /var/run/php/php7.0-fpm-$app.sock" --target_file="$finalphpconf"
ynh_replace_string --match_string="^user = .*" --replace_string="user = $app" --target_file="$finalphpconf"
ynh_replace_string --match_string="^group = .*" --replace_string="group = $app" --target_file="$finalphpconf"
ynh_replace_string --match_string=".*chdir = .*" --replace_string="chdir = $final_path" --target_file="$finalphpconf"
# Configure fpm children
ynh_replace_string --match_string=".*pm = .*" --replace_string="pm = $php_pm" --target_file="$finalphpconf"
ynh_replace_string --match_string=".*pm.max_children = .*" --replace_string="pm.max_children = $php_max_children" --target_file="$finalphpconf"
ynh_replace_string --match_string=".*pm.max_requests = .*" --replace_string="pm.max_requests = 500" --target_file="$finalphpconf"
ynh_replace_string --match_string=".*request_terminate_timeout = .*" --replace_string="request_terminate_timeout = 1d" --target_file="$finalphpconf"
if [ "$php_pm" = "dynamic" ]
then
ynh_replace_string --match_string=".*pm.start_servers = .*" --replace_string="pm.start_servers = $php_start_servers" --target_file="$finalphpconf"
ynh_replace_string --match_string=".*pm.min_spare_servers = .*" --replace_string="pm.min_spare_servers = $php_min_spare_servers" --target_file="$finalphpconf"
ynh_replace_string --match_string=".*pm.max_spare_servers = .*" --replace_string="pm.max_spare_servers = $php_max_spare_servers" --target_file="$finalphpconf"
elif [ "$php_pm" = "ondemand" ]
then
ynh_replace_string --match_string=".*pm.process_idle_timeout = .*" --replace_string="pm.process_idle_timeout = 10s" --target_file="$finalphpconf"
fi
# Comment unused parameters
if [ "$php_pm" != "dynamic" ]
then
ynh_replace_string --match_string=".*\(pm.start_servers = .*\)" --replace_string=";\1" --target_file="$finalphpconf"
ynh_replace_string --match_string=".*\(pm.min_spare_servers = .*\)" --replace_string=";\1" --target_file="$finalphpconf"
ynh_replace_string --match_string=".*\(pm.max_spare_servers = .*\)" --replace_string=";\1" --target_file="$finalphpconf"
fi
if [ "$php_pm" != "ondemand" ]
then
ynh_replace_string --match_string=".*\(pm.process_idle_timeout = .*\)" --replace_string=";\1" --target_file="$finalphpconf"
fi
# Concatene the extra config.
if [ -e ../conf/extra_php-fpm.conf ]; then
cat ../conf/extra_php-fpm.conf >> "$finalphpconf"
fi
fi
sudo chown root: "$finalphpconf"
ynh_store_file_checksum --file="$finalphpconf"
if [ -e "../conf/php-fpm.ini" ]
then
echo "Packagers ! Please do not use a separate php ini file, merge your directives in the pool file instead." >&2
finalphpini="$fpm_config_dir/conf.d/20-$app.ini"
ynh_backup_if_checksum_is_different "$finalphpini"
sudo cp ../conf/php-fpm.ini "$finalphpini"
sudo chown root: "$finalphpini"
ynh_store_file_checksum "$finalphpini"
fi
ynh_systemd_action --service_name=$fpm_service --action=reload
}

View file

@ -19,50 +19,46 @@ ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=2
ynh_print_info --message="Loading installation settings..."
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=db_name)
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#=================================================
# STANDARD BACKUP STEPS
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
ynh_print_info --message="Declaring files to be backed up..."
#=================================================
# BACKUP THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Backing up the main app directory..."
CHECK_SIZE "$final_path"
ynh_backup --src_path="$final_path"
#=================================================
# BACKUP NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Backing up nginx web server configuration..."
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# BACKUP PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Backing up php-fpm configuration..."
ynh_backup --src_path="/etc/php/7.0/fpm/pool.d/$app.conf"
ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
#=================================================
# BACKUP THE MYSQL DATABASE
#=================================================
ynh_script_progression --message="Backing up the MySQL database..." --weight=2
ynh_mysql_dump_db --database="$db_name" > db.sql
CHECK_SIZE "db.sql"
#=================================================
# BACKUP FAIL2BAN CONFIGURATION
#=================================================
ynh_script_progression --message="Backing up fail2ban configuration"
ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf"
ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf"
@ -72,7 +68,6 @@ ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf"
#=================================================
# BACKUP THE CRON FILE
#=================================================
ynh_script_progression --message="Backing up cron file"
ynh_backup --src_path="/etc/cron.d/$app"
@ -80,4 +75,4 @@ ynh_backup --src_path="/etc/cron.d/$app"
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --last
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

View file

@ -65,7 +65,7 @@ ynh_abort_if_errors
#=================================================
# MODIFY URL IN NGINX CONF
#=================================================
ynh_script_progression --message="Updating nginx web server configuration..." --weight=2
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=2
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
@ -121,7 +121,7 @@ ynh_mysql_execute_as_root --sql="UPDATE leed_configuration SET value='$domain_pa
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading nginx web server..."
ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --service_name=nginx --action=reload

View file

@ -8,7 +8,6 @@
source _common.sh
source /usr/share/yunohost/helpers
source _ynh_add_fpm_config
#=================================================
# RETRIEVE ARGUMENTS

View file

@ -8,7 +8,6 @@
source _common.sh
source /usr/share/yunohost/helpers
source _ynh_add_fpm_config
#=================================================
# MANAGE FAILURE OF THE SCRIPT
@ -77,9 +76,9 @@ ynh_setup_source --dest_dir="$final_path"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring nginx web server..." --weight=2
ynh_script_progression --message="Configuring NGINX web server..." --weight=2
# Create a dedicated nginx config
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
@ -93,17 +92,18 @@ ynh_system_user_create --username=$app
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring php-fpm..." --weight=2
ynh_script_progression --message="Configuring PHP-FPM..." --weight=2
# Create a dedicated php-fpm config
# Create a dedicated PHP-FPM config
ynh_add_fpm_config --usage=low --footprint=low
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#=================================================
# SPECIFIC SETUP
#=================================================
# SETTING UP WITH CURL
#=================================================
ynh_script_progression --message="Installing Leed with Curl..." --weight=5
ynh_script_progression --message="Installing Leed with cURL..." --weight=5
# Set right permissions for curl install
chown -R $app: $final_path
@ -152,7 +152,7 @@ chown -R $app $final_path/cache $final_path/plugins $final_path/updates
#=================================================
# SETUP FAIL2BAN
#=================================================
ynh_script_progression --message="Configuring fail2ban..." --weight=9
ynh_script_progression --message="Configuring Fail2Ban..." --weight=9
# Create a dedicated fail2ban config
ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="PHP message: Leed: wrong login for .* client: <HOST>" --max_retry=5
@ -175,7 +175,7 @@ fi
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading nginx web server..." --weight=3
ynh_script_progression --message="Reloading NGINX web server..." --weight=3
ynh_systemd_action --service_name=nginx --action=reload

View file

@ -49,15 +49,15 @@ ynh_remove_nginx_config
#=================================================
# REMOVE PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Removing php-fpm configuration..."
ynh_script_progression --message="Removing PHP-FPM configuration..."
# Remove the dedicated php-fpm config
# Remove the dedicated PHP-FPM config
ynh_remove_fpm_config
#=================================================
# REMOVE FAIL2BAN CONFIGURATION
#=================================================
ynh_script_progression --message="Removing fail2ban configuration..." --weight=5
ynh_script_progression --message="Removing Fail2Ban configuration..." --weight=5
# Remove the dedicated fail2ban config
ynh_remove_fail2ban_config

View file

@ -28,6 +28,7 @@ path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
admin=$(ynh_app_setting_get --app=$app --key=admin)
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
@ -82,7 +83,7 @@ ynh_system_user_create --username=$app
# RESTORE THE PHP-FPM CONFIGURATION
#=================================================
ynh_restore_file --origin_path="/etc/php/7.0/fpm/pool.d/$app.conf"
ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
#=================================================
# RESTORE FAIL2BAN CONFIGURATION
@ -114,7 +115,7 @@ chown -R $app $final_path/cache $final_path/plugins $final_path/updates
#=================================================
ynh_script_progression --message="Reloading nginx web server and php-fpm..."
ynh_systemd_action --service_name=php7.0-fpm --action=reload
ynh_systemd_action --service_name=php${phpversion}-fpm --action=reload
ynh_systemd_action --service_name=nginx --action=reload
#=================================================

View file

@ -8,7 +8,6 @@
source _common.sh
source /usr/share/yunohost/helpers
source _ynh_add_fpm_config
#=================================================
# LOAD SETTINGS
@ -31,6 +30,7 @@ admin_mail_html=$(ynh_app_setting_get --app=$app --key=admin_mail_html)
fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint)
fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage)
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#=================================================
# CHECK VERSION
@ -186,7 +186,7 @@ ynh_system_user_create --username=$app
# Overwrite the php-fpm configuration only if it's allowed
if [ $overwrite_phpfpm -eq 1 ]
then
ynh_script_progression --message="Upgrading php-fpm configuration..." --weight=2
ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=2
# Create a dedicated php-fpm config
ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint
fi
@ -226,7 +226,7 @@ chown -R $app $final_path/cache $final_path/plugins $final_path/updates
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Upgrading Leed with curl..." --weight=4
ynh_script_progression --message="Upgrading Leed with cURL..." --weight=4
# Set the app as temporarily public for curl call
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
# Regen SSOwat configuration
@ -240,7 +240,7 @@ fi
#=================================================
# UPGRADE FAIL2BAN
#=================================================
ynh_script_progression --message="Reconfiguring fail2ban..." --weight=8
ynh_script_progression --message="Reconfiguring Fail2Ban..." --weight=8
# Create a dedicated fail2ban config
ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="PHP message: Leed: wrong login for .* client: <HOST>" --max_retry=5