diff --git a/conf/sogo.conf b/conf/sogo.conf index 05ce975..4fcf110 100644 --- a/conf/sogo.conf +++ b/conf/sogo.conf @@ -1,4 +1,5 @@ { + /* WARNING: Don't edit this file. All change will be removed after each app upgrade */ WOPort = 127.0.0.1:__PORT__; WOLogFile = /var/log/__APP__/sogo.log; /* Fix Yunohost Tile */ diff --git a/manifest.toml b/manifest.toml index f7484df..ad8e9c9 100644 --- a/manifest.toml +++ b/manifest.toml @@ -7,7 +7,7 @@ name = "SOGo" description.en = "Opensource groupware for E-Mail, Contacts and Calender" description.fr = "Groupware opensource pour les e-mail, contacts et calendrier" -version = "5.0.1~ynh4" +version = "5.0.1~ynh5" maintainers = ["Josué Tille"] @@ -21,7 +21,8 @@ cpe = "cpe:2.3:a:alinto:sogo" fund = "https://www.sogo.nu/partner.html" [integration] -yunohost = ">= 11.2" +yunohost = ">= 11.2.30" +helpers_version = "2.1" architectures = "all" multi_instance = false ldap = true diff --git a/scripts/_common.sh b/scripts/_common.sh index c3d16fa..48027fe 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,11 +1,7 @@ #!/bin/bash #================================================= -# COMMON VARIABLES -#================================================= - -#================================================= -# PERSONAL HELPERS +# COMMON VARIABLES AND CUSTOM HELPERS #================================================= config_nginx() { @@ -46,7 +42,7 @@ location = /.well-known/carddav { rewrite ^ https://$server_name/SOGo/dav/; }' - ynh_add_nginx_config + ynh_config_add_nginx if ! is_url_handled -d "$domain" -p "/principals"; then echo "$principals_block" >> "$nginx_config" @@ -60,7 +56,7 @@ location = /.well-known/carddav { if ! is_url_handled -d "$domain" -p "/.wellk-nown/carddav"; then echo "$carddav_block" >> "$nginx_config" fi - ynh_store_file_checksum --file="$nginx_config" + ynh_store_file_checksum "$nginx_config" systemctl reload nginx.service } @@ -75,13 +71,9 @@ set_permissions() { chmod 644 "/etc/cron.d/$app" } -#================================================= -# EXPERIMENTAL HELPERS -#================================================= - is_url_handled() { # Declare an array to define the options of this helper. - local legacy_args=dp + #REMOVEME? local legacy_args=dp declare -Ar args_array=( [d]=domain= [p]=path= ) local domain local path @@ -108,7 +100,3 @@ is_url_handled() { return 1 fi } - -#================================================= -# FUTURE OFFICIAL HELPERS -#================================================= diff --git a/scripts/backup b/scripts/backup index 228d9a0..2458e56 100755 --- a/scripts/backup +++ b/scripts/backup @@ -1,49 +1,40 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC 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 -#================================================= -# DECLARE DATA AND CONF FILES TO BACKUP -#================================================= -ynh_print_info --message="Declaring files to be backed up..." +ynh_print_info "Declaring files to be backed up..." #================================================= # SYSTEM CONFIGURATION #================================================= # Backup the nginx configuration -ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # BACKUP VARIOUS FILES #================================================= # Backup SOGo configuration -ynh_backup --src_path="/etc/$app" +ynh_backup "/etc/$app" # Backup cron -ynh_backup --src_path="/etc/cron.d/$app" +ynh_backup "/etc/cron.d/$app" # Backup logs -ynh_backup --src_path="/var/log/$app" +ynh_backup "/var/log/$app" #================================================= # BACKUP THE MYSQL DATABASE #================================================= -ynh_print_info --message="Backing up the MySQL database..." +ynh_print_info "Backing up the MySQL database..." -ynh_mysql_dump_db --database="$db_name" > db.sql +ynh_mysql_dump_db > db.sql #================================================= # END OF SCRIPT #================================================= -ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." +ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/change_url b/scripts/change_url index 5c76915..86f07c8 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -1,29 +1,21 @@ #!/bin/bash -#================================================= -# GENERIC STARTING -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers # Check if the new path stay /SOGo if not exit if [[ $path != "/SOGo" ]]; then - ynh_die --message "You can't use an other path than '/SOGo'" + ynh_die "You can't use an other path than '/SOGo'" fi #================================================= -# STANDARD MODIFICATIONS -#================================================= -ynh_script_progression --message="Updating NGINX configuration..." +ynh_script_progression "Updating NGINX configuration..." -ynh_change_url_nginx_config +ynh_config_change_url_nginx config_nginx #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Change of URL completed for $app" --last +ynh_script_progression "Change of URL completed for $app" diff --git a/scripts/install b/scripts/install index 9ef697b..5821763 100755 --- a/scripts/install +++ b/scripts/install @@ -1,28 +1,22 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers if [[ $path != "/SOGo" ]]; then - ynh_die --message "You can't install SOGo on other path than '/SOGo'" + ynh_die "You can't install SOGo on other path than '/SOGo'" fi #================================================= # ADD A CONFIGURATION #================================================= -ynh_script_progression --message="Configuring application..." --weight=3 +ynh_script_progression "Configuring application..." mkdir -p "/etc/$app" -ynh_add_config --template="sogo.conf" --destination="/etc/$app/sogo.conf" +ynh_config_add --template="sogo.conf" --destination="/etc/$app/sogo.conf" config_nginx -ynh_use_logrotate --logfile="/var/log/$app/sogo.log" --nonappend +ynh_config_add_logrotate "/var/log/$app/sogo.log" yunohost service add "sogo" --description="Groupware for E-Mail, Contacts and Calender" --log="/var/log/$app/$app.log" @@ -31,12 +25,12 @@ set_permissions #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=1 +ynh_script_progression "Starting $app's systemd service..." -ynh_systemd_action --service_name="$app" --action="restart" --log_path="systemd" +ynh_systemctl --service="$app" --action="restart" --log_path="systemd" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of $app completed" --last +ynh_script_progression "Installation of $app completed" diff --git a/scripts/remove b/scripts/remove index e40fa3e..fabfd8a 100755 --- a/scripts/remove +++ b/scripts/remove @@ -1,44 +1,38 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers #================================================= # REMOVE SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Removing system configurations related to $app..." --weight=1 +ynh_script_progression "Removing system configurations related to $app..." yunohost service remove "sogo" # Remove the dedicated systemd config -ynh_remove_systemd_config +ynh_config_remove_systemd # Remove the app-specific logrotate config -ynh_remove_logrotate +ynh_config_remove_logrotate # Remove the dedicated NGINX config -ynh_remove_nginx_config +ynh_config_remove_nginx #================================================= # SPECIFIC REMOVE #================================================= # REMOVE VARIOUS FILES #================================================= -ynh_script_progression --message="Removing various files..." --weight=1 +ynh_script_progression "Removing various files..." -ynh_secure_remove --file="/etc/$app" +ynh_safe_rm "/etc/$app" # Remove stunnel config -ynh_secure_remove --file="/etc/stunnel/$app.conf" +ynh_safe_rm "/etc/stunnel/$app.conf" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of $app completed" --last +ynh_script_progression "Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index 936d2a7..1f9d40b 100755 --- a/scripts/restore +++ b/scripts/restore @@ -1,11 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC 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 @@ -13,20 +7,19 @@ source /usr/share/yunohost/helpers #================================================= # RESTORE THE MYSQL DATABASE #================================================= -ynh_script_progression --message="Restoring the MySQL database..." --weight=1 +ynh_script_progression "Restoring the MySQL database..." -ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < ./db.sql +ynh_mysql_db_shell < ./db.sql #================================================= # RESTORE VARIOUS FILES #================================================= -ynh_script_progression --message="Restoring various files..." --weight=1 -ynh_restore - +ynh_script_progression "Restoring various files..." +ynh_restore_everything #================================================= # RESTORE SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 +ynh_script_progression "Restoring system configurations related to $app..." yunohost service add "sogo" --description="Groupware for E-Mail, Contacts and Calender" --log="/var/log/$app/$app.log" set_permissions @@ -34,22 +27,22 @@ set_permissions #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=3 +ynh_script_progression "Starting $app's systemd service..." -ynh_systemd_action --service_name="$app" --action="restart" --log_path="systemd" +ynh_systemctl --service="$app" --action="restart" --log_path="systemd" #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 +ynh_script_progression "Reloading NGINX web server..." -ynh_systemd_action --service_name="nginx" --action=reload +ynh_systemctl --service="nginx" --action=reload # Use logrotate to manage app-specific logfile(s) -ynh_use_logrotate --logfile="/var/log/$app/sogo.log" --nonappend +ynh_config_add_logrotate "/var/log/$app/sogo.log" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Restoration completed for $app" --last +ynh_script_progression "Restoration completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index 000e712..b14887b 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,60 +1,54 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers #================================================= # UPGRADE SETTINGS FROM OLD INSTALL #================================================= -ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 +ynh_script_progression "Ensuring downward compatibility..." # Manage migrations -ynh_script_progression --message="Migrating database if needed..." +ynh_script_progression "Migrating database if needed..." -if ynh_compare_current_package_version --comparison le --version 4.0.0~ynh0; then - ynh_replace_string --match_string __APP__ --replace_string $app --target_file migrations/3.2-4.0.sh - ynh_replace_string --match_string __DBUSER__ --replace_string $db_user --target_file migrations/3.2-4.0.sh - ynh_replace_string --match_string __DBPASS__ --replace_string $db_pwd --target_file migrations/3.2-4.0.sh +if ynh_app_upgrading_from_version_before_or_equal_to 4.0.0~ynh0; then + ynh_replace --match=__APP__ --replace="$app" --file=migrations/3.2-4.0.sh + ynh_replace --match=__DBUSER__ --replace="$db_user" --file=migrations/3.2-4.0.sh + ynh_replace --match=__DBPASS__ --replace="$db_pwd" --file=migrations/3.2-4.0.sh bash migrations/3.2-4.0.sh fi #================================================= # UPDATE A CONFIG FILE #================================================= -ynh_script_progression --message="Configuring application..." --weight=1 +ynh_script_progression "Configuring application..." # Configure SOGO -ynh_add_config --template="sogo.conf" --destination="/etc/$app/sogo.conf" +ynh_config_add --template="sogo.conf" --destination="/etc/$app/sogo.conf" #================================================= # REAPPLY SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 +ynh_script_progression "Upgrading system configurations related to $app..." config_nginx yunohost service add "sogo" --description="Groupware for E-Mail, Contacts and Calender" --log="/var/log/$app/$app.log" # Use logrotate to manage app-specific logfile(s) -ynh_use_logrotate --logfile="/var/log/$app/sogo.log" --nonappend +ynh_config_add_logrotate "/var/log/$app/sogo.log" set_permissions #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=1 +ynh_script_progression "Starting $app's systemd service..." -ynh_systemd_action --service_name="$app" --action="restart" --log_path="systemd" +ynh_systemctl --service="$app" --action="restart" --log_path="systemd" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" --last +ynh_script_progression "Upgrade of $app completed" diff --git a/tests.toml b/tests.toml index 99fb3c9..9402fbb 100644 --- a/tests.toml +++ b/tests.toml @@ -7,3 +7,4 @@ test_format = 1.0 test_upgrade_from.cc07f5da79498ef948c31a99f6ace9ad0a5b9ec1.name = "Before group permission support" test_upgrade_from.2fc174c57586df38506a07195decb08eed02f55f.name = "Before refactoring" test_upgrade_from.732e6d2962ed7e0fb9cb7a807e2b095adeab35c3.name = "last packagingv1 version" + test_upgrade_from.e3bb393e5e40ddb2a3c01cfc23b9f43f27f4ff27.name = "Before helper 2.1"