From 9a2b82739b48c55a24c8a40424d1a5c8b1a5bebd Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 23 Feb 2020 17:38:13 +0100 Subject: [PATCH] Apply example_ynh --- README.md | 1 - README_fr.md | 1 - scripts/backup | 5 +++++ scripts/change_url | 18 ++++++++++++++++++ scripts/install | 8 +++++++- scripts/remove | 1 + scripts/restore | 7 +++++++ scripts/upgrade | 3 +++ scripts/ynh_install_php__3 | 2 +- 9 files changed, 42 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 445bf01..d72ebe0 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/civicrm_drupal7%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/civicrm_drupal7/) * ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/civicrm_drupal7%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/civicrm_drupal7/) -* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/civicrm_drupal7%20%28Apps%29.svg)](https://ci-stretch.nohost.me/ci/apps/civicrm_drupal7/) ## Links diff --git a/README_fr.md b/README_fr.md index 60cfd6b..4a6ff35 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/civicrm_drupal7%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/civicrm_drupal7/) * ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/civicrm_drupal7%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/civicrm_drupal7/) -* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/civicrm_drupal7%20%28Apps%29.svg)](https://ci-stretch.nohost.me/ci/apps/civicrm_drupal7/) ## Liens diff --git a/scripts/backup b/scripts/backup index 84308f2..015da10 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 @@ -63,6 +67,7 @@ ynh_mysql_dump_db --database="$db_name" > db.sql #================================================= # BACKUP A CRON FILE #================================================= +ynh_print_info --message="Backing up a cron file..." ynh_backup --src_path="/etc/cron.d/$app" 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 347c210..830a1ab 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 @@ -187,6 +191,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" @@ -204,6 +209,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/remove b/scripts/remove index e621e6d..6fcaa13 100644 --- a/scripts/remove +++ b/scripts/remove @@ -72,6 +72,7 @@ ynh_remove_nginx_config #================================================= # REMOVE THE CRON FILE #================================================= +ynh_print_info --message="Removing the cron file..." # Remove a cron file ynh_secure_remove --file="/etc/cron.d/$app" diff --git a/scripts/restore b/scripts/restore index 3492801..818f2cb 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 @@ -95,6 +101,7 @@ ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./ #================================================= # 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 fa1d19c..4bddd3f 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) @@ -154,6 +155,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" @@ -175,6 +177,7 @@ ynh_systemd_action --service_name=cron --action=reload #================================================= # 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" }