diff --git a/check_process b/check_process index 0a909a8..b3002dc 100644 --- a/check_process +++ b/check_process @@ -5,12 +5,12 @@ ;; Test complet ; Manifest - domain="domain.tld" (DOMAIN) - path="/SOGo" (PATH) - admin="john" (USER) + domain="domain.tld" + path="/SOGo" + admin="john" language="French" - is_public=1 (PUBLIC|public=1|private=0) - port="20000" (PORT) + is_public=1 + port="20000" ; Checks pkg_linter=1 setup_sub_dir=1 @@ -22,8 +22,6 @@ upgrade=1 from_commit=cc07f5da79498ef948c31a99f6ace9ad0a5b9ec1 backup_restore=1 multi_instance=0 - incorrect_path=1 - port_already_use=1 (8448) change_url=0 ;;; Upgrade options ; commit=cc07f5da79498ef948c31a99f6ace9ad0a5b9ec1 diff --git a/conf/cron b/conf/cron index 3e4484b..f770c98 100644 --- a/conf/cron +++ b/conf/cron @@ -2,17 +2,17 @@ # Vacation messages expiration # The credentials file should contain the sieve admin credentials (username:passwd) -0 0 * * * __APP__ /opt/yunohost/__APP__/sbin/sogo-tool update-autoreply -p /etc/sogo/sieve.creds +0 0 * * * __APP__ /opt/yunohost/__APP__/sbin/sogo-tool update-autoreply -p /etc/sogo/sieve.creds # Session cleanup - runs every minute # - Ajust the nbMinutes parameter to suit your needs # Example: Sessions without activity since 60 minutes will be dropped: -* * * * * __APP__ /opt/yunohost/__APP__/sbin/sogo-tool expire-sessions 60 > /dev/null 2>&1 +* * * * * __APP__ /opt/yunohost/__APP__/sbin/sogo-tool expire-sessions 60 > /dev/null 2>&1 # Email alarms - runs every minutes # If you need to use SMTP AUTH for outgoing mails, specify credentials to use # with '-p /path/to/credentialsFile' (same format as the sieve credentials) -* * * * * __APP__ /opt/yunohost/__APP__/sbin/sogo-ealarms-notify > /dev/null 2>&1 +* * * * * __APP__ /opt/yunohost/__APP__/sbin/sogo-ealarms-notify > /dev/null 2>&1 # Daily backups # - writes to ~sogo/backups/ by default diff --git a/manifest.json b/manifest.json index 872fd07..6e560eb 100644 --- a/manifest.json +++ b/manifest.json @@ -2,13 +2,20 @@ "name": "SOGo", "id": "sogo", "packaging_format": 1, - "license": "LGPL-2.1,GPL-2.0", - "url": "https://sogo.nu/", - "version": "4.0.7-1~ynh2", "description": { - "en": "An opensource groupware for E-Mail, Contacts and Calender.", - "fr": "Un groupware opensource pour les e-mail, contacts et calendrier" + "en": "Opensource groupware for E-Mail, Contacts and Calender", + "fr": "Groupware opensource pour les e-mail, contacts et calendrier" }, + "version": "5.4.0~ynh1", + "url": "https://sogo.nu/", + "upstream": { + "license": "LGPL-2.1,GPL-2.0", + "website": "https://sogo.nu/", + "demo": "https://demo.sogo.nu/SOGo/", + "admindoc": "https://www.sogo.nu/support.html#/documentation", + "code": "https://github.com/inverse-inc/sogo" + }, + "license": "LGPL-2.1,GPL-2.0", "maintainer": { "name": "Josué Tille", "email": "josue@tille.ch" @@ -24,35 +31,21 @@ "mysql" ], "requirements": { - "yunohost": ">= 4.1" + "yunohost": ">= 4.3.0" }, "arguments": { "install" : [ { "name": "domain", - "type": "domain", - "ask": { - "en": "Choose a domain name for SOGo", - "fr": "Choisissez un nom de domaine pour SOGo" - }, - "example": "example.com" + "type": "domain" }, { "name": "admin", - "type": "user", - "ask": { - "en": "Choose an admin user", - "fr": "Choisissez l’administrateur" - }, - "example": "johndoe" + "type": "user" }, { "name": "is_public", "type": "boolean", - "ask": { - "en": "Is it a public site ? To be able to use caldav and cardav you need to set as public.", - "fr": "Est-ce un site public ? Pour pouvoir utiliser caldav et cardav vous devz mettre en public." - }, "help": { "en": "If it's not public, everybody which want to access to any page of SOGo need to be authenticated on the SSO. On the public mode anybody can access to the authentication page. The shared calendar will be also accessible by anybody who has this link", "fr": "Si n'est pas publique, n'importe qui veux accéder à n'importe quelle page de SOGo doit être authentifié dans le SSO. Dans le mode publique n'importe qui peut accéder à la page d'authentification de SOGo. Les agenda partagé seront aussi accessible par n'import qui qui à ce liens." diff --git a/scripts/_common.sh b/scripts/_common.sh index 0f5273b..1fa5507 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -6,6 +6,9 @@ app=$YNH_APP_INSTANCE_NAME +# dependencies used by the app +pkg_dependencies="sogo stunnel4 memcached" + #================================================= # DEFINE ALL COMMON FONCTIONS #================================================= diff --git a/scripts/backup b/scripts/backup index 05d1216..4568644 100755 --- a/scripts/backup +++ b/scripts/backup @@ -3,47 +3,78 @@ #================================================= # GENERIC START #================================================= +# IMPORT GENERIC HELPERS +#================================================= -# Import common cmd -source ../settings/scripts/experimental_helper.sh +# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh - -# Source YunoHost helpers source /usr/share/yunohost/helpers -# Stop script if errors +#================================================= +# 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 +#================================================= +# LOAD SETTINGS +#================================================= ynh_print_info --message="Loading installation settings..." -# retrieve useful param -domain=$(ynh_app_setting_get --app $app --key domain) -db_name=$(ynh_app_setting_get --app $app --key db_name) +app=$YNH_APP_INSTANCE_NAME + +domain=$(ynh_app_setting_get --app=$app --key=domain) +db_name=$(ynh_app_setting_get --app=$app --key=db_name) #================================================= -# STANDARD BACKUP STEPS +# DECLARE DATA AND CONF FILES TO BACKUP #================================================= +ynh_print_info --message="Declaring files to be backed up..." -ynh_print_info --message="Backing up configuration..." - +#================================================= # BACKUP THE NGINX CONFIGURATION -ynh_backup --src_path "/etc/nginx/conf.d/$domain.d/$app.conf" +#================================================= -# Backup SOGo config -ynh_backup --src_path "/etc/$app" +ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" -# Backup stunnel config -ynh_backup --src_path "/etc/stunnel/$app.conf" +#================================================= +# BACKUP SOGo CONFIGURATION +#================================================= -# Backup Cron -ynh_backup --src_path "/etc/cron.d/$app" +ynh_backup --src_path="/etc/$app" -# Backup Logs -ynh_print_info --message="Backing up logs" -ynh_backup --src_path "/var/log/$app" +#================================================= +# BACKUP STUNNEL CONFIGURATION +#================================================= +ynh_backup --src_path="/etc/stunnel/$app.conf" + +#================================================= +# BACKUP CRON +#================================================= + +ynh_backup --src_path="/etc/cron.d/$app" + +#================================================= +# BACKUP LOGS +#================================================= + +ynh_backup --src_path="/var/log/$app" + +#================================================= # BACKUP THE MYSQL DATABASE -ynh_print_info --message="Backing up database" -ynh_mysql_dump_db "$db_name" > db.sql +#================================================= +ynh_print_info --message="Backing up the MySQL database..." + +ynh_mysql_dump_db --database="$db_name" > db.sql + +#================================================= +# END OF SCRIPT +#================================================= ynh_print_info --message="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 1813e6b..90733ed 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -5,7 +5,6 @@ #================================================= # Import common cmd -source ./experimental_helper.sh source ./_common.sh # IMPORT GENERIC HELPERS diff --git a/scripts/experimental_helper.sh b/scripts/experimental_helper.sh deleted file mode 100644 index e69de29..0000000 diff --git a/scripts/install b/scripts/install index 8e6324d..b063666 100755 --- a/scripts/install +++ b/scripts/install @@ -3,24 +3,38 @@ #================================================= # GENERIC START #================================================= +# IMPORT GENERIC HELPERS +#================================================= -# Import common cmd -source ./experimental_helper.sh -source ./_common.sh - -# Source YunoHost helpers +source _common.sh source /usr/share/yunohost/helpers -# Stop script if errors +#================================================= +# 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 -ynh_script_progression --message="Validating installation parameters..." - +#================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST +#================================================= + domain=$YNH_APP_ARG_DOMAIN admin=$YNH_APP_ARG_ADMIN is_public=$YNH_APP_ARG_IS_PUBLIC +app=$YNH_APP_INSTANCE_NAME + +#================================================= +# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS +#================================================= +ynh_script_progression --message="Validating installation parameters..." --weight=1 + # Set variable path_url="/SOGo" # final_path="/opt/yunohost/$app" @@ -28,33 +42,45 @@ path_url="/SOGo" # Register (book) web path ynh_webpath_register --app $app --domain $domain --path_url $path_url -# Find a port for SOGo -ynh_script_progression --message="Finding available ports..." -port=$(ynh_find_port --port 20000) -smtp_port=$(ynh_find_port --port $((port+1))) - +#================================================= # STORE SETTINGS FROM MANIFEST -ynh_script_progression --message="Storing installation settings..." -ynh_app_setting_set --app $app --key admin --value $admin -ynh_app_setting_set --app $app --key is_public --value $is_public -ynh_app_setting_set --app $app --key smtp_port --value $smtp_port -ynh_app_setting_set --app $app --key web_port --value $port +#================================================= +ynh_script_progression --message="Storing installation settings..." --weight=1 + +ynh_app_setting_set --app=$app --key=domain --value=$domain +ynh_app_setting_set --app=$app --key=path --value=$path_url +ynh_app_setting_set --app=$app --key=admin --value=$admin +ynh_app_setting_set --app=$app --key=is_public --value=$is_public #================================================= # STANDARD MODIFICATIONS #================================================= +# FIND AND OPEN A PORT +#================================================= +ynh_script_progression --message="Finding an available port..." --weight=1 +port=$(ynh_find_port --port 20000) +ynh_app_setting_set --app=$app --key=web_port --value=$port + +smtp_port=$(ynh_find_port --port $((port+1))) +ynh_app_setting_set --app=$app --key=smtp_port --value=$smtp_port + +#================================================= # INSTALL DEPENDENCIES -ynh_script_progression --message="Installing dependencies..." --weight=7 -install_dependance +#================================================= +ynh_script_progression --message="Installing dependencies..." --weight=1 +ynh_install_app_dependencies $pkg_dependencies + +#================================================= # CREATE A MYSQL DATABASE -ynh_script_progression --message="Configuring MySQL database..." -db_name=$(ynh_sanitize_dbid $app) +#================================================= +ynh_script_progression --message="Creating a MySQL database..." --weight=1 + +db_name=$(ynh_sanitize_dbid --db_name=$app) db_user=$db_name -ynh_app_setting_set --app $app --key db_name --value $db_name -ynh_app_setting_set --app $app --key db_user --value $db_user -ynh_mysql_setup_db --db_name $db_name --db_user $db_user +ynh_app_setting_set --app=$app --key=db_name --value=$db_name +ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name ynh_script_progression --message="Configuring application..." --weight=3 @@ -69,39 +95,60 @@ config_stunnel # Install crontab config_cron -#Configure Nginx -ynh_script_progression --message="Configuring nginx..." --weight=1 +#================================================= +# NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Configuring NGINX web server..." --weight=1 + config_nginx +#================================================= +# SECURE FILES AND DIRECTORIES +#================================================= +ynh_script_progression --message="Protecting directory..." --weight=1 + +set_permission + #================================================= # GENERIC FINALIZATION #================================================= +# SETUP LOGROTATE +#================================================= +ynh_script_progression --message="Configuring log rotation..." --weight=1 -# SECURE FILES AND DIRECTORIES -ynh_script_progression --message="Protecting directory..." -set_permission +ynh_use_logrotate --logfile /var/log/$app/sogo.log --nonappend -# configure the sso -ynh_script_progression --message="Configuring permissions..." -ynh_permission_create --permission="sync_client" --allowed='visitors' --auth_header=false\ - --label="Sync client" --protected=true --show_tile=false\ - --additional_urls="/Microsoft-Server-ActiveSync" "/principals" "/.well-known/caldav" "/.well-known/carddav" +#================================================= +# SETUP SSOWAT +#================================================= +ynh_script_progression --message="Configuring permissions..." --weight=1 if [ "$is_public" == '1' ]; then ynh_permission_update --permission "main" --add "visitors" fi -# SETUP LOGROTATE -ynh_script_progression --message="Configuring log rotation..." -ynh_use_logrotate --logfile /var/log/$app/sogo.log --nonappend +ynh_permission_create --permission="sync_client" --allowed='visitors' --auth_header=false\ + --label="Sync client" --protected=true --show_tile=false\ + --additional_urls="/Microsoft-Server-ActiveSync" "/principals" "/.well-known/caldav" "/.well-known/carddav" -# Register service -yunohost service add $app --log "/var/log/$app/sogo.log" +#================================================= +# INTEGRATE SERVICE IN YUNOHOST +#================================================= +ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 -# Restart services -ynh_script_progression --message="Starting sogo services..." --weight=3 -systemctl restart sogo -systemctl restart stunnel4 +yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log" + +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a systemd service..." --weight=1 + +ynh_systemd_action --service_name=$app --action="restart" --log_path="systemd" +ynh_systemd_action --service_name=stunnel4 --action="restart" --log_path="systemd" + +#================================================= +# END OF SCRIPT +#================================================= ynh_script_progression --message="Installation of $app completed" --last diff --git a/scripts/remove b/scripts/remove index 13e6b77..a0845a3 100755 --- a/scripts/remove +++ b/scripts/remove @@ -3,57 +3,100 @@ #================================================= # GENERIC START #================================================= +# IMPORT GENERIC HELPERS +#================================================= -# Import common cmd -source ./experimental_helper.sh -source ./_common.sh - -# Source YunoHost helpers +source _common.sh source /usr/share/yunohost/helpers -ynh_script_progression --message="Loading installation settings..." +#================================================= +# LOAD SETTINGS +#================================================= +ynh_script_progression --message="Loading installation settings..." --weight=1 -# Retrieve app settings app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get --app $app --key domain) -port=$(ynh_app_setting_get --app $app --key port) -db_name=$(ynh_app_setting_get --app $app --key db_name) -db_user=$(ynh_app_setting_get --app $app --key db_user) -final_path=$(ynh_app_setting_get --app $app --key final_path) + +domain=$(ynh_app_setting_get --app=$app --key=domain) +port=$(ynh_app_setting_get --app=$app --key=port) +db_name=$(ynh_app_setting_get --app=$app --key=db_name) +db_user=$db_name +final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= # STANDARD REMOVE #================================================= +# REMOVE SERVICE INTEGRATION IN YUNOHOST +#================================================= -# Remove metapackage and its dependencies -ynh_script_progression --message="Removing dependencies" --weight=10 -ynh_remove_app_dependencies +# Remove the service from the list of services known by YunoHost (added from `yunohost service add`) +if ynh_exec_warn_less yunohost service status $app >/dev/null +then + ynh_script_progression --message="Removing $app service integration..." --weight=1 + yunohost service remove $app +fi + +#================================================= +# STOP AND REMOVE SERVICE +#================================================= +ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1 + +# Remove the dedicated systemd config +ynh_remove_systemd_config + +#================================================= +# REMOVE LOGROTATE CONFIGURATION +#================================================= +ynh_script_progression --message="Removing logrotate configuration..." --weight=1 + +# Remove the app-specific logrotate config +ynh_remove_logrotate + +#================================================= +# REMOVE THE MYSQL DATABASE +#================================================= +ynh_script_progression --message="Removing the MySQL database..." --weight=1 # Remove a database if it exists, along with the associated user -ynh_script_progression --message="Removing databases..." -ynh_mysql_remove_db --db_user $db_user --db_name $db_name +ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name + +#================================================= +# REMOVE APP MAIN DIR +#================================================= +ynh_script_progression --message="Removing app main directory..." --weight=1 # Remove the app directory securely -ynh_script_progression --message="Removing user data..." ynh_secure_remove --file="$final_path" -ynh_script_progression --message="Removing configuration..." +#================================================= +# REMOVE NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1 + +# Remove the dedicated NGINX config +ynh_remove_nginx_config + +#================================================= +# REMOVE DEPENDENCIES +#================================================= +ynh_script_progression --message="Removing dependencies..." --weight=3 + +# Remove metapackage and its dependencies +ynh_remove_app_dependencies + +#================================================= +# SPECIFIC REMOVE +#================================================= +# REMOVE VARIOUS FILES +#================================================= +ynh_script_progression --message="Removing various files..." --weight=1 -# Remove sogo config ynh_secure_remove --file="/etc/$app" # Remove stunnel config ynh_secure_remove --file="/etc/stunnel/$app.conf" -# Remove nginx config -ynh_script_progression --message="Removing nginx configuration..." -ynh_remove_nginx_config - - -# Remove service -yunohost service remove $app - -# Remove the app-specific logrotate config -ynh_remove_logrotate +#================================================= +# END OF SCRIPT +#================================================= ynh_script_progression --message="Removal of $app completed" --last diff --git a/scripts/restore b/scripts/restore index 4731326..7b308b0 100755 --- a/scripts/restore +++ b/scripts/restore @@ -5,7 +5,6 @@ #================================================= # Import common cmd -source ../settings/scripts/experimental_helper.sh source ../settings/scripts/_common.sh # Source YunoHost helpers diff --git a/scripts/upgrade b/scripts/upgrade index 8e6e654..10edd1c 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -3,36 +3,45 @@ #================================================= # GENERIC START #================================================= - -# Import common cmd -source ./experimental_helper.sh -source ./_common.sh - # IMPORT GENERIC HELPERS +#================================================= + +source _common.sh source /usr/share/yunohost/helpers -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -ynh_script_progression --message="Loading installation settings..." - +#================================================= # LOAD SETTINGS -domain=$(ynh_app_setting_get --app $app --key domain) -path_url=$(ynh_normalize_url_path --path_url $(ynh_app_setting_get --app $app --key path)) -admin=$(ynh_app_setting_get --app $app --key admin) -is_public=$(ynh_app_setting_get --app $app --key is_public) -port=$(ynh_app_setting_get --app $app --key web_port) -smtp_port=$(ynh_app_setting_get --app $app --key smtp_port) -db_name=$(ynh_app_setting_get --app $app --key db_name) -db_user=$(ynh_app_setting_get --app $app --key db_user) -db_pwd=$(ynh_app_setting_get --app $app --key mysqlpwd) +#================================================= +ynh_script_progression --message="Loading installation settings..." --weight=1 + +app=$YNH_APP_INSTANCE_NAME + +domain=$(ynh_app_setting_get --app=$app --key=domain) +path_url=$(ynh_app_setting_get --app=$app --key=path) +admin=$(ynh_app_setting_get --app=$app --key=admin) +is_public=$(ynh_app_setting_get --app=$app --key=is_public) +port=$(ynh_app_setting_get --app=$app --key=web_port) +smtp_port=$(ynh_app_setting_get --app=$app --key=smtp_port) +db_name=$(ynh_app_setting_get --app=$app --key=db_name) +db_user=$db_name +db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) + +#================================================= +# CHECK VERSION +#================================================= + +upgrade_type=$(ynh_check_app_version_changed) + +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= +ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1 # Backup the current version of the app ynh_backup_before_upgrade - ynh_clean_setup () { - # restore it if the upgrade fails - ynh_restore_upgradebackup + # Restore it if the upgrade fails + ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -140,7 +149,12 @@ yunohost service add $app --log "/var/log/$app/sogo.log" # Restart services ynh_script_progression --message="Starting SOGo services..." --weight=3 + systemctl restart sogo systemctl restart stunnel4 +#================================================= +# END OF SCRIPT +#================================================= + ynh_script_progression --message="Upgrade of $app completed" --last