1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/roundcube_ynh.git synced 2024-09-03 20:16:28 +02:00

[fix] add ynh_exit_properly on generic function

This commit is contained in:
magikcypress 2017-06-18 01:53:14 +02:00
parent 2c27e1d7b7
commit b27fa9e7cc
No known key found for this signature in database
GPG key ID: 3B3C7CD61957AC9A
2 changed files with 35 additions and 1 deletions

View file

@ -343,6 +343,40 @@ ynh_backup_before_upgrade () { # Backup the current version of the app, restore
fi fi
} }
# Manage a fail of the script
#
# Print a warning to inform that the script was failed
# Execute the ynh_clean_setup function if used in the app script
#
# usage of ynh_clean_setup function
# This function provide a way to clean some residual of installation that not managed by remove script.
# To use it, simply add in your script:
# ynh_clean_setup () {
# instructions...
# }
# This function is optionnal.
#
# Usage: ynh_exit_properly is used only by the helper ynh_check_error.
# You must not use it directly.
ynh_exit_properly () {
exit_code=$?
if [ "$exit_code" -eq 0 ]; then
ynh_die # Exit without error if the script ended correctly
fi
trap '' EXIT # Ignore new exit signals
set +eu # Do not exit anymore if a command fail or if a variable is empty
echo -e "!!\n $app's script has encountered an error. Its execution was cancelled.\n!!" >&2
if type -t ynh_clean_setup > /dev/null; then # Check if the function exist in the app script.
ynh_clean_setup # Call the function to do specific cleaning for the app.
fi
ynh_die # Exit with error status
}
# Exit if an error occurs during the execution of the script. # Exit if an error occurs during the execution of the script.
# #
# Stop immediatly the execution if an error occured or if a empty variable is used. # Stop immediatly the execution if an error occured or if a empty variable is used.

View file

@ -80,7 +80,7 @@ exec_composer admin "$final_path" require \
"sblaisot/automatic_addressbook 0.4.2" "sblaisot/automatic_addressbook 0.4.2"
installed_plugins+=" 'contextmenu', 'automatic_addressbook'," installed_plugins+=" 'contextmenu', 'automatic_addressbook',"
# Instal CardDAV plugin # Install CardDAV plugin
if [[ $with_carddav -eq 1 ]]; then if [[ $with_carddav -eq 1 ]]; then
install_carddav "$final_path" \ install_carddav "$final_path" \
&& installed_plugins+=" 'carddav'," \ && installed_plugins+=" 'carddav'," \