From 00e31fca3ed7e36f8e0feabfe548eb538f33992c Mon Sep 17 00:00:00 2001 From: Thatoo Date: Sun, 17 Mar 2019 13:10:55 +0100 Subject: [PATCH 01/11] Explanation about updates of wordpress core. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 939fd62..abedad6 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ Use the admin panel of your wordpress to configure this app. * Integration with YunoHost users and SSO: * private mode: Blog only accessible by YunoHost users * public mode: Visible by anyone, YunoHost users automatically connected - * Automatic update of wordpress core, plugins and themes + * Automatic update of wordpress core, plugins and themes. This Yunohost package of wordpress needs to be updated from wordpress admin panel, not only from yunohost admin panel. * Allow to set up a [multisite](https://codex.wordpress.org/Glossary#Multisite) instance. #### Multi-users support From f8bd77655ea37ccd96cecce58eb6cc7cd0480626 Mon Sep 17 00:00:00 2001 From: Thatoo Date: Sun, 17 Mar 2019 14:46:43 +0100 Subject: [PATCH 02/11] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index abedad6..66ba37a 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ Use the admin panel of your wordpress to configure this app. * Integration with YunoHost users and SSO: * private mode: Blog only accessible by YunoHost users * public mode: Visible by anyone, YunoHost users automatically connected - * Automatic update of wordpress core, plugins and themes. This Yunohost package of wordpress needs to be updated from wordpress admin panel, not only from yunohost admin panel. + * Automatic update of wordpress core, plugins and themes. * Allow to set up a [multisite](https://codex.wordpress.org/Glossary#Multisite) instance. #### Multi-users support @@ -46,6 +46,7 @@ Supported, with LDAP and SSO. ## Limitations * Multisite only available on subdirectories. +* As the automatic update plugin isn't working as expected, pay attention to keep your wordpress up to date from the wordpress admin panel, and not only from yunohost admin panel. For security reason, you should control that all updates are regularly applied in wordpress admin panel as well as in yunohost admin panel. ## Links From 7bcaf90f1362cedafa8ef5800296b7bf702bb6ff Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Sun, 24 Mar 2019 16:48:36 +0100 Subject: [PATCH 03/11] Update pull_request_template.md --- pull_request_template.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pull_request_template.md b/pull_request_template.md index 08e2e54..9c8c59c 100644 --- a/pull_request_template.md +++ b/pull_request_template.md @@ -19,7 +19,6 @@ - [ ] **Approval (LGTM)** : - [ ] **Approval (LGTM)** : - **CI succeeded** : -[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/wordpress_ynh%20-BRANCH-%20(Official)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/wordpress_ynh%20-BRANCH-%20(Official)/) *Please replace '-BRANCH-' in this link for a PR from a local branch.* -or -[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/wordpress_ynh%20PR-NUM-%20(Official_fork)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/wordpress_ynh%20PR-NUM-%20(Official_fork)/) *Replace '-NUM-' by the PR number in this link for a PR from a forked repository.* +[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/wordpress_ynh%20PR-NUM-/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/wordpress_ynh%20PR-NUM-/) +*Please replace '-NUM-' in this link by the PR number.* When the PR is marked as ready to merge, you have to wait for 3 days before really merging it. From 4613d112ea60096f6f6d3c54da18a2ec61bb3a1a Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Mon, 15 Apr 2019 20:53:48 +0200 Subject: [PATCH 04/11] Move from ci-apps-dev to ci-apps-hq --- pull_request_template.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pull_request_template.md b/pull_request_template.md index 9c8c59c..3ad8883 100644 --- a/pull_request_template.md +++ b/pull_request_template.md @@ -19,6 +19,6 @@ - [ ] **Approval (LGTM)** : - [ ] **Approval (LGTM)** : - **CI succeeded** : -[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/wordpress_ynh%20PR-NUM-/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/wordpress_ynh%20PR-NUM-/) +[![Build Status](https://ci-apps-hq.yunohost.org/jenkins/job/wordpress_ynh%20PR-NUM-/badge/icon)](https://ci-apps-hq.yunohost.org/jenkins/job/wordpress_ynh%20PR-NUM-/) *Please replace '-NUM-' in this link by the PR number.* When the PR is marked as ready to merge, you have to wait for 3 days before really merging it. From 7b0bdf8fb91fbff140a73830150eaf0066d6c459 Mon Sep 17 00:00:00 2001 From: lapineige Date: Sun, 5 May 2019 21:13:00 +0200 Subject: [PATCH 05/11] Add a warant about wordpress risk Fix #30 --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 939fd62..2bdffd5 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,15 @@ Supported, with LDAP and SSO. * Multisite only available on subdirectories. +**Security** + +Please be aware that Wordpress is known for being frequently a source of security risks https://en.wikipedia.org/wiki/WordPress#Vulnerabilities, and also as the most popular (source: https://en.wikipedia.org/wiki/WordPress) website management system it is a target for bots and attackers. +Some vulnerabilities might let an attacker breach into your wordpress, or even your Yunohost server (via privilege escalation). + +Don't forget to comply with good security principles (strong password, frequent updates, don't add unknow code in your theme/extensions…). In particular, *please keep your wordpress as up-to-date as possible*. + +Furthermore, you might take a look at this guide: https://codex.wordpress.org/Hardening_WordPress. You might see some benefits in the use of wordpress security plugins. + ## Links * Report a bug: https://github.com/YunoHost-Apps/wordpress_ynh/issues From b924fea9a19793f0953686463c40ca679639afff Mon Sep 17 00:00:00 2001 From: lapineige Date: Sun, 5 May 2019 21:19:17 +0200 Subject: [PATCH 06/11] fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2bdffd5..02d2420 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ Supported, with LDAP and SSO. **Security** -Please be aware that Wordpress is known for being frequently a source of security risks https://en.wikipedia.org/wiki/WordPress#Vulnerabilities, and also as the most popular (source: https://en.wikipedia.org/wiki/WordPress) website management system it is a target for bots and attackers. +Please be aware that Wordpress is known for being frequently a source of security risks (https://en.wikipedia.org/wiki/WordPress#Vulnerabilities), and also as the most popular website management system it is a target for bots and attackers. Some vulnerabilities might let an attacker breach into your wordpress, or even your Yunohost server (via privilege escalation). Don't forget to comply with good security principles (strong password, frequent updates, don't add unknow code in your theme/extensions…). In particular, *please keep your wordpress as up-to-date as possible*. From 7e4808ebc3318b3b6096729a28260fc936af4e78 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Sun, 12 May 2019 17:31:17 +0200 Subject: [PATCH 07/11] Force upgrade with a cron --- scripts/backup | 6 ++++++ scripts/change_url | 8 ++++++++ scripts/install | 7 +++++++ scripts/remove | 6 ++++++ scripts/restore | 6 ++++++ scripts/upgrade | 7 +++++++ 6 files changed, 40 insertions(+) diff --git a/scripts/backup b/scripts/backup index 827fb07..90086f8 100644 --- a/scripts/backup +++ b/scripts/backup @@ -68,6 +68,12 @@ ynh_script_progression --message="Backup fail2ban configuration" ynh_backup "/etc/fail2ban/jail.d/$app.conf" ynh_backup "/etc/fail2ban/filter.d/$app.conf" +#================================================= +# BACKUP CRON +#================================================= + +ynh_backup "/etc/cron.d/$app" + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/change_url b/scripts/change_url index a96f0a0..30e3250 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -124,6 +124,14 @@ fi ynh_mysql_execute_as_root "UPDATE wp_options SET option_value='$new_domain$new_path' WHERE option_name='siteurl'" $app ynh_mysql_execute_as_root "UPDATE wp_options SET option_value='$new_domain$new_path' WHERE option_name='home'" $app +#================================================= +# UPDATE THE CRON +#================================================= + +ynh_replace_string "$old_domain$old_path" "$new_domain$new_path" +echo "# Reach everyday wp-cron.php?doing_wp_cron to trig the internal wordpress cron. +0 3 * * * root wget -q -O - https:///wp-cron.php?doing_wp_cron >/dev/null 2>&1" > /etc/cron.d/$app + #================================================= # GENERIC FINALISATION #================================================= diff --git a/scripts/install b/scripts/install index 8b42bb6..cebf5f6 100644 --- a/scripts/install +++ b/scripts/install @@ -228,6 +228,13 @@ $wpcli_alias plugin activate wp-fail2ban $plugin_network # Calculate and store the config file checksum into the app settings ynh_store_file_checksum "$final_path/wp-config.php" +#================================================= +# 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 + #================================================= # GENERIC FINALISATION #================================================= diff --git a/scripts/remove b/scripts/remove index e9475ff..cd63b6f 100755 --- a/scripts/remove +++ b/scripts/remove @@ -69,6 +69,12 @@ ynh_script_progression --message="Remove fail2ban configuration" --weight=8 # Remove the dedicated fail2ban config ynh_remove_fail2ban_config +#================================================= +# REMOVE THE CRON +#================================================= + +ynh_secure_remove /etc/cron.d/$app + #================================================= # GENERIC FINALISATION #================================================= diff --git a/scripts/restore b/scripts/restore index 53f6d4f..e5b6150 100644 --- a/scripts/restore +++ b/scripts/restore @@ -103,6 +103,12 @@ ynh_restore_file "/etc/fail2ban/jail.d/$app.conf" ynh_restore_file "/etc/fail2ban/filter.d/$app.conf" ynh_systemd_action --action=restart --service_name=fail2ban +#================================================= +# RESTORE THE CRON +#================================================= + +ynh_restore_file "/etc/cron.d/$app" + #================================================= # GENERIC FINALISATION #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 002e300..2882522 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -200,6 +200,13 @@ $wpcli_alias plugin is-installed http-authentication && $wpcli_alias plugin deac # Recalculate and store the checksum of the file for the next upgrade. ynh_store_file_checksum "$final_path/wp-config.php" +#================================================= +# 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 + #================================================= # GENERIC FINALISATION #================================================= From 21b087ea6ebb499124745384771bfb0ddd866f11 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Sun, 12 May 2019 17:45:06 +0200 Subject: [PATCH 08/11] Upgrade to wordpress 5.2 --- 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 ea65fb2..4d810a1 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.0.3 +**Shipped version:** 5.2 ## Screenshots diff --git a/conf/app.src b/conf/app.src index 97a18a8..2a7d89c 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://wordpress.org/wordpress-5.0.3.tar.gz -SOURCE_SUM=83bec78836aabac08f769d50f1bffe5d +SOURCE_URL=https://wordpress.org/wordpress-5.2.tar.gz +SOURCE_SUM=a45a23290f24ac7779e38a2bc8655344 SOURCE_SUM_PRG=md5sum ARCH_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/manifest.json b/manifest.json index b14392d..e585ab1 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.0.3~ynh1", + "version": "5.2~ynh1", "url": "https://wordpress.org/", "license": "GPL-2.0", "maintainer": { From f93e5381c793b815612116e101dd8a8b4e574867 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Sun, 12 May 2019 20:58:25 +0200 Subject: [PATCH 09/11] Fix cron in change_url --- scripts/change_url | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 30e3250..8731ed3 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -128,9 +128,8 @@ ynh_mysql_execute_as_root "UPDATE wp_options SET option_value='$new_domain$new_p # UPDATE THE CRON #================================================= -ynh_replace_string "$old_domain$old_path" "$new_domain$new_path" echo "# Reach everyday wp-cron.php?doing_wp_cron to trig the internal wordpress cron. -0 3 * * * root wget -q -O - https:///wp-cron.php?doing_wp_cron >/dev/null 2>&1" > /etc/cron.d/$app +0 3 * * * root wget -q -O - https://$new_domain$new_path/wp-cron.php?doing_wp_cron >/dev/null 2>&1" > /etc/cron.d/$app #================================================= # GENERIC FINALISATION From 87e36e665c56dfbe110f44a35a4ccc9724e89a75 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Mon, 20 May 2019 23:00:15 +0200 Subject: [PATCH 10/11] Normalization from example_ynh --- README.md | 8 +- check_process | 10 - conf/nginx.conf | 6 + manifest.json | 9 +- scripts/_common.sh | 447 +++++++++------------------------------------ scripts/backup | 33 ++-- scripts/change_url | 44 ++--- scripts/install | 110 ++++++----- scripts/remove | 29 +-- scripts/restore | 63 +++---- scripts/upgrade | 97 +++++----- 11 files changed, 281 insertions(+), 575 deletions(-) diff --git a/README.md b/README.md index ea65fb2..200ecf0 100644 --- a/README.md +++ b/README.md @@ -39,9 +39,9 @@ Supported, with LDAP and SSO. #### Supported architectures -* x86-64b - [![](https://ci-apps.yunohost.org/ci/logs/wordpress%20%28Official%29.svg)](https://ci-apps.yunohost.org/ci/apps/wordpress/) -* ARMv8-A - [![](https://ci-apps-arm.yunohost.org/ci/logs/wordpress%20%28Official%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/wordpress/) -* Jessie x86-64b - [![](https://ci-stretch.nohost.me/ci/logs/wordpress%20%28Official%29.svg)](https://ci-stretch.nohost.me/ci/apps/wordpress/) +* 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/) ## Limitations @@ -61,6 +61,8 @@ Furthermore, you might take a look at this guide: https://codex.wordpress.org/Ha * Report a bug: https://github.com/YunoHost-Apps/wordpress_ynh/issues * Wordpress website: https://wordpress.org/ + * Wordpress repository: https://core.trac.wordpress.org/browser + https://build.trac.wordpress.org/browser * YunoHost website: https://yunohost.org/ --- diff --git a/check_process b/check_process index 6bff7bc..a039cd8 100644 --- a/check_process +++ b/check_process @@ -41,17 +41,7 @@ port_already_use=0 change_url=0 ;;; Levels - Level 1=auto - Level 2=auto - Level 3=auto -# Level 4: https://github.com/YunoHost-Apps/wordpress_ynh/blob/master/conf/sql/single.sql#L1 - Level 4=1 Level 5=auto - Level 6=auto - Level 7=auto - Level 8=0 - Level 9=0 - Level 10=0 ;;; Options Email= Notification=down diff --git a/conf/nginx.conf b/conf/nginx.conf index e89b0b7..e8651d1 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -6,15 +6,21 @@ #sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; location __PATH__/ { + + # Path to source alias __FINALPATH__/; + index index.php; if (!-e $request_filename) { rewrite ^(.+)$ __PATH__/index.php?q=$1 last; } + + # Force usage of https if ($scheme = http) { rewrite ^ https://$server_name$request_uri? permanent; } + client_max_body_size 30m; location ~ [^/]\.php(/|$) { fastcgi_split_path_info ^(.+?\.php)(/.*)$; diff --git a/manifest.json b/manifest.json index b14392d..0f1dce1 100644 --- a/manifest.json +++ b/manifest.json @@ -14,7 +14,7 @@ "email": "maniackc_dev@crudelis.fr" }, "requirements": { - "yunohost": ">= 3.4" + "yunohost": ">= 3.5" }, "multi_instance": true, "services": [ @@ -54,6 +54,7 @@ }, { "name": "language", + "type": "string", "ask": { "en": "Choose the language of the WordPress site", "fr": "Choissisez la langue du WordPress" @@ -77,7 +78,11 @@ "en": "Is it a public WordPress site ?", "fr": "Est-ce un site public ?" }, - "default": true + "default": true, + "help": { + "en": "A public wordpress will be publicly visible for everyone. If you're looking for a public blog, you should choose to install a public wordpress.", + "fr": "Un wordpress public sera visible publiquement pour tous. Si vous recherchez un blog public, vous devriez choisir d'installer un wordpress public." + } } ] } diff --git a/scripts/_common.sh b/scripts/_common.sh index 0d215d5..d3a9c43 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -22,382 +22,35 @@ CHECK_SIZE () { # Vérifie avant chaque backup que l'espace est suffisant fi } -#================================================= -# FUTUR OFFICIAL HELPERS -#================================================= - -# Create a dedicated fail2ban config (jail and filter conf files) -# -# usage: ynh_add_fail2ban_config log_file filter [max_retry [ports]] -# | arg: -l, --logpath= - Log file to be checked by fail2ban -# | arg: -r, --failregex= - Failregex to be looked for by fail2ban -# | arg: -m, --max_retry= - Maximum number of retries allowed before banning IP address - default: 3 -# | arg: -p, --ports= - Ports blocked for a banned IP address - default: http,https -ynh_add_fail2ban_config () { - # Declare an array to define the options of this helper. - declare -Ar args_array=( [l]=logpath= [r]=failregex= [m]=max_retry= [p]=ports= ) - local logpath - local failregex - local max_retry - local ports - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - max_retry=${max_retry:-3} - ports=${ports:-http,https} - - test -n "$logpath" || ynh_die "ynh_add_fail2ban_config expects a logfile path as first argument and received nothing." - test -n "$failregex" || ynh_die "ynh_add_fail2ban_config expects a failure regex as second argument and received nothing." - - finalfail2banjailconf="/etc/fail2ban/jail.d/$app.conf" - finalfail2banfilterconf="/etc/fail2ban/filter.d/$app.conf" - ynh_backup_if_checksum_is_different "$finalfail2banjailconf" 1 - ynh_backup_if_checksum_is_different "$finalfail2banfilterconf" 1 - - tee $finalfail2banjailconf <&2 - echo "WARNING${fail2ban_error#*WARNING}" >&2 - fi -} - -# Remove the dedicated fail2ban config (jail and filter conf files) -# -# usage: ynh_remove_fail2ban_config -ynh_remove_fail2ban_config () { - ynh_secure_remove "/etc/fail2ban/jail.d/$app.conf" - ynh_secure_remove "/etc/fail2ban/filter.d/$app.conf" - if [ "$(lsb_release --codename --short)" != "jessie" ]; then - systemctl reload fail2ban - else - systemctl restart fail2ban - fi -} - -#================================================= - -# Read the value of a key in a ynh manifest file -# -# usage: ynh_read_manifest manifest key -# | arg: -m, --manifest= - Path of the manifest to read -# | arg: -k, --key= - Name of the key to find -ynh_read_manifest () { - # Declare an array to define the options of this helper. - declare -Ar args_array=( [m]=manifest= [k]=manifest_key= ) - local manifest - local manifest_key - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - - python3 -c "import sys, json;print(json.load(open('$manifest', encoding='utf-8'))['$manifest_key'])" -} - -# Read the upstream version from the manifest -# The version number in the manifest is defined by ~ynh -# For example : 4.3-2~ynh3 -# This include the number before ~ynh -# In the last example it return 4.3-2 -# -# usage: ynh_app_upstream_version [-m manifest] -# | arg: -m, --manifest= - Path of the manifest to read -ynh_app_upstream_version () { - declare -Ar args_array=( [m]=manifest= ) - local manifest - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - - manifest="${manifest:-../manifest.json}" - if [ ! -e "$manifest" ]; then - manifest="../settings/manifest.json" # Into the restore script, the manifest is not at the same place - fi - version_key=$(ynh_read_manifest --manifest="$manifest" --manifest_key="version") - echo "${version_key/~ynh*/}" -} - -# Read package version from the manifest -# The version number in the manifest is defined by ~ynh -# For example : 4.3-2~ynh3 -# This include the number after ~ynh -# In the last example it return 3 -# -# usage: ynh_app_package_version [-m manifest] -# | arg: -m, --manifest= - Path of the manifest to read -ynh_app_package_version () { - declare -Ar args_array=( [m]=manifest= ) - local manifest - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - - manifest="${manifest:-../manifest.json}" - if [ ! -e "$manifest" ]; then - manifest="../settings/manifest.json" # Into the restore script, the manifest is not at the same place - fi - version_key=$(ynh_read_manifest --manifest="$manifest" --manifest_key="version") - echo "${version_key/*~ynh/}" -} - -# Checks the app version to upgrade with the existing app version and returns: -# - UPGRADE_APP if the upstream app version has changed -# - UPGRADE_PACKAGE if only the YunoHost package has changed -# -## It stops the current script without error if the package is up-to-date -# -# This helper should be used to avoid an upgrade of an app, or the upstream part -# of it, when it's not needed -# -# To force an upgrade, even if the package is up to date, -# you have to set the variable YNH_FORCE_UPGRADE before. -# example: sudo YNH_FORCE_UPGRADE=1 yunohost app upgrade MyApp -# -# usage: ynh_check_app_version_changed -ynh_check_app_version_changed () { - local force_upgrade=${YNH_FORCE_UPGRADE:-0} - local package_check=${PACKAGE_CHECK_EXEC:-0} - - # By default, upstream app version has changed - local return_value="UPGRADE_APP" - - local current_version=$(ynh_read_manifest --manifest="/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json" --manifest_key="version" || echo 1.0) - local current_upstream_version="$(ynh_app_upstream_version --manifest="/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json")" - local update_version=$(ynh_read_manifest --manifest="../manifest.json" --manifest_key="version" || echo 1.0) - local update_upstream_version="$(ynh_app_upstream_version)" - - if [ "$current_version" == "$update_version" ] ; then - # Complete versions are the same - if [ "$force_upgrade" != "0" ] - then - echo "Upgrade forced by YNH_FORCE_UPGRADE." >&2 - unset YNH_FORCE_UPGRADE - elif [ "$package_check" != "0" ] - then - echo "Upgrade forced for package check." >&2 - else - ynh_die "Up-to-date, nothing to do" 0 - fi - elif [ "$current_upstream_version" == "$update_upstream_version" ] ; then - # Upstream versions are the same, only YunoHost package versions differ - return_value="UPGRADE_PACKAGE" - fi - echo $return_value -} - -#================================================= - -# Start (or other actions) a service, print a log in case of failure and optionnaly wait until the service is completely started -# -# usage: ynh_systemd_action [-n service_name] [-a action] [ [-l "line to match"] [-p log_path] [-t timeout] [-e length] ] -# | arg: -n, --service_name= - Name of the service to reload. Default : $app -# | arg: -a, --action= - Action to perform with systemctl. Default: start -# | arg: -l, --line_match= - Line to match - The line to find in the log to attest the service have finished to boot. -# If not defined it don't wait until the service is completely started. -# | arg: -p, --log_path= - Log file - Path to the log file. Default : /var/log/$app/$app.log -# | arg: -t, --timeout= - Timeout - The maximum time to wait before ending the watching. Default : 300 seconds. -# | arg: -e, --length= - Length of the error log : Default : 20 -ynh_systemd_action() { - # Declare an array to define the options of this helper. - declare -Ar args_array=( [n]=service_name= [a]=action= [l]=line_match= [p]=log_path= [t]=timeout= [e]=length= ) - local service_name - local action - local line_match - local length - local log_path - local timeout - - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - - local service_name="${service_name:-$app}" - local action=${action:-start} - local log_path="${log_path:-/var/log/$service_name/$service_name.log}" - local length=${length:-20} - local timeout=${timeout:-300} - - # Start to read the log - if [[ -n "${line_match:-}" ]] - then - local templog="$(mktemp)" - # Following the starting of the app in its log - if [ "$log_path" == "systemd" ] ; then - # Read the systemd journal - journalctl -u $service_name -f --since=-45 > "$templog" & - else - # Read the specified log file - tail -F -n0 "$log_path" > "$templog" & - fi - # Get the PID of the tail command - local pid_tail=$! - fi - - echo "${action^} the service $service_name" >&2 - systemctl $action $service_name \ - || ( journalctl --lines=$length -u $service_name >&2 \ - ; test -n "$log_path" && echo "--" && tail --lines=$length "$log_path" >&2 \ - ; false ) - - # Start the timeout and try to find line_match - if [[ -n "${line_match:-}" ]] - then - local i=0 - for i in $(seq 1 $timeout) - do - # Read the log until the sentence is found, that means the app finished to start. Or run until the timeout - if grep --quiet "$line_match" "$templog" - then - echo "The service $service_name has correctly started." >&2 - break - fi - echo -n "." >&2 - sleep 1 - done - if [ $i -eq $timeout ] - then - echo "The service $service_name didn't fully started before the timeout." >&2 - echo "Please find here an extract of the end of the log of the service $service_name:" - journalctl --lines=$length -u $service_name >&2 - test -n "$log_path" && echo "--" && tail --lines=$length "$log_path" >&2 - fi - - echo "" - ynh_clean_check_starting - fi -} - -# Clean temporary process and file used by ynh_check_starting -# (usually used in ynh_clean_setup scripts) -# -# usage: ynh_clean_check_starting -ynh_clean_check_starting () { - # Stop the execution of tail. - kill -s 15 $pid_tail 2>&1 - ynh_secure_remove "$templog" 2>&1 -} - #================================================= # EXPERIMENTAL HELPERS #================================================= -# Print a message as INFO and show progression during an app script -# -# usage: ynh_script_progression --message=message [--weight=weight] [--time] -# | arg: -m, --message= - The text to print -# | arg: -w, --weight= - The weight for this progression. This value is 1 by default. Use a bigger value for a longer part of the script. -# | arg: -t, --time= - Print the execution time since the last call to this helper. Especially usefull to define weights. -# | arg: -l, --last= - Use for the last call of the helper, to fill te progression bar. -increment_progression=0 -previous_weight=0 -# Define base_time when the file is sourced -base_time=$(date +%s) -ynh_script_progression () { - # Declare an array to define the options of this helper. - declare -Ar args_array=( [m]=message= [w]=weight= [t]=time [l]=last ) - local message - local weight - local time - local last - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - weight=${weight:-1} - time=${time:-0} - last=${last:-0} - - # Get execution time since the last $base_time - local exec_time=$(( $(date +%s) - $base_time )) - base_time=$(date +%s) - - # Get the number of occurrences of 'ynh_script_progression' in the script. Except those are commented. - local helper_calls="$(grep --count "^[^#]*ynh_script_progression" $0)" - # Get the number of call with a weight value - local weight_calls=$(grep --perl-regexp --count "^[^#]*ynh_script_progression.*(--weight|-w )" $0) - - # Get the weight of each occurrences of 'ynh_script_progression' in the script using --weight - local weight_valuesA="$(grep --perl-regexp "^[^#]*ynh_script_progression.*--weight" $0 | sed 's/.*--weight[= ]\([[:digit:]].*\)/\1/g')" - # Get the weight of each occurrences of 'ynh_script_progression' in the script using -w - local weight_valuesB="$(grep --perl-regexp "^[^#]*ynh_script_progression.*-w " $0 | sed 's/.*-w[= ]\([[:digit:]].*\)/\1/g')" - # Each value will be on a different line. - # Remove each 'end of line' and replace it by a '+' to sum the values. - local weight_values=$(( $(echo "$weight_valuesA" | tr '\n' '+') + $(echo "$weight_valuesB" | tr '\n' '+') 0 )) - - # max_progression is a total number of calls to this helper. - # Less the number of calls with a weight value. - # Plus the total of weight values - local max_progression=$(( $helper_calls - $weight_calls + $weight_values )) - - # Increment each execution of ynh_script_progression in this script by the weight of the previous call. - increment_progression=$(( $increment_progression + $previous_weight )) - # Store the weight of the current call in $previous_weight for next call - previous_weight=$weight - - # Set the scale of the progression bar - local scale=20 - # progress_string(1,2) should have the size of the scale. - local progress_string1="####################" - local progress_string0="...................." - - # Reduce $increment_progression to the size of the scale - if [ $last -eq 0 ] - then - local effective_progression=$(( $increment_progression * $scale / $max_progression )) - # If last is specified, fill immediately the progression_bar - else - local effective_progression=$scale - fi - - # Build $progression_bar from progress_string(1,2) according to $effective_progression - local progression_bar="${progress_string1:0:$effective_progression}${progress_string0:0:$(( $scale - $effective_progression ))}" - - local print_exec_time="" - if [ $time -eq 1 ] - then - print_exec_time=" [$(date +%Hh%Mm,%Ss --date="0 + $exec_time sec")]" - fi - - ynh_print_info "[$progression_bar] > ${message}${print_exec_time}" -} - -#================================================= - # Send an email to inform the administrator # -# usage: ynh_send_readme_to_admin app_message [recipients] -# | arg: -m --app_message= - The message to send to the administrator. +# usage: ynh_send_readme_to_admin --app_message=app_message [--recipients=recipients] [--type=type] +# | arg: -m --app_message= - The file with the content to send to the administrator. # | arg: -r, --recipients= - The recipients of this email. Use spaces to separate multiples recipients. - default: root # example: "root admin@domain" # If you give the name of a YunoHost user, ynh_send_readme_to_admin will find its email adress for you # example: "root admin@domain user1 user2" +# | arg: -t, --type= - Type of mail, could be 'backup', 'change_url', 'install', 'remove', 'restore', 'upgrade' ynh_send_readme_to_admin() { # Declare an array to define the options of this helper. - declare -Ar args_array=( [m]=app_message= [r]=recipients= ) + declare -Ar args_array=( [m]=app_message= [r]=recipients= [t]=type= ) local app_message local recipients + local type # Manage arguments with getopts + ynh_handle_getopts_args "$@" - local app_message="${app_message:-...No specific information...}" - local recipients="${recipients:-root}" + app_message="${app_message:-}" + recipients="${recipients:-root}" + type="${type:-install}" + + # Get the value of admin_mail_html + admin_mail_html=$(ynh_app_setting_get $app admin_mail_html) + admin_mail_html="${admin_mail_html:-0}" # Retrieve the email of users find_mails () { @@ -423,18 +76,75 @@ ynh_send_readme_to_admin() { } recipients=$(find_mails "$recipients") - local mail_subject="☁️🆈🅽🅷☁️: \`$app\` was just installed!" + # Subject base + local mail_subject="☁️🆈🅽🅷☁️: \`$app\`" + + # Adapt the subject according to the type of mail required. + if [ "$type" = "backup" ]; then + mail_subject="$mail_subject has just been backup." + elif [ "$type" = "change_url" ]; then + mail_subject="$mail_subject has just been moved to a new URL!" + elif [ "$type" = "remove" ]; then + mail_subject="$mail_subject has just been removed!" + elif [ "$type" = "restore" ]; then + mail_subject="$mail_subject has just been restored!" + elif [ "$type" = "upgrade" ]; then + mail_subject="$mail_subject has just been upgraded!" + else # install + mail_subject="$mail_subject has just been installed!" + fi local mail_message="This is an automated message from your beloved YunoHost server. Specific information for the application $app. -$app_message +$(if [ -n "$app_message" ] +then + cat "$app_message" +else + echo "...No specific information..." +fi) --- Automatic diagnosis data from YunoHost -$(yunohost tools diagnosis | grep -B 100 "services:" | sed '/services:/d')" +__PRE_TAG1__$(yunohost tools diagnosis | grep -B 100 "services:" | sed '/services:/d')__PRE_TAG2__" + + # Store the message into a file for further modifications. + echo "$mail_message" > mail_to_send + + # If a html email is required. Apply html tags to the message. + if [ "$admin_mail_html" -eq 1 ] + then + # Insert 'br' tags at each ending of lines. + ynh_replace_string "$" "
" mail_to_send + + # Insert starting HTML tags + sed --in-place '1s@^@\n\n\n\n@' mail_to_send + + # Keep tabulations + ynh_replace_string " " "\ \ " mail_to_send + ynh_replace_string "\t" "\ \ " mail_to_send + + # Insert url links tags + ynh_replace_string "__URL_TAG1__\(.*\)__URL_TAG2__\(.*\)__URL_TAG3__" "\1" mail_to_send + + # Insert pre tags + ynh_replace_string "__PRE_TAG1__" "
" mail_to_send
+		ynh_replace_string "__PRE_TAG2__" "<\pre>" mail_to_send
+
+		# Insert finishing HTML tags
+		echo -e "\n\n" >> mail_to_send
+
+	# Otherwise, remove tags to keep a plain text.
+	else
+		# Remove URL tags
+		ynh_replace_string "__URL_TAG[1,3]__" "" mail_to_send
+		ynh_replace_string "__URL_TAG2__" ": " mail_to_send
+
+		# Remove PRE tags
+		ynh_replace_string "__PRE_TAG[1-2]__" "" mail_to_send
+	fi
 
 	# Define binary to use for mail command
 	if [ -e /usr/bin/bsd-mailx ]
@@ -444,8 +154,15 @@ $(yunohost tools diagnosis | grep -B 100 "services:" | sed '/services:/d')"
 		local mail_bin=/usr/bin/mail.mailutils
 	fi
 
+	if [ "$admin_mail_html" -eq 1 ]
+	then
+		content_type="text/html"
+	else
+		content_type="text/plain"
+	fi
+
 	# Send the email to the recipients
-	echo "$mail_message" | $mail_bin -a "Content-Type: text/plain; charset=UTF-8" -s "$mail_subject" "$recipients"
+	cat mail_to_send | $mail_bin -a "Content-Type: $content_type; charset=UTF-8" -s "$mail_subject" "$recipients"
 }
 
 #=================================================
@@ -459,6 +176,8 @@ ynh_maintenance_mode_ON () {
 		domain=$(ynh_app_setting_get $app domain)
 	fi
 
+	mkdir -p /var/www/html/
+	
 	# Create an html to serve as maintenance notice
 	echo "
 
diff --git a/scripts/backup b/scripts/backup
index 827fb07..53c9973 100644
--- a/scripts/backup
+++ b/scripts/backup
@@ -19,57 +19,56 @@ ynh_abort_if_errors
 #=================================================
 # LOAD SETTINGS
 #=================================================
-ynh_script_progression --message="Load settings" --weight=2
+ynh_script_progression --message="Loading installation settings..." --weight=2
 
 app=$YNH_APP_INSTANCE_NAME
 
-domain=$(ynh_app_setting_get $app domain)
-final_path=$(ynh_app_setting_get $app final_path)
-db_name=$(ynh_app_setting_get $app db_name)
-db_pwd=$(ynh_app_setting_get $app mysqlpwd)
+domain=$(ynh_app_setting_get --app=$app --key=domain)
+final_path=$(ynh_app_setting_get --app=$app --key=final_path)
+db_name=$(ynh_app_setting_get --app=$app --key=db_name)
 
 #=================================================
 # STANDARD BACKUP STEPS
 #=================================================
 # BACKUP THE APP MAIN DIR
 #=================================================
-ynh_script_progression --message="Backup the app main dir" --weight=2
+ynh_script_progression --message="Backing up the main app directory..." --weight=2
 
 CHECK_SIZE "$final_path"
-ynh_backup "$final_path"
+ynh_backup --src_path="$final_path"
 
 #=================================================
 # BACKUP NGINX CONFIGURATION
 #=================================================
-ynh_script_progression --message="Backup nginx configuration"
+ynh_script_progression --message="Backing up nginx web server configuration..."
 
-ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
+ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
 
 #=================================================
 # BACKUP PHP-FPM CONFIGURATION
 #=================================================
-ynh_script_progression --message="Backup php-fpm configuration"
+ynh_script_progression --message="Backing up php-fpm configuration..."
 
-ynh_backup "/etc/php/7.0/fpm/pool.d/$app.conf"
+ynh_backup --src_path="/etc/php/7.0/fpm/pool.d/$app.conf"
 
 #=================================================
 # BACKUP THE MYSQL DATABASE
 #=================================================
-ynh_script_progression --message="Backup the mysql database" --weight=2
+ynh_script_progression --message="Backing up the MySQL database..." --weight=2
 
-ynh_mysql_dump_db "$db_name" > db.sql
+ynh_mysql_dump_db --database="$db_name" > db.sql
 CHECK_SIZE "db.sql"
 
 #=================================================
 # BACKUP FAIL2BAN CONFIGURATION
 #=================================================
-ynh_script_progression --message="Backup fail2ban configuration"
+ynh_script_progression --message="Backing up fail2ban configuration..."
 
-ynh_backup "/etc/fail2ban/jail.d/$app.conf"
-ynh_backup "/etc/fail2ban/filter.d/$app.conf"
+ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf"
+ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf"
 
 #=================================================
 # END OF SCRIPT
 #=================================================
 
-ynh_script_progression --message="Backup completed" --last
+ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --time --last
diff --git a/scripts/change_url b/scripts/change_url
index a96f0a0..acb13aa 100644
--- a/scripts/change_url
+++ b/scripts/change_url
@@ -12,7 +12,6 @@ source /usr/share/yunohost/helpers
 #=================================================
 # RETRIEVE ARGUMENTS
 #=================================================
-ynh_script_progression --message="Retrieve arguments from the manifest"
 
 old_domain=$YNH_APP_OLD_DOMAIN
 old_path=$YNH_APP_OLD_PATH
@@ -25,31 +24,21 @@ app=$YNH_APP_INSTANCE_NAME
 #=================================================
 # LOAD SETTINGS
 #=================================================
-ynh_script_progression --message="Load settings" --weight=2
+ynh_script_progression --message="Loading installation settings..." --weight=2
 
-final_path=$(ynh_app_setting_get $app final_path)
-multisite=$(ynh_app_setting_get $app multisite)
+final_path=$(ynh_app_setting_get --app=$app --key=final_path)
+multisite=$(ynh_app_setting_get  --app=$app --key=multisite)
 
 if [ $multisite -eq 1 ]
 then
 	echo "A multisite installation of Wordpress can't be moved easily. Please have a look at the Wordpress codex to learn more about that." >&2
-	ynh_die "https://codex.wordpress.org/Moving_WordPress#Moving_WordPress_Multisite"
+	ynh_die --message="https://codex.wordpress.org/Moving_WordPress#Moving_WordPress_Multisite"
 fi
 
-#=================================================
-# CHECK THE SYNTAX OF THE PATHS
-#=================================================
-ynh_script_progression --message="Check the syntax of the paths"
-
-test -n "$old_path" || old_path="/"
-test -n "$new_path" || new_path="/"
-new_path=$(ynh_normalize_url_path $new_path)
-old_path=$(ynh_normalize_url_path $old_path)
-
 #=================================================
 # ACTIVATE MAINTENANCE MODE
 #=================================================
-ynh_script_progression --message="Activate maintenance mode" --weight=2
+ynh_script_progression --message="Activating maintenance mode..." --weight=2
 
 path_url=$old_path
 domain=$old_domain
@@ -83,7 +72,7 @@ ynh_abort_if_errors
 #=================================================
 # MODIFY URL IN NGINX CONF
 #=================================================
-ynh_script_progression --message="Modify url in nginx configuration" --weight=3
+ynh_script_progression --message="Updating nginx web server configuration..." --weight=3
 
 nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
 
@@ -91,15 +80,12 @@ nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
 if [ $change_path -eq 1 ]
 then
 	# Make a backup of the original nginx config file if modified
-	ynh_backup_if_checksum_is_different "$nginx_conf_path"
+	ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
 
 	# Set global variables for nginx helper
 	domain="$old_domain"
 	path_url="$new_path"
 
-	# Store path_url setting
-	ynh_app_setting_set $app path "$path_url"
-
 	# Create a dedicated nginx config
 	ynh_add_nginx_config
 fi
@@ -108,11 +94,11 @@ fi
 if [ $change_domain -eq 1 ]
 then
 	# Delete file checksum for the old conf file location
-	ynh_delete_file_checksum "$nginx_conf_path"
+	ynh_delete_file_checksum --file="$nginx_conf_path"
 	mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
 
 	# Store file checksum for the new config file location
-	ynh_store_file_checksum "/etc/nginx/conf.d/$new_domain.d/$app.conf"
+	ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
 fi
 
 #=================================================
@@ -121,22 +107,22 @@ fi
 # UPDATE THE DATABASE
 #=================================================
 
-ynh_mysql_execute_as_root "UPDATE wp_options SET option_value='$new_domain$new_path' WHERE option_name='siteurl'" $app
-ynh_mysql_execute_as_root "UPDATE wp_options SET option_value='$new_domain$new_path' WHERE option_name='home'" $app
+ynh_mysql_execute_as_root --sql="UPDATE wp_options SET option_value='$new_domain$new_path' WHERE option_name='siteurl'" --database=$app
+ynh_mysql_execute_as_root --sql="UPDATE wp_options SET option_value='$new_domain$new_path' WHERE option_name='home'" --database=$app
 
 #=================================================
 # GENERIC FINALISATION
 #=================================================
 # RELOAD NGINX
 #=================================================
-ynh_script_progression --message="Reload nginx"
+ynh_script_progression --message="Reloading nginx web server..."
 
-ynh_systemd_action --action=reload --service_name=nginx
+ynh_systemd_action --service_name=nginx --action=reload
 
 #=================================================
 # DEACTIVE MAINTENANCE MODE
 #=================================================
-ynh_script_progression --message="Disable maintenance mode" --weight=5
+ynh_script_progression --message="Disabling maintenance mode" --weight=5
 
 path_url=$old_path
 domain=$old_domain
@@ -146,4 +132,4 @@ ynh_maintenance_mode_OFF
 # END OF SCRIPT
 #=================================================
 
-ynh_script_progression --message="Change of url completed" --last
+ynh_script_progression --message="Change of URL completed for $app" --last
diff --git a/scripts/install b/scripts/install
index 8b42bb6..21d7e4a 100644
--- a/scripts/install
+++ b/scripts/install
@@ -19,7 +19,6 @@ ynh_abort_if_errors
 #=================================================
 # RETRIEVE ARGUMENTS FROM THE MANIFEST
 #=================================================
-ynh_script_progression --message="Retrieve arguments from the manifest"
 
 domain=$YNH_APP_ARG_DOMAIN
 path_url=$YNH_APP_ARG_PATH
@@ -33,64 +32,61 @@ app=$YNH_APP_INSTANCE_NAME
 #=================================================
 # CHECK IF THE APP CAN BE INSTALLED WITH THIS ARGS
 #=================================================
-ynh_script_progression --message="Check if the app can be installed" --weight=2
+ynh_script_progression --message="Validating installation parameters..." --weight=2
 
 final_path=/var/www/$app
-test ! -e "$final_path" || ynh_die "This path already contains a folder"
-
-# Normalize the url path syntax
-path_url=$(ynh_normalize_url_path $path_url)
+test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
 
 # Register (book) web path
-ynh_webpath_register $app $domain $path_url
+ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
 
 if [ "$path_url" == "/" ] && [ $multisite -eq 1 ]; then
-	ynh_die "Multisite option of wordpress doesn't work at the root of a domain."
+	ynh_die --message="Multisite option of wordpress doesn't work at the root of a domain."
 fi
 
 #=================================================
 # STORE SETTINGS FROM MANIFEST
 #=================================================
-ynh_script_progression --message="Store settings from manifest" --weight=2
+ynh_script_progression --message="Storing installation settings..." --weight=2
 
-ynh_app_setting_set $app domain $domain
-ynh_app_setting_set $app path $path_url
-ynh_app_setting_set $app admin $admin_wordpress
-ynh_app_setting_set $app is_public $is_public
-ynh_app_setting_set $app language $language
-ynh_app_setting_set $app multisite $multisite
+ynh_app_setting_set --app=$app --key=domain --value=$domain
+ynh_app_setting_set --app=$app --key=path --value=$path_url
+ynh_app_setting_set --app=$app --key=admin --value=$admin_wordpress
+ynh_app_setting_set --app=$app --key=is_public --value=$is_public
+ynh_app_setting_set --app=$app --key=language --value=$language
+ynh_app_setting_set --app=$app --key=multisite --value=$multisite
 
 #=================================================
 # STANDARD MODIFICATIONS
 #=================================================
 # INSTALL DEPENDENCIES
 #=================================================
-ynh_script_progression --message="Install dependencies" --weight=9
+ynh_script_progression --message="Installing dependencies..." --weight=9
 
 ynh_install_app_dependencies php5-cli
 
 #=================================================
 # CREATE A MYSQL DATABASE
 #=================================================
-ynh_script_progression --message="Create a mysql database"
+ynh_script_progression --message="Creating a MySQL database..."
 
-db_name=$(ynh_sanitize_dbid $app)
-ynh_app_setting_set $app db_name $db_name
-ynh_mysql_setup_db $db_name $db_name
+db_name=$(ynh_sanitize_dbid --db_name=$app)
+ynh_app_setting_set --app=$app --key=db_name --value=$db_name
+ynh_mysql_setup_db --db_user=$db_name --db_name=$db_name
 
 #=================================================
 # DOWNLOAD, CHECK AND UNPACK SOURCE
 #=================================================
-ynh_script_progression --message="Download, check and unpack source" --weight=4
+ynh_script_progression --message="Setting up source files..." --weight=4
 
-ynh_app_setting_set $app final_path $final_path
+ynh_app_setting_set --app=$app --key=final_path --value=$final_path
 # Download, check integrity, uncompress and patch the source from app.src
-ynh_setup_source "$final_path"
+ynh_setup_source --dest_dir="$final_path"
 
 #=================================================
 # NGINX CONFIGURATION
 #=================================================
-ynh_script_progression --message="Configure nginx" --weight=3
+ynh_script_progression --message="Configuring nginx web server..." --weight=3
 
 # Create a dedicated nginx config
 ynh_add_nginx_config
@@ -98,15 +94,15 @@ ynh_add_nginx_config
 #=================================================
 # CREATE DEDICATED USER
 #=================================================
-ynh_script_progression --message="Create a dedicated user" --weight=3
+ynh_script_progression --message="Configuring system user..." --weight=3
 
 # Create a dedicated system user
-ynh_system_user_create $app
+ynh_system_user_create --username=$app
 
 #=================================================
 # PHP-FPM CONFIGURATION
 #=================================================
-ynh_script_progression --message="Configure php-fpm" --weight=2
+ynh_script_progression --message="Configuring php-fpm..." --weight=2
 
 # Create a dedicated php-fpm config
 ynh_add_fpm_config
@@ -116,49 +112,49 @@ ynh_add_fpm_config
 #=================================================
 # CONFIGURE WP-CONFIG
 #=================================================
-ynh_script_progression --message="Configure wp-config.php"
+ynh_script_progression --message="Configuring wordpress..."
 
 cp ../conf/wp-config.php $final_path/wp-config.php
 # Change variables in Wordpress configuration
-ynh_replace_string "__DB_USER__" "$db_name" $final_path/wp-config.php
-ynh_replace_string "__DB_PWD__" "$db_pwd" $final_path/wp-config.php
+ynh_replace_string --match_string="__DB_USER__" --replace_string=$db_name --target_file=$final_path/wp-config.php
+ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file=$final_path/wp-config.php
 
 for i in 1 2 3 4 5 6 7 8
 do
-	j=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d '[A-Za-z0-9]' | sed -n 's/\(.\{40\}\).*/\1/p')
+	j=$(ynh_string_random --length=40)
 	if [ "$j" = "" ];
 	then
 		# For obscure reasons, the loop is too fast at execution
 		sleep 1
-		j=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d '[A-Za-z0-9]' | sed -n 's/\(.\{40\}\).*/\1/p')
+		j=$(ynh_string_random --length=40)
 	fi
-	ynh_replace_string "KEY$i" "$j" $final_path/wp-config.php
+	ynh_replace_string --match_string="KEY$i" --replace_string="$j" --target_file=$final_path/wp-config.php
 done
 
 #=================================================
 # SETTING UP WITH CURL
 #=================================================
-ynh_script_progression --message="Install wordpress with Curl" --weight=10
+ynh_script_progression --message="Installing wordpress with Curl..." --weight=10
 
 # Set right permissions for curl install
 chown -R $app: $final_path
 
 # Set the app as temporarily public for curl call
-ynh_app_setting_set $app unprotected_uris "/"
+ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
 # Regen SSOwat configuration
 yunohost app ssowatconf
 
 # Reload Nginx
-ynh_systemd_action --action=reload --service_name=nginx
+ynh_systemd_action --service_name=nginx --action=reload
 
 # Wordpress installation
 ynh_local_curl "/wp-admin/install.php?step=2" "&weblog_title=YunoBlog" "user_name=$admin_wordpress" "admin_password=$db_pwd" "admin_password2=$db_pwd" "admin_email=$admin_wordpress@$domain" "Submit=Install+WordPress"
 
-ynh_print_info "Please wait during Wordpress installation"
+ynh_print_info --message="Please wait during Wordpress installation..."
 for i in `seq 1 300`
 do
 	# The loop waits for wordpress to be installed, or 5 minutes.
-	if ynh_mysql_connect_as $db_name $db_pwd $db_name <<< "show tables" | grep -q "wp_options"; then
+	if ynh_mysql_connect_as --user=$db_name --password=$db_pwd --database=$db_name <<< "show tables" | grep --quiet "wp_options"; then
 		# If the table wp_options is found, wordpress has finished its installation.
 		break
 	fi
@@ -168,9 +164,9 @@ done
 #=================================================
 # INSTALL WORDPRESS PLUGINS
 #=================================================
-ynh_script_progression --message="Install wordpress plugins" --weight=20
+ynh_script_progression --message="Installing wordpress plugins..." --weight=20
 
-wget -nv https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -O $final_path/wp-cli.phar
+wget --no-verbose https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar --output-document=$final_path/wp-cli.phar
 wpcli_alias="php $final_path/wp-cli.phar --allow-root --path=$final_path"
 
 $wpcli_alias plugin install simple-ldap-login
@@ -181,7 +177,7 @@ $wpcli_alias plugin install wp-fail2ban
 #=================================================
 # SET LANGUAGE
 #=================================================
-ynh_script_progression --message="Set language" --weight=3
+ynh_script_progression --message="Configuring language..." --weight=3
 
 $wpcli_alias core language install $language
 $wpcli_alias site switch-language $language
@@ -192,29 +188,29 @@ $wpcli_alias site switch-language $language
 
 if [ $multisite -eq 1 ]
 then
-	ynh_script_progression --message="Configure multisite" --weight=2
+	ynh_script_progression --message="Configuring multisite..." --weight=2
 
-	ynh_replace_string "#--MULTISITE--" "" /etc/nginx/conf.d/$domain.d/$app.conf
+	ynh_replace_string --match_string="#--MULTISITE--" --replace_string="" --target_file=/etc/nginx/conf.d/$domain.d/$app.conf
 	# Allow multisite
-	ynh_replace_string "//--MULTISITE1--define" "define " $final_path/wp-config.php
+	ynh_replace_string --match_string="//--MULTISITE1--define" --replace_string="define " --target_file=$final_path/wp-config.php
 
 	# Activate multisite via wp-cli
 	ynh_exec_fully_quiet $wpcli_alias core multisite-convert --base=$path_url/
 
 	# Activate multisite in wordpress config
-	ynh_replace_string "//--MULTISITE2--define" "define" $final_path/wp-config.php
+	ynh_replace_string --match_string="//--MULTISITE2--define" --replace_string="define" --target_file=$final_path/wp-config.php
 
-	ynh_mysql_connect_as $db_name $db_pwd $db_name < ../conf/sql/multisite.sql
+	ynh_mysql_connect_as --user=$db_name --password=$db_pwd --database=$db_name < ../conf/sql/multisite.sql
 	plugin_network="--network"
 else
-	ynh_mysql_connect_as $db_name $db_pwd $db_name < ../conf/sql/single.sql
+	ynh_mysql_connect_as --user=$db_name --password=$db_pwd --database=$db_name < ../conf/sql/single.sql
 	plugin_network=""
 fi
 
 #=================================================
 # ACTIVATE WORDPRESS PLUGINS
 #=================================================
-ynh_script_progression --message="Activate wordpress plugins" --weight=4
+ynh_script_progression --message="Activating plugins..." --weight=4
 
 $wpcli_alias plugin activate simple-ldap-login $plugin_network
 # Do not activate http-authentication, this plugin is sometimes unstable
@@ -226,7 +222,7 @@ $wpcli_alias plugin activate wp-fail2ban $plugin_network
 #=================================================
 
 # Calculate and store the config file checksum into the app settings
-ynh_store_file_checksum "$final_path/wp-config.php"
+ynh_store_file_checksum --file="$final_path/wp-config.php"
 
 #=================================================
 # GENERIC FINALISATION
@@ -243,7 +239,7 @@ chown root: $final_path/wp-config.php
 #=================================================
 # SETUP FAIL2BAN
 #=================================================
-ynh_script_progression --message="Configure fail2ban" --weight=7
+ynh_script_progression --message="Configuring fail2ban..." --weight=7
 
 # Create a dedicated fail2ban config
 ynh_add_fail2ban_config --logpath="/var/log/auth.log" --failregex="Authentication (attempt for unknown user|failure for) .* from " --max_retry=5
@@ -251,20 +247,20 @@ ynh_add_fail2ban_config --logpath="/var/log/auth.log" --failregex="Authenticatio
 #=================================================
 # SETUP SSOWAT
 #=================================================
-ynh_script_progression --message="Setup SSOwat"
+ynh_script_progression --message="Configuring SSOwat..."
 
 if [ $is_public -eq 0 ];
 then
 	# Remove the public access
-	ynh_app_setting_delete $app unprotected_uris
+	ynh_app_setting_delete --app=$app --key=unprotected_uris
 fi
 
 #=================================================
 # RELOAD NGINX
 #=================================================
-ynh_script_progression --message="Reload nginx" --weight=3
+ynh_script_progression --message="Reloading nginx web server..." --weight=3
 
-ynh_systemd_action --action=reload --service_name=nginx
+ynh_systemd_action --service_name=nginx --action=reload
 
 #=================================================
 # REMOVE WP-CLI.PHAR
@@ -276,12 +272,12 @@ ynh_secure_remove $final_path/wp-cli.phar
 # SEND A README FOR THE ADMIN
 #=================================================
 
-message="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"
+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
 
-ynh_send_readme_to_admin --app_message="$message" --recipients="$admin_wordpress"
+ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="$admin_wordpress" --type=install
 
 #=================================================
 # END OF SCRIPT
 #=================================================
 
-ynh_script_progression --message="Installation completed" --last
+ynh_script_progression --message="Installation of $app completed" --last
diff --git a/scripts/remove b/scripts/remove
index e9475ff..c0f9f2d 100755
--- a/scripts/remove
+++ b/scripts/remove
@@ -12,19 +12,20 @@ source /usr/share/yunohost/helpers
 #=================================================
 # LOAD SETTINGS
 #=================================================
-ynh_script_progression --message="Load settings" --weight=2
+ynh_script_progression --message="Loading installation settings..." --weight=2
 
 app=$YNH_APP_INSTANCE_NAME
 
-domain=$(ynh_app_setting_get $app domain)
-db_name=$(ynh_app_setting_get $app db_name)
+domain=$(ynh_app_setting_get --app=$app --key=domain)
+db_name=$(ynh_app_setting_get --app=$app --key=db_name)
+final_path=$(ynh_app_setting_get --app=$app --key=final_path)
 
 #=================================================
 # STANDARD REMOVE
 #=================================================
 # REMOVE DEPENDENCIES
 #=================================================
-ynh_script_progression --message="Remove dependencies" --weight=11
+ynh_script_progression --message="Removing dependencies..." --weight=11
 
 # Remove metapackage and its dependencies
 ynh_remove_app_dependencies
@@ -32,23 +33,23 @@ ynh_remove_app_dependencies
 #=================================================
 # REMOVE THE MYSQL DATABASE
 #=================================================
-ynh_script_progression --message="Remove the mysql database" --weight=2
+ynh_script_progression --message="Removing the MySQL database..." --weight=2
 
 # Remove a database if it exists, along with the associated user
-ynh_mysql_remove_db $db_name $db_name
+ynh_mysql_remove_db --db_user=$db_name --db_name=$db_name
 
 #=================================================
 # REMOVE APP MAIN DIR
 #=================================================
-ynh_script_progression --message="Remove app main directory"
+ynh_script_progression --message="Removing app main directory..."
 
 # Remove the app directory securely
-ynh_secure_remove "/var/www/$app"
+ynh_secure_remove --file="$final_path"
 
 #=================================================
 # REMOVE NGINX CONFIGURATION
 #=================================================
-ynh_script_progression --message="Remove nginx configuration"
+ynh_script_progression --message="Removing nginx web server configuration..."
 
 # Remove the dedicated nginx config
 ynh_remove_nginx_config
@@ -56,7 +57,7 @@ ynh_remove_nginx_config
 #=================================================
 # REMOVE PHP-FPM CONFIGURATION
 #=================================================
-ynh_script_progression --message="Remove php-fpm configuration" --weight=2
+ynh_script_progression --message="Removing php-fpm configuration..." --weight=2
 
 # Remove the dedicated php-fpm config
 ynh_remove_fpm_config
@@ -64,7 +65,7 @@ ynh_remove_fpm_config
 #=================================================
 # REMOVE FAIL2BAN CONFIGURATION
 #=================================================
-ynh_script_progression --message="Remove fail2ban configuration" --weight=8
+ynh_script_progression --message="Removing fail2ban configuration..." --weight=8
 
 # Remove the dedicated fail2ban config
 ynh_remove_fail2ban_config
@@ -74,13 +75,13 @@ ynh_remove_fail2ban_config
 #=================================================
 # REMOVE DEDICATED USER
 #=================================================
-ynh_script_progression --message="Remove the dedicated user" --weight=3
+ynh_script_progression --message="Removing the dedicated system user..." --weight=3
 
 # Delete dedicated system user
-ynh_system_user_delete $app
+ynh_system_user_delete --username=$app
 
 #=================================================
 # END OF SCRIPT
 #=================================================
 
-ynh_script_progression --message="Deletion completed" --last
+ynh_script_progression --message="Removal of $app completed" --last
diff --git a/scripts/restore b/scripts/restore
index 53f6d4f..dff157d 100644
--- a/scripts/restore
+++ b/scripts/restore
@@ -19,30 +19,31 @@ ynh_abort_if_errors
 #=================================================
 # LOAD SETTINGS
 #=================================================
-ynh_script_progression --message="Load settings" --weight=3
+ynh_script_progression --message="Loading settings..." --weight=3
 
 app=$YNH_APP_INSTANCE_NAME
 
-domain=$(ynh_app_setting_get $app domain)
-path_url=$(ynh_app_setting_get $app path)
-is_public=$(ynh_app_setting_get $app is_public)
-final_path=$(ynh_app_setting_get $app final_path)
-db_name=$(ynh_app_setting_get $app db_name)
-admin_wordpress=$(ynh_app_setting_get $app admin)
+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)
+db_name=$(ynh_app_setting_get --app=$app --key=db_name)
+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_webpath_available $domain $path_url \
-	|| ynh_die "Path not available: ${domain}${path_url}"
+ynh_webpath_available --domain=$domain --path_url=$path_url \
+	|| ynh_die --message="Path not available: ${domain}${path_url}"
 test ! -d $final_path \
-	|| ynh_die "There is already a directory: $final_path "
+	|| ynh_die --message="There is already a directory: $final_path "
 
 #=================================================
 # ACTIVATE MAINTENANCE MODE
 #=================================================
-ynh_script_progression --message="Activate maintenance mode"
+ynh_script_progression --message="Activating maintenance mode..."
 
 ynh_maintenance_mode_ON
 
@@ -52,31 +53,31 @@ ynh_maintenance_mode_ON
 # RESTORE THE NGINX CONFIGURATION
 #=================================================
 
-ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
+ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
 
 #=================================================
 # RESTORE THE APP MAIN DIR
 #=================================================
-ynh_script_progression --message="Restore the app main directory"
+ynh_script_progression --message="Restoring the app main directory..."
 
-ynh_restore_file "$final_path"
+ynh_restore_file --origin_path="$final_path"
 
 #=================================================
 # RESTORE THE MYSQL DATABASE
 #=================================================
-ynh_script_progression --message="Restore the mysql database" --weight=3
+ynh_script_progression --message="Restoring the MySQL database..." --weight=3
 
-db_pwd=$(ynh_app_setting_get $app mysqlpwd)
-ynh_mysql_setup_db $db_name $db_name $db_pwd
-ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql
+db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
+ynh_mysql_setup_db --db_user=$db_name --db_name=$db_name --db_pwd=$db_pwd
+ynh_mysql_connect_as --user=$db_name --password=$db_pwd --database=$db_name < ./db.sql
 
 #=================================================
 # RECREATE THE DEDICATED USER
 #=================================================
-ynh_script_progression --message="Recreate the dedicated user" --weight=3
+ynh_script_progression --message="Recreating the dedicated system user..." --weight=3
 
 # Create the dedicated user (if not existing)
-ynh_system_user_create $app
+ynh_system_user_create --username=$app
 
 #=================================================
 # RESTORE USER RIGHTS
@@ -92,15 +93,15 @@ chown root: $final_path/wp-config.php
 # RESTORE THE PHP-FPM CONFIGURATION
 #=================================================
 
-ynh_restore_file "/etc/php/7.0/fpm/pool.d/$app.conf"
+ynh_restore_file --origin_path="/etc/php/7.0/fpm/pool.d/$app.conf"
 
 #=================================================
 # RESTORE THE FAIL2BAN CONFIGURATION
 #=================================================
-ynh_script_progression --message="Restore the fail2ban configuration" --weight=6
+ynh_script_progression --message="Restoring the fail2ban configuration..." --weight=6
 
-ynh_restore_file "/etc/fail2ban/jail.d/$app.conf"
-ynh_restore_file "/etc/fail2ban/filter.d/$app.conf"
+ynh_restore_file --origin_path="/etc/fail2ban/jail.d/$app.conf"
+ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$app.conf"
 ynh_systemd_action --action=restart --service_name=fail2ban
 
 #=================================================
@@ -108,15 +109,15 @@ ynh_systemd_action --action=restart --service_name=fail2ban
 #=================================================
 # RELOAD NGINX AND PHP-FPM
 #=================================================
-ynh_script_progression --message="Reload nginx and php-fpm" --weight=2
+ynh_script_progression --message="Reloading nginx web server and php-fpm..." --weight=2
 
-ynh_systemd_action --action=reload --service_name=php5-fpm
-ynh_systemd_action --action=reload --service_name=nginx
+ynh_systemd_action --service_name=php7.0-fpm --action=reload
+ynh_systemd_action --service_name=nginx --action=reload
 
 #=================================================
 # DEACTIVE MAINTENANCE MODE
 #=================================================
-ynh_script_progression --message="Disable maintenance mode" --weight=8
+ynh_script_progression --message="Disabling maintenance mode..." --weight=8
 
 ynh_maintenance_mode_OFF
 
@@ -124,12 +125,12 @@ ynh_maintenance_mode_OFF
 # SEND A README FOR THE ADMIN
 #=================================================
 
-message="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"
+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
 
-ynh_send_readme_to_admin --app_message="$message" --recipients="$admin_wordpress"
+ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="$admin_wordpress" --type=restore
 
 #=================================================
 # END OF SCRIPT
 #=================================================
 
-ynh_script_progression --message="Restoration completed" --last
+ynh_script_progression --message="Restoration completed for $app" --last
diff --git a/scripts/upgrade b/scripts/upgrade
index 002e300..4c1ba98 100644
--- a/scripts/upgrade
+++ b/scripts/upgrade
@@ -12,18 +12,18 @@ source /usr/share/yunohost/helpers
 #=================================================
 # LOAD SETTINGS
 #=================================================
-ynh_script_progression --message="Load settings" --weight=5
+ynh_script_progression --message="Loading installation settings..." --weight=5
 
 app=$YNH_APP_INSTANCE_NAME
 
-domain=$(ynh_app_setting_get $app domain)
-path_url=$(ynh_app_setting_get $app path)
-admin_wordpress=$(ynh_app_setting_get $app admin)
-language=$(ynh_app_setting_get $app language)
-is_public=$(ynh_app_setting_get $app is_public)
-multisite=$(ynh_app_setting_get $app multisite)
-final_path=$(ynh_app_setting_get $app final_path)
-db_name=$(ynh_app_setting_get $app db_name)
+domain=$(ynh_app_setting_get --app=$app --key=domain)
+path_url=$(ynh_app_setting_get --app=$app --key=path)
+admin_wordpress=$(ynh_app_setting_get --app=$app --key=admin)
+language=$(ynh_app_setting_get --app=$app --key=language)
+is_public=$(ynh_app_setting_get --app=$app --key=is_public)
+multisite=$(ynh_app_setting_get --app=$app --key=multisite)
+final_path=$(ynh_app_setting_get --app=$app --key=final_path)
+db_name=$(ynh_app_setting_get --app=$app --key=db_name)
 
 #=================================================
 # CHECK VERSION
@@ -34,47 +34,48 @@ upgrade_type=$(ynh_check_app_version_changed)
 #=================================================
 # ENSURE DOWNWARD COMPATIBILITY
 #=================================================
-ynh_script_progression --message="Ensure downward compatibility"
+ynh_script_progression --message="Ensuring downward compatibility..."
 
 if [ -z "$admin_wordpress" ]; then
-	ynh_mysql_execute_as_root "select MAX(user_login) from wp_users where user_status=0 INTO OUTFILE '/tmp/wordpressuser';" $db_name
+	ynh_mysql_execute_as_root --sql="select MAX(user_login) from wp_users where user_status=0 INTO OUTFILE '/tmp/wordpressuser';" --database=$db_name
 	admin_wordpress=$(cat /tmp/wordpressuser)
-	ynh_secure_remove /tmp/wordpressuser
-	ynh_app_setting_set $app admin $admin_wordpress
+	ynh_secure_remove --file=/tmp/wordpressuser
+	ynh_app_setting_set --app=$app --key=admin --value=$admin_wordpress
 fi
 
+# If final_path doesn't exist, create it
 if [ -z "$final_path" ]; then
 	final_path=/var/www/$app
-	ynh_app_setting_set $app final_path $final_path
+	ynh_app_setting_set --app=$app --key=final_path --value=$final_path
 fi
 
 if [ -z "$language" ]; then
 	language=$(grep WPLANG $final_path/wp-config.php | cut -d"'" -f4)
-	ynh_app_setting_set $app language $language
+	ynh_app_setting_set --app=$app --key=language --value=$language
 fi
 
 # Fix is_public as a boolean
 if [ "${is_public,,}" = "yes" ]; then
-	ynh_app_setting_set $app is_public 1
+	ynh_app_setting_set --app=$app --key=is_public --value=1
 	is_public=1
 elif [ "${is_public,,}" = "no" ]; then
-	ynh_app_setting_set $app is_public 0
+	ynh_app_setting_set --app=$app --key=is_public --value=0
 	is_public=0
 fi
 
 # Fix multisite as a boolean
 if [ "${multisite,,}" = "yes" ]; then
-	ynh_app_setting_set $app multisite 1
+	ynh_app_setting_set --app=$app --key=multisite --value=1
 	multisite=1
 elif [ "${multisite,,}" = "no" ]; then
-	ynh_app_setting_set $app multisite 0
+	ynh_app_setting_set --app=$app --key=multisite --value=0
 	multisite=0
 fi
 
 # If db_name doesn't exist, create it
-if [ -z $db_name ]; then
-	db_name=$(ynh_sanitize_dbid $app)
-	ynh_app_setting_set $app db_name $db_name
+if [ -z "$db_name" ]; then
+	db_name=$(ynh_sanitize_dbid --db_name=$app)
+	ynh_app_setting_set --app=$app --key=db_name --value=$db_name
 fi
 
 # If some 'add_filter' are still in wp_config, remove them
@@ -87,7 +88,7 @@ fi
 #=================================================
 # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
 #=================================================
-ynh_script_progression --message="Backup the app before upgrading" --weight=15
+ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=15
 
 # Backup the current version of the app
 ynh_backup_before_upgrade
@@ -103,26 +104,26 @@ ynh_abort_if_errors
 #=================================================
 
 # Normalize the URL path syntax
-path_url=$(ynh_normalize_url_path $path_url)
+path_url=$(ynh_normalize_url_path --path_url=$path_url)
 
 #=================================================
 # ACTIVATE MAINTENANCE MODE
 #=================================================
-ynh_script_progression --message="Activate maintenance mode" --weight=2
+ynh_script_progression --message="Activating maintenance mode..." --weight=2
 
 ynh_maintenance_mode_ON
 
 #=================================================
 # UPGRADE DEPENDENCIES
 #=================================================
-ynh_script_progression --message="Upgrade dependencies" --weight=11
+ynh_script_progression --message="Upgrading dependencies..." --weight=11
 
 ynh_install_app_dependencies php5-cli
 
 #=================================================
 # NGINX CONFIGURATION
 #=================================================
-ynh_script_progression --message="Reconfigure nginx" --weight=2
+ynh_script_progression --message="Upgrading nginx web server configuration..." --weight=2
 
 # Create a dedicated nginx config
 ynh_add_nginx_config
@@ -130,15 +131,15 @@ ynh_add_nginx_config
 #=================================================
 # CREATE DEDICATED USER
 #=================================================
-ynh_script_progression --message="Create a dedicated user"
+ynh_script_progression --message="Making sure dedicated system user exists..."
 
 # Create a dedicated user (if not existing)
-ynh_system_user_create $app
+ynh_system_user_create --username=$app
 
 #=================================================
 # PHP-FPM CONFIGURATION
 #=================================================
-ynh_script_progression --message="Reconfigure php-fpm" --weight=4
+ynh_script_progression --message="Upgrading php-fpm configuration..." --weight=4
 
 # Create a dedicated php-fpm config
 ynh_add_fpm_config
@@ -150,33 +151,33 @@ ynh_add_fpm_config
 #=================================================
 
 # Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
-ynh_backup_if_checksum_is_different "$final_path/wp-config.php"
+ynh_backup_if_checksum_is_different --file="$final_path/wp-config.php"
 
 #=================================================
 # CONFIGURE MULTISITE
 #=================================================
-ynh_script_progression --message="Configure multisite" --weight=2
+ynh_script_progression --message="Configuring multisite..." --weight=2
 
 if [ $multisite -eq 1 ]
 then
-	ynh_replace_string "#--MULTISITE--" "" /etc/nginx/conf.d/$domain.d/$app.conf
+	ynh_replace_string --match_string="#--MULTISITE--" --replace_string="" --target_file=/etc/nginx/conf.d/$domain.d/$app.conf
 	plugin_network="--network"
 else
 	multisite=0
 	plugin_network=""
 	if [ $is_public -eq 0 ]
 	then
-		ynh_replace_string "#--PRIVATE--" "" /etc/nginx/conf.d/$domain.d/$app.conf
+		ynh_replace_string --match_string="#--PRIVATE--" --replace_string="" --target_file=/etc/nginx/conf.d/$domain.d/$app.conf
 	else
-		ynh_replace_string "//--PUBLIC--define" "define" $final_path/wp-config.php
+		ynh_replace_string --match_string="//--PUBLIC--define" --replace_string="define" --target_file=$final_path/wp-config.php
 	fi
 fi
-ynh_app_setting_set $app multisite $multisite
+ynh_app_setting_set --app=$app --key=multisite --value=$multisite
 
 #=================================================
 # UPDATE WORDPRESS PLUGINS
 #=================================================
-ynh_script_progression --message="Update wordpress plugins" --weight=11
+ynh_script_progression --message="Updating plugins" --weight=11
 
 wget -nv https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -O $final_path/wp-cli.phar
 wpcli_alias="php $final_path/wp-cli.phar --allow-root --path=$final_path"
@@ -198,7 +199,7 @@ $wpcli_alias plugin is-installed http-authentication && $wpcli_alias plugin deac
 #=================================================
 
 # Recalculate and store the checksum of the file for the next upgrade.
-ynh_store_file_checksum "$final_path/wp-config.php"
+ynh_store_file_checksum --file="$final_path/wp-config.php"
 
 #=================================================
 # GENERIC FINALISATION
@@ -215,7 +216,7 @@ chown root: $final_path/wp-config.php
 #=================================================
 # UPGRADE FAIL2BAN
 #=================================================
-ynh_script_progression --message="Reconfigure fail2ban" --weight=9
+ynh_script_progression --message="Reconfiguring fail2ban..." --weight=9
 
 # Create a dedicated fail2ban config
 ynh_add_fail2ban_config --logpath="/var/log/auth.log" --failregex="Authentication (attempt for unknown user|failure for) .* from " --max_retry=5
@@ -223,35 +224,35 @@ ynh_add_fail2ban_config --logpath="/var/log/auth.log" --failregex="Authenticatio
 #=================================================
 # SETUP SSOWAT
 #=================================================
-ynh_script_progression --message="Reconfigure SSOwat"
+ynh_script_progression --message="Upgrading SSOwat configuration..."
 
 # Remove skipped_uris if it's still present
-ynh_app_setting_delete $app skipped_uris
+ynh_app_setting_delete --app=$app --key=skipped_uris
 if [ $is_public -eq 0 ]; then
 	# Remove the public access
-	ynh_app_setting_delete $app unprotected_uris
+	ynh_app_setting_delete --app=$app --key=unprotected_uris
 else
 	# Or replace skipped_uris by unprotected_uris
-	ynh_app_setting_set $app unprotected_uris "/"
+	ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
 fi
 
 #=================================================
 # RELOAD NGINX
 #=================================================
-ynh_script_progression --message="Reload nginx"
+ynh_script_progression --message="Reloading nginx web server..."
 
-ynh_systemd_action --action=reload --service_name=nginx
+ynh_systemd_action --service_name=nginx --action=reload
 
 #=================================================
 # REMOVE WP-CLI.PHAR
 #=================================================
 
-ynh_secure_remove $final_path/wp-cli.phar
+ynh_secure_remove --file=$final_path/wp-cli.phar
 
 #=================================================
 # DEACTIVE MAINTENANCE MODE
 #=================================================
-ynh_script_progression --message="Disable maintenance mode" --weight=5
+ynh_script_progression --message="Disabling maintenance mode..." --weight=5
 
 ynh_maintenance_mode_OFF
 
@@ -259,4 +260,4 @@ ynh_maintenance_mode_OFF
 # END OF SCRIPT
 #=================================================
 
-ynh_script_progression --message="Upgrade completed" --last
+ynh_script_progression --message="Upgrade of $app completed" --last

From cdcc8dba72dcbf2c38183c48bb883419513d7b27 Mon Sep 17 00:00:00 2001
From: Maniack Crudelis 
Date: Tue, 21 May 2019 12:14:55 +0200
Subject: [PATCH 11/11] Remove legacy code

---
 scripts/install | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/scripts/install b/scripts/install
index 21d7e4a..4b2f531 100644
--- a/scripts/install
+++ b/scripts/install
@@ -122,13 +122,8 @@ ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --targ
 for i in 1 2 3 4 5 6 7 8
 do
 	j=$(ynh_string_random --length=40)
-	if [ "$j" = "" ];
-	then
-		# For obscure reasons, the loop is too fast at execution
-		sleep 1
-		j=$(ynh_string_random --length=40)
-	fi
 	ynh_replace_string --match_string="KEY$i" --replace_string="$j" --target_file=$final_path/wp-config.php
+	sleep 0.5
 done
 
 #=================================================