From 063a5404691d54b50b88a52addfd5e3d6de5ebd0 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Fri, 17 Apr 2020 12:33:58 +0200 Subject: [PATCH 1/6] Add new badges --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2508de9..b3129e3 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Wordpress for YunoHost -[![Integration level](https://dash.yunohost.org/integration/wordpress.svg)](https://dash.yunohost.org/appci/app/wordpress) +[![Integration level](https://dash.yunohost.org/integration/wordpress.svg)](https://dash.yunohost.org/appci/app/wordpress) ![](https://ci-apps.yunohost.org/ci/badges/wordpress.status.svg) [![](https://ci-apps.yunohost.org/ci/badges/wordpress.maintain.svg)](https://github.com/YunoHost/Apps/#what-to-do-if-i-cant-maintain-my-app-anymore-) [![Install Wordpress with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=wordpress) > *This package allow you to install wordpress quickly and simply on a YunoHost server. From 00a1a6e7dd5c814f5084c11c2810f886a32bdf61 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Fri, 17 Apr 2020 12:34:52 +0200 Subject: [PATCH 2/6] Upgrade to 5.4 --- README.md | 2 +- conf/app.src | 4 ++-- manifest.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b3129e3..414c54f 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to WordPress is open source software you can use to create a beautiful website, blog, or app. With this package, you can even activate the [multisite](https://codex.wordpress.org/Glossary#Multisite) option. -**Shipped version:** 5.3.2 +**Shipped version:** 5.4 ## Screenshots diff --git a/conf/app.src b/conf/app.src index 67ef19e..d28f0a0 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://wordpress.org/wordpress-5.3.2.tar.gz -SOURCE_SUM=ec7fcc299de72d4914a688ea34c96f37 +SOURCE_URL=https://wordpress.org/wordpress-5.4.tar.gz +SOURCE_SUM=28e230c169031b92a4766d1e9cd105e1 SOURCE_SUM_PRG=md5sum ARCH_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/manifest.json b/manifest.json index 8a72e05..7e1b488 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Create a beautiful blog or website easily", "fr": "Logiciel de création de blog ou de site Web" }, - "version": "5.3.2~ynh1", + "version": "5.4~ynh1", "url": "https://wordpress.org/", "license": "GPL-2.0", "maintainer": { From efa92603d78d94d40c997bcd8c7a97d7b29c8d4f Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Fri, 17 Apr 2020 12:36:44 +0200 Subject: [PATCH 3/6] Actions and config_panel tests --- check_process | 13 ++++++++++++ config_panel.toml | 6 ++++++ scripts/actions/public_private | 7 ++++++ scripts/config | 39 +++++++++++++++++++++++++++++----- 4 files changed, 60 insertions(+), 5 deletions(-) diff --git a/check_process b/check_process index ae40e3b..533da94 100644 --- a/check_process +++ b/check_process @@ -6,6 +6,17 @@ language="fr_FR" multisite=0 is_public=1 (PUBLIC|public=1|private=0) + ; Actions + is_public=0|1 + ; Config_panel + main.is_public.is_public=0|1 + main.overwrite_files.overwrite_nginx=0|1 + main.overwrite_files.overwrite_phpfpm=0|1 + main.global_config.email_type=0|1 + main.php_fpm_config.footprint=low|medium|high + main.php_fpm_config.free_footprint=20 + main.php_fpm_config.usage=low|medium|high + main.php_fpm_config.force_max_children=20|0 ; Checks pkg_linter=1 setup_sub_dir=1 @@ -19,6 +30,8 @@ multi_instance=1 port_already_use=0 change_url=1 + actions=1 + config_panel=1 ;; Test avec multisite ; Manifest domain="domain.tld" (DOMAIN) diff --git a/config_panel.toml b/config_panel.toml index 8d62e79..c96a294 100644 --- a/config_panel.toml +++ b/config_panel.toml @@ -60,3 +60,9 @@ name = "Wordpress configuration" 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.
medium: Low usage, few people or/and publicly accessible. Low RAM footprint, medium processor footprint when used.
high: High usage, frequently visited website. High RAM footprint, but lower on processor usage and quickly responding." + + [main.php_fpm_config.force_max_children] + ask = "Force the value of pm.max_children ?" + type = "number" + default = "0" + help = "Do not change this value unless you're sure about what you're doing !
pm.max_children is automatically defined by this formula: $max_ram / 2 / $footprint
You can force that value, and ignore the formula by changing the value here.
To reset to the default value, set to 0." diff --git a/scripts/actions/public_private b/scripts/actions/public_private index 0bb8f36..6615ab9 100755 --- a/scripts/actions/public_private +++ b/scripts/actions/public_private @@ -8,6 +8,13 @@ source /usr/share/yunohost/helpers +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= + +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + #================================================= # RETRIEVE ARGUMENTS #================================================= diff --git a/scripts/config b/scripts/config index af78344..ef235d6 100644 --- a/scripts/config +++ b/scripts/config @@ -16,6 +16,8 @@ source _ynh_add_fpm_config app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID} +fpm_config_dir=$(ynh_app_setting_get --app=$app --key=fpm_config_dir) + #================================================= # LOAD VALUES #================================================= @@ -61,6 +63,14 @@ free_footprint="${YNH_CONFIG_MAIN_PHP_FPM_CONFIG_FREE_FOOTPRINT:-$old_free_footp old_fpm_usage="$(ynh_app_setting_get --app=$app --key=fpm_usage)" fpm_usage="${YNH_CONFIG_MAIN_PHP_FPM_CONFIG_USAGE:-$old_fpm_usage}" +# php_forced_max_children for php-fpm +old_php_forced_max_children="$(ynh_app_setting_get --app=$app --key=php_forced_max_children)" +# If php_forced_max_children isn't into settings.yml, get the current value from the fpm config +if [ -z "$old_php_forced_max_children" ]; then + old_php_forced_max_children="$(grep "^pm.max_children" "$fpm_config_dir/pool.d/$app.conf" | awk '{print $3}')" +fi +php_forced_max_children="${YNH_CONFIG_MAIN_PHP_FPM_CONFIG_FORCE_MAX_CHILDREN:-$old_php_forced_max_children}" + #================================================= # SHOW_CONFIG FUNCTION FOR 'SHOW' COMMAND #================================================= @@ -79,6 +89,7 @@ show_config() { ynh_return "YNH_CONFIG_MAIN_PHP_FPM_CONFIG_FOOTPRINT=$fpm_footprint" ynh_return "YNH_CONFIG_MAIN_PHP_FPM_CONFIG_FREE_FOOTPRINT=$free_footprint" ynh_return "YNH_CONFIG_MAIN_PHP_FPM_CONFIG_USAGE=$fpm_usage" + ynh_return "YNH_CONFIG_MAIN_PHP_FPM_CONFIG_FORCE_MAX_CHILDREN=$php_forced_max_children" } #================================================= @@ -88,11 +99,14 @@ show_config() { apply_config() { # Change public accessibility - if [ "$is_public" = "1" ] + if [ "$is_public" != "$old_is_public" ] then - yunohost app action run $app public_private --args is_public=1 - else - yunohost app action run $app public_private --args is_public=0 + if [ "$is_public" = "1" ] + then + yunohost app action run $app public_private --args is_public=1 + else + yunohost app action run $app public_private --args is_public=0 + fi fi #================================================= @@ -116,7 +130,10 @@ apply_config() { # RECONFIGURE PHP-FPM #================================================= - if [ "$fpm_usage" != "$old_fpm_usage" ] || [ "$fpm_footprint" != "$old_fpm_footprint" ] || [ "$free_footprint" != "$old_free_footprint" ] + if [ "$fpm_usage" != "$old_fpm_usage" ] || \ + [ "$fpm_footprint" != "$old_fpm_footprint" ] || \ + [ "$free_footprint" != "$old_free_footprint" ] || \ + [ "$php_forced_max_children" != "$old_php_forced_max_children" ] then # If fpm_footprint is set to 'specific', use $free_footprint value. if [ "$fpm_footprint" = "specific" ] @@ -124,6 +141,18 @@ apply_config() { fpm_footprint=$free_footprint fi + if [ "$php_forced_max_children" != "$old_php_forced_max_children" ] + then + # Set php_forced_max_children + if [ $php_forced_max_children -ne 0 ] + then + ynh_app_setting_set --app=$app --key=php_forced_max_children --value="$php_forced_max_children" + else + # If the value is set to 0, remove the setting + ynh_app_setting_delete --app=$app --key=php_forced_max_children + fi + fi + if [ "$fpm_footprint" != "0" ] then ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint From 7a0b62eddb134ca905619a1ac7ec83a8db3af618 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Fri, 17 Apr 2020 12:37:54 +0200 Subject: [PATCH 4/6] Misc updates --- README.md | 2 +- check_process | 5 +---- scripts/change_url | 7 ------- scripts/install | 10 ++++++++-- scripts/restore | 8 +++++++- scripts/upgrade | 25 ++++++++++++++++++------- 6 files changed, 35 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 414c54f..5e0b80e 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ Supported, with LDAP and SSO. * x86-64b - [![](https://ci-apps.yunohost.org/ci/logs/wordpress%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/wordpress/) * ARMv8-A - [![](https://ci-apps-arm.yunohost.org/ci/logs/wordpress%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/wordpress/) -* Jessie x86-64b - [![](https://ci-stretch.nohost.me/ci/logs/wordpress%20%28Apps%29.svg)](https://ci-stretch.nohost.me/ci/apps/wordpress/) +* Buster x86-64b - [![](https://ci-buster.nohost.me/ci/logs/wordpress%20%28Apps%29.svg)](https://ci-buster.nohost.me/ci/apps/wordpress/) ## Limitations diff --git a/check_process b/check_process index 533da94..337ce41 100644 --- a/check_process +++ b/check_process @@ -43,19 +43,16 @@ ; Checks setup_sub_dir=1 setup_root=0 - setup_nourl=0 setup_private=1 setup_public=1 upgrade=1 backup_restore=1 multi_instance=1 - port_already_use=0 - change_url=0 ;;; Levels Level 5=auto ;;; Options Email= -Notification=down +Notification=change ;;; Upgrade options ; commit=cbb74263e33deb0ec36f99886a2f773e36d40fd9 name=Upgrade 4.8 diff --git a/scripts/change_url b/scripts/change_url index 3ba81c0..d35f7a7 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -77,13 +77,6 @@ then change_path=1 fi -#================================================= -# MANAGE FAILURE OF THE SCRIPT -#================================================= - -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - #================================================= # STANDARD MODIFICATIONS #================================================= diff --git a/scripts/install b/scripts/install index e66ac45..86945d3 100644 --- a/scripts/install +++ b/scripts/install @@ -117,7 +117,7 @@ else usage=high fi # Create a dedicated php-fpm config -ynh_add_fpm_config --usage=$usage --footprint=$usage +ynh_add_fpm_config --usage=$usage --footprint=medium #================================================= # SPECIFIC SETUP @@ -286,7 +286,13 @@ ynh_secure_remove $final_path/wp-cli.phar # SEND A README FOR THE ADMIN #================================================= -echo "If you're facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/wordpress_ynh" > mail_to_send +# Get main domain and buid the url of the admin panel of the app. +admin_panel="https://$(grep portal_domain /etc/ssowat/conf.json | cut -d'"' -f4)/yunohost/admin/#/apps/$app" + +echo "You can configure this app easily by using the experimental __URL_TAG1__config-panel feature__URL_TAG2__$admin_panel/config-panel__URL_TAG3__. +You can also find some specific actions for this app by using the experimental __URL_TAG1__action feature__URL_TAG2__$admin_panel/actions__URL_TAG3__. + +If you're facing an issue or want to improve this app, please open a new issue in this __URL_TAG1__project__URL_TAG2__https://github.com/YunoHost-Apps/wordpress_ynh__URL_TAG3__." > mail_to_send ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="$admin_wordpress" --type=install diff --git a/scripts/restore b/scripts/restore index dceb28e..f02810a 100644 --- a/scripts/restore +++ b/scripts/restore @@ -131,7 +131,13 @@ ynh_maintenance_mode_OFF # SEND A README FOR THE ADMIN #================================================= -echo "If you're facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/wordpress_ynh" > mail_to_send +# Get main domain and buid the url of the admin panel of the app. +admin_panel="https://$(grep portal_domain /etc/ssowat/conf.json | cut -d'"' -f4)/yunohost/admin/#/apps/$app" + +echo "You can configure this app easily by using the experimental __URL_TAG1__config-panel feature__URL_TAG2__$admin_panel/config-panel__URL_TAG3__. +You can also find some specific actions for this app by using the experimental __URL_TAG1__action feature__URL_TAG2__$admin_panel/actions__URL_TAG3__. + +If you're facing an issue or want to improve this app, please open a new issue in this __URL_TAG1__project__URL_TAG2__https://github.com/YunoHost-Apps/wordpress_ynh__URL_TAG3__." > mail_to_send ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="$admin_wordpress" --type=restore diff --git a/scripts/upgrade b/scripts/upgrade index 55f4667..da9bab3 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -119,7 +119,7 @@ fi # If fpm_footprint doesn't exist, create it if [ -z "$fpm_footprint" ]; then - fpm_footprint=$usage + fpm_footprint=medium ynh_app_setting_set --app=$app --key=fpm_footprint --value=$fpm_footprint fi @@ -223,14 +223,17 @@ ynh_script_progression --message="Configuring multisite..." --weight=2 if [ $multisite -eq 1 ] then ynh_replace_string --match_string="#--MULTISITE--" --replace_string="" --target_file=/etc/nginx/conf.d/$domain.d/$app.conf + + ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.d/$app.conf" + + ynh_systemd_action --service_name=nginx --action=reload + plugin_network="--network" else multisite=0 plugin_network="" - if [ $is_public -eq 0 ] + if [ $is_public -eq 1 ] then - ynh_replace_string --match_string="#--PRIVATE--" --replace_string="" --target_file=/etc/nginx/conf.d/$domain.d/$app.conf - else ynh_replace_string --match_string="//--PUBLIC--define" --replace_string="define" --target_file=$final_path/wp-config.php fi fi @@ -332,10 +335,18 @@ ynh_maintenance_mode_OFF # Get main domain and buid the url of the admin panel of the app. admin_panel="https://$(grep portal_domain /etc/ssowat/conf.json | cut -d'"' -f4)/yunohost/admin/#/apps/$app" -# Build the changelog -ynh_app_changelog || true +# If a html email is required. Apply html to the changelog. +if [ "$admin_mail_html" -eq 1 ]; then + format=html +else + format=plain +fi +ynh_app_changelog --format=$format -echo "If you're facing an issue or want to improve this app, please open a new issue in this __URL_TAG1__project__URL_TAG2__https://github.com/YunoHost-Apps/wordpress_ynh__URL_TAG3__. +echo "You can configure this app easily by using the experimental __URL_TAG1__config-panel feature__URL_TAG2__$admin_panel/config-panel__URL_TAG3__. +You can also find some specific actions for this app by using the experimental __URL_TAG1__action feature__URL_TAG2__$admin_panel/actions__URL_TAG3__. + +If you're facing an issue or want to improve this app, please open a new issue in this __URL_TAG1__project__URL_TAG2__https://github.com/YunoHost-Apps/wordpress_ynh__URL_TAG3__. --- From 10a1fe6bf94a8b2eed2386b614771a51e093d958 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Fri, 17 Apr 2020 12:53:19 +0200 Subject: [PATCH 5/6] New reset actions --- actions.toml | 30 +++++++ scripts/actions/reset_default_app | 128 +++++++++++++++++++++++++++ scripts/actions/reset_default_system | 80 +++++++++++++++++ scripts/backup | 2 +- scripts/restore | 2 +- 5 files changed, 240 insertions(+), 2 deletions(-) create mode 100755 scripts/actions/reset_default_app create mode 100755 scripts/actions/reset_default_system diff --git a/actions.toml b/actions.toml index f10fb3d..b9b966c 100644 --- a/actions.toml +++ b/actions.toml @@ -9,3 +9,33 @@ description = "Change the public access of the app." type = "boolean" ask = "Is it a public app ?" default = true + + +[reset_default_nginx] +name = "Reset the nginx config for this app." +command = "/bin/bash scripts/actions/reset_default_system nginx" +# user = "root" # optional +# cwd = "/" # optional +# accepted_return_codes = [0, 1, 2, 3] # optional +accepted_return_codes = [0] +description = "Reset the nginx config for this app." + + +[reset_default_phpfpm] +name = "Reset the php-fpm config for this app." +command = "/bin/bash scripts/actions/reset_default_system phpfpm" +# user = "root" # optional +# cwd = "/" # optional +# accepted_return_codes = [0, 1, 2, 3] # optional +accepted_return_codes = [0] +description = "Reset the php-fpm config for this app." + + +[reset_default_app] +name = "Reset the app with a default configuration." +command = "/bin/bash scripts/actions/reset_default_app" +# user = "root" # optional +# cwd = "/" # optional +# accepted_return_codes = [0, 1, 2, 3] # optional +accepted_return_codes = [0] +description = "Reset the app to its default configuration to try to fix potential issues.
This action won't remove any data added to the app.
However, if you have modified any configuration, it will be overwritten." diff --git a/scripts/actions/reset_default_app b/scripts/actions/reset_default_app new file mode 100755 index 0000000..bb63459 --- /dev/null +++ b/scripts/actions/reset_default_app @@ -0,0 +1,128 @@ +#!/bin/bash + +#================================================= +# GENERIC STARTING +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source scripts/_common.sh +source /usr/share/yunohost/helpers +source scripts/_ynh_add_fpm_config + +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= + +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + +#================================================= +# RETRIEVE ARGUMENTS +#================================================= + +app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID} + +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) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) + +#================================================= +# SPECIFIC ACTION +#================================================= +# ACTIVATE MAINTENANCE MODE +#================================================= +ynh_script_progression --message="Activating maintenance mode..." + +ynh_maintenance_mode_ON + +#================================================= +# NGINX CONFIGURATION +#================================================= + +ynh_script_progression --message="Upgrading nginx web server configuration..." --weight=1 + +# Create a dedicated nginx config +yunohost app action run $app reset_default_nginx + +#================================================= +# 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 + +#================================================= +# PHP-FPM CONFIGURATION +#================================================= + +ynh_script_progression --message="Upgrading php-fpm configuration..." --weight=2 + +# Create a dedicated php-fpm config +yunohost app action run $app reset_default_phpfpm + +#================================================= +# CREATE A CRON TASK FOR AUTOMATIC UPDATE +#================================================= + +echo "# Reach everyday wp-cron.php?doing_wp_cron to trig the internal wordpress cron. +0 3 * * * root wget -q -O - https://$domain$path_url/wp-cron.php?doing_wp_cron >/dev/null 2>&1" > /etc/cron.d/$app + +#================================================= +# SECURE FILES AND DIRECTORIES +#================================================= + +# Set permissions to app files +# Files have to be own by the user of wordpress. To allow upgrade from the app. +chown -R $app: $final_path +# Except the file config wp-config.php +chown root: $final_path/wp-config.php + +# Reset permissions +find $final_path/ -type f -print0 | xargs -0 chmod 0644 +find $final_path/ -type d -print0 | xargs -0 chmod 0755 + +#================================================= +# UPGRADE FAIL2BAN +#================================================= +ynh_script_progression --message="Reconfiguring fail2ban..." --weight=5 + +# Create a dedicated fail2ban config +ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="PHP message: Leed: wrong login for .* client: " --max_retry=5 + +#================================================= +# SETUP SSOWAT +#================================================= +ynh_script_progression --message="Upgrading SSOwat configuration..." --weight=1 + +# Remove skipped_uris if it's still present +ynh_app_setting_delete --app=$app --key=skipped_uris +if [ $is_public -eq 0 ]; then + # Remove the public access + ynh_app_setting_delete --app=$app --key=unprotected_uris +else + # Or replace skipped_uris by unprotected_uris + ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" +fi + +#================================================= +# RELOAD NGINX +#================================================= +ynh_script_progression --message="Reloading nginx web server..." + +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# DEACTIVE MAINTENANCE MODE +#================================================= +ynh_script_progression --message="Disabling maintenance mode..." + +ynh_maintenance_mode_OFF + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Execution completed" --last diff --git a/scripts/actions/reset_default_system b/scripts/actions/reset_default_system new file mode 100755 index 0000000..1dd2617 --- /dev/null +++ b/scripts/actions/reset_default_system @@ -0,0 +1,80 @@ +#!/bin/bash + +#================================================= +# GENERIC STARTING +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source scripts/_common.sh +source /usr/share/yunohost/helpers +source scripts/_ynh_add_fpm_config + +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= + +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + +#================================================= +# RETRIEVE ARGUMENTS +#================================================= + +app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID} + +type=$1 + +domain=$(ynh_app_setting_get --app=$app --key=domain) +path_url=$(ynh_app_setting_get --app=$app --key=path) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) + +multisite=$(ynh_app_setting_get --app=$app --key=multisite) +is_public=$(ynh_app_setting_get --app=$app --key=is_public) + +#================================================= +# SPECIFIC ACTION +#================================================= +# RESET THE CONFIG FILE +#================================================= + +if [ $type == nginx ]; then + name=Nginx +elif [ $type == phpfpm ]; then + name=PHP-FPM +else + ynh_die --message="The type $type is not recognized" +fi + +ynh_script_progression --message="Resetting the specific configuration of $name for the app $app..." --weight=3 + +if [ $type == nginx ] +then + (cd scripts; ynh_add_nginx_config) + + if [ $multisite -eq 1 ] + then + ynh_replace_string --match_string="#--MULTISITE--" --replace_string="" --target_file=/etc/nginx/conf.d/$domain.d/$app.conf + + ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.d/$app.conf" + + ynh_systemd_action --service_name=nginx --action=reload + fi + +elif [ $type == phpfpm ] +then + # If the app is private, set the usage to low, otherwise to high. + if [ $is_public -eq 0 ] + then + usage=low + else + usage=high + fi + (cd scripts; ynh_add_fpm_config --usage=$usage --footprint=medium) +fi + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Execution completed" --last diff --git a/scripts/backup b/scripts/backup index f98be64..eeea16b 100644 --- a/scripts/backup +++ b/scripts/backup @@ -77,4 +77,4 @@ ynh_backup "/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)." --time --last +ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --last diff --git a/scripts/restore b/scripts/restore index f02810a..616904a 100644 --- a/scripts/restore +++ b/scripts/restore @@ -33,7 +33,7 @@ admin_wordpress=$(ynh_app_setting_get --app=$app --key=admin) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= -ynh_script_progression --message="Validating restoration parameters..." --time --weight=1 +ynh_script_progression --message="Validating restoration parameters..." ynh_webpath_available --domain=$domain --path_url=$path_url \ || ynh_die --message="Path not available: ${domain}${path_url}" From 31d83f858abb7d4bb7dc99ac0cd02acc5bb3a597 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Sun, 19 Apr 2020 00:28:14 +0200 Subject: [PATCH 6/6] Drop YNH_APP_ID --- scripts/actions/public_private | 2 +- scripts/actions/reset_default_app | 2 +- scripts/actions/reset_default_system | 2 +- scripts/config | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/actions/public_private b/scripts/actions/public_private index 6615ab9..397212c 100755 --- a/scripts/actions/public_private +++ b/scripts/actions/public_private @@ -22,7 +22,7 @@ ynh_abort_if_errors # Get is_public is_public=${YNH_ACTION_IS_PUBLIC} -app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID} +app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF ARGUMENTS ARE CORRECT diff --git a/scripts/actions/reset_default_app b/scripts/actions/reset_default_app index bb63459..f4205f6 100755 --- a/scripts/actions/reset_default_app +++ b/scripts/actions/reset_default_app @@ -21,7 +21,7 @@ ynh_abort_if_errors # RETRIEVE ARGUMENTS #================================================= -app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID} +app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) diff --git a/scripts/actions/reset_default_system b/scripts/actions/reset_default_system index 1dd2617..254970f 100755 --- a/scripts/actions/reset_default_system +++ b/scripts/actions/reset_default_system @@ -21,7 +21,7 @@ ynh_abort_if_errors # RETRIEVE ARGUMENTS #================================================= -app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID} +app=$YNH_APP_INSTANCE_NAME type=$1 diff --git a/scripts/config b/scripts/config index ef235d6..3f57515 100644 --- a/scripts/config +++ b/scripts/config @@ -14,7 +14,7 @@ source _ynh_add_fpm_config # RETRIEVE ARGUMENTS #================================================= -app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID} +app=$YNH_APP_INSTANCE_NAME fpm_config_dir=$(ynh_app_setting_get --app=$app --key=fpm_config_dir)