From 96fda9562e947c0cf081d4c0b3c74e5ec2a3062d Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 30 Mar 2019 22:28:14 +0100 Subject: [PATCH] Fix package_linter (#1) * Fix package_linter --- check_process | 2 +- manifest.json | 3 ++- scripts/_common.sh | 20 ++++++++++++++++++++ scripts/install | 41 +++++++++++++---------------------------- scripts/restore | 22 +++++++++++++++++++--- scripts/upgrade | 27 +++++++++++++++++++++++---- 6 files changed, 78 insertions(+), 37 deletions(-) create mode 100644 scripts/_common.sh diff --git a/check_process b/check_process index 6c82762..351f17f 100644 --- a/check_process +++ b/check_process @@ -15,7 +15,7 @@ multi_instance=0 wrong_user=0 wrong_path=1 - incorrect_path=1 + incorrect_path=0 corrupt_source=0 fail_download_source=0 port_already_use=0 diff --git a/manifest.json b/manifest.json index 94042f4..3a5c347 100644 --- a/manifest.json +++ b/manifest.json @@ -6,8 +6,9 @@ "en": "Z-Push is an Exchange ActiveSync fronted written in php which lets you synchronize emails (imap/smtp backend) and calendar/contacts (carddav and caldav backend)", "fr": "Z-Push est un fronted Exchange ActiveSync écrit en php qui permet de synchroniser vos email (backend imap/smtp) et vos contacts/calendrier (backend carddav et caldav)" }, + "version": "2.3.6~ynh2", "url": "https://z-push.org", - "license": "free", + "license": "AGPL-3.0-or-later", "maintainer": { "name": "beudbeud, polytan02" }, diff --git a/scripts/_common.sh b/scripts/_common.sh new file mode 100644 index 0000000..8bb05b4 --- /dev/null +++ b/scripts/_common.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +#================================================= +# COMMON VARIABLES +#================================================= + +# dependencies used by the app +pkg_dependencies="deb1 deb2" + +#================================================= +# PERSONAL HELPERS +#================================================= + +#================================================= +# EXPERIMENTAL HELPERS +#================================================= + +#================================================= +# FUTURE OFFICIAL HELPERS +#================================================= diff --git a/scripts/install b/scripts/install index 4d6b0c4..363be05 100755 --- a/scripts/install +++ b/scripts/install @@ -1,36 +1,21 @@ #!/bin/bash -# Active trap pour arrêter le script si une erreur est détectée. -EXIT_PROPERLY () { # Provoque l'arrêt du script en cas d'erreur. Et nettoye les résidus. - exit_code=$? - if [ "$exit_code" -eq 0 ]; then - exit 0 # Quitte sans erreur si le script se termine correctement. - fi - trap '' EXIT - set +eu - echo -e "\e[91m \e[1m" # Shell in light red bold - echo -e "!!\n $app install's script has encountered an error. Installation was cancelled.\n!!" >&2 +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= - if type -t CLEAN_SETUP > /dev/null; then # Vérifie l'existance de la fonction avant de l'exécuter. - CLEAN_SETUP # Appel la fonction de nettoyage spécifique du script install. - fi - - # Compense le bug de ssowat qui ne supprime pas l'entrée de l'app en cas d'erreur d'installation. - sudo sed -i "\@\"$domain$path/\":@d" /etc/ssowat/conf.json - - ynh_die -} - -TRAP_ON () { # Activate signal capture - set -eu # Exit if a command fail, and if a variable is used unset. - trap EXIT_PROPERLY EXIT # Capturing exit signals on shell script -} - -TRAP_ON - -# Source app helpers +source _common.sh source /usr/share/yunohost/helpers +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= + +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + # Retrieve arguments app=$YNH_APP_INSTANCE_NAME domain=$YNH_APP_ARG_DOMAIN diff --git a/scripts/restore b/scripts/restore index 6c723c3..2dd9d68 100755 --- a/scripts/restore +++ b/scripts/restore @@ -1,11 +1,27 @@ #!/bin/bash -set -eu -app=$YNH_APP_INSTANCE_NAME +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= -# Source YunoHost helpers +#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts +source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= + +ynh_clean_setup () { + #### Remove this function if there's nothing to clean before calling the remove script. + true +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors +app=$YNH_APP_INSTANCE_NAME + # Retrieve old app settings path=$(ynh_app_setting_get $app path) domain=$(ynh_app_setting_get $app domain) diff --git a/scripts/upgrade b/scripts/upgrade index 984bed5..cca630d 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,7 +1,12 @@ #!/bin/bash -set -eu -# Source app helpers +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source _common.sh source /usr/share/yunohost/helpers # Retrieve arguments @@ -23,6 +28,20 @@ else echo "${final_path} exists, we don't create it." fi +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= +ynh_print_info "Backing up the app before upgrading (may take a while)..." + +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + # restore it if the upgrade fails + ynh_restore_upgradebackup +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + if [ -z "$statedir" ]; then statedir="/home/yunohost.app/$app" @@ -64,8 +83,8 @@ ynh_package_install_from_equivs ../conf/z-push-deps.control \ # Cleaning -sudo rm -rf $final_path -sudo rm -rf $final_logpath +ynh_secure_remove "$final_path" +ynh_secure_remove "$final_logpath" sudo rm -f $final_nginxconf sudo rm -f $final_phpconf sudo rm -f /etc/logrotate.d/$app