From c28485388da78d9e4633ac97d9c59f10a4d7756c Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 23 Feb 2020 18:02:29 +0100 Subject: [PATCH] Apply example_ynh --- README.md | 1 - README_fr.md | 1 - scripts/backup | 5 +++++ scripts/change_url | 18 ++++++++++++++++++ scripts/install | 10 ++++++++-- scripts/remove | 1 + scripts/restore | 7 +++++++ scripts/upgrade | 5 ++++- scripts/ynh_install_php__3 | 2 +- 9 files changed, 44 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 05db486..3871c8d 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/drupal%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/drupal/) * ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/drupal%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/drupal/) -* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/drupal%20%28Apps%29.svg)](https://ci-stretch.nohost.me/ci/apps/drupal/) ## Links diff --git a/README_fr.md b/README_fr.md index ce4cbf3..0fb7e87 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/drupal%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/drupal/) * ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/drupal%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/drupal/) -* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/drupal%20%28Apps%29.svg)](https://ci-stretch.nohost.me/ci/apps/drupal/) ## 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 32f2a28..b8abe7f 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 68805a3..333658b 100644 --- a/scripts/install +++ b/scripts/install @@ -16,13 +16,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 @@ -31,7 +36,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 @@ -163,7 +167,7 @@ popd #================================================= # SET THE CRON FILE #================================================= -ynh_print_info --message="Setting the cron file" +ynh_print_info --message="Setting the cron file..." cp ../conf/cron /etc/cron.d/$app @@ -173,6 +177,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" @@ -190,6 +195,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 96e92a6..d20c553 100644 --- a/scripts/remove +++ b/scripts/remove @@ -80,6 +80,7 @@ ynh_del_swap #================================================= # 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 fa3c0d6..530ab41 100644 --- a/scripts/restore +++ b/scripts/restore @@ -16,7 +16,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 @@ -48,6 +52,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" @@ -69,6 +74,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 @@ -96,6 +102,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 f0a6503..f5b73af 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -28,9 +28,10 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) language=$(ynh_app_setting_get --app=$app --key=language) 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 @@ popd #================================================= # 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=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" }