From 9302cf203eb5e3f4ab270bee85609f58ec0a2579 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 23 Feb 2020 17:27:30 +0100 Subject: [PATCH] Apply example_ynh --- README.md | 1 - README_fr.md | 1 - scripts/backup | 4 ++++ scripts/change_url | 18 ++++++++++++++++++ scripts/install | 8 +++++++- scripts/restore | 7 +++++++ scripts/upgrade | 3 +++ scripts/ynh_install_php__3 | 2 +- 8 files changed, 40 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 7cdda1d..a2ac1d5 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,6 @@ LDAP module can be installed * x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/drupal7%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/drupal7/) * ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/drupal7%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/drupal7/) -* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/drupal7%20%28Apps%29.svg)](https://ci-stretch.nohost.me/ci/apps/drupal7/) ## Links diff --git a/README_fr.md b/README_fr.md index 72e75c2..82582e0 100644 --- a/README_fr.md +++ b/README_fr.md @@ -31,7 +31,6 @@ le module d'authentification LDAP peut ĂȘtre installĂ© * x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/drupal7%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/drupal7/) * ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/drupal7%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/drupal7/) -* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/drupal7%20%28Apps%29.svg)](https://ci-stretch.nohost.me/ci/apps/drupal7/) ## Liens diff --git a/scripts/backup b/scripts/backup index 84308f2..09fec26 100644 --- a/scripts/backup +++ b/scripts/backup @@ -13,7 +13,11 @@ source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE #================================================= +ynh_print_info --message="Managing script failure..." +ynh_clean_setup () { + true +} # Exit if an error occurs during the execution of the script ynh_abort_if_errors diff --git a/scripts/change_url b/scripts/change_url index 03fabfe..865a9f7 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -12,6 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # RETRIEVE ARGUMENTS #================================================= +ynh_print_info --message="Retrieve arguments from the manifest" old_domain=$YNH_APP_OLD_DOMAIN old_path=$YNH_APP_OLD_PATH @@ -34,6 +35,23 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) #db_user=$db_name #db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= +ynh_print_info --message="Backing up the app before changing its url (may take a while)..." + +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. + ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" + + # restore it if the upgrade fails + ynh_restore_upgradebackup +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + #================================================= # CHECK WHICH PARTS SHOULD BE CHANGED #================================================= diff --git a/scripts/install b/scripts/install index 97fd265..7aa4977 100644 --- a/scripts/install +++ b/scripts/install @@ -15,13 +15,18 @@ source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE #================================================= +ynh_print_info --message="Managing script failure..." +ynh_clean_setup () { + true +} # Exit if an error occurs during the execution of the script ynh_abort_if_errors #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= +ynh_print_info --message="Retrieving arguments from the manifest..." domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH @@ -30,7 +35,6 @@ is_public=$YNH_APP_ARG_IS_PUBLIC language=$YNH_APP_ARG_LANGUAGE password=$YNH_APP_ARG_PASSWORD install_profil=$YNH_APP_ARG_INSTALL_PROFIL - admin_mail=$(ynh_user_get_info --username=$admin --key="mail") app=$YNH_APP_INSTANCE_NAME @@ -179,6 +183,7 @@ ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_fil #================================================= # STORE THE CONFIG FILE CHECKSUM #================================================= +ynh_print_info --message="Storing the config file checksum..." # Calculate and store the config file checksum into the app settings ynh_store_file_checksum --file="$final_path/$app/sites/default/settings.php" @@ -196,6 +201,7 @@ ynh_add_fpm_config --phpversion="7.2" #================================================= # SECURE FILES AND DIRECTORIES #================================================= +ynh_print_info --message="Securing files and directories..." # Set permissions to app files chown -R $app: $final_path diff --git a/scripts/restore b/scripts/restore index e52faa5..5587e14 100644 --- a/scripts/restore +++ b/scripts/restore @@ -15,7 +15,11 @@ source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE #================================================= +ynh_print_info --message="Managing script failure..." +ynh_clean_setup () { + true +} # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -47,6 +51,7 @@ test ! -d $final_path \ #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= +ynh_print_info --message="Restoring the nginx configuration..." ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" @@ -68,6 +73,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # RESTORE USER RIGHTS #================================================= +ynh_print_info --message="Restoring user rights..." # Restore permissions on app files chown -R $app: $final_path @@ -82,6 +88,7 @@ ynh_install_php --phpversion="7.2" --package="$extra_pkg_dependencies" #================================================= # RESTORE THE PHP-FPM CONFIGURATION #================================================= +ynh_print_info --message="Restoring PHP-FPM configuration..." ynh_restore_file --origin_path="/etc/php/7.2/fpm/pool.d/$app.conf" diff --git a/scripts/upgrade b/scripts/upgrade index 8b98d17..c13793b 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -30,6 +30,7 @@ db_name=$(ynh_app_setting_get --app=$app --key=db_name) #================================================= # CHECK VERSION #================================================= +ynh_print_info --message="Checking version..." upgrade_type=$(ynh_check_app_version_changed) @@ -145,6 +146,7 @@ update-alternatives --set php /usr/bin/php7.0 #================================================= # STORE THE CONFIG FILE CHECKSUM #================================================= +ynh_print_info --message="Storing the config file checksum..." # Recalculate and store the checksum of the file for the next upgrade. ynh_store_file_checksum --file="$final_path/$app/sites/default/settings.php" @@ -166,6 +168,7 @@ ynh_systemd_action --service_name=cron --action=restart #================================================= # SECURE FILES AND DIRECTORIES #================================================= +ynh_print_info --message="Securing files and directories..." # Set permissions on app files chown -R $app: $final_path diff --git a/scripts/ynh_install_php__3 b/scripts/ynh_install_php__3 index ca72f7f..8d8323a 100644 --- a/scripts/ynh_install_php__3 +++ b/scripts/ynh_install_php__3 @@ -41,7 +41,7 @@ ynh_install_php () { ynh_pin_repo --package="*" --pin="origin \"packages.sury.org\"" 200 --name=extra_php_version ynh_pin_repo --package="php7.0*" --pin="origin \"packages.sury.org\"" 600 --name=extra_php_version --append - # Advertise service in admin panel + # INTEGRATE SERVICE IN YUNOHOST yunohost service add php${phpversion}-fpm --log "/var/log/php${phpversion}-fpm.log" }