From 3e26ede40885463fe79c50034f777b8a79e04d34 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Wed, 11 Oct 2023 06:23:07 +0000 Subject: [PATCH 01/16] Upgrade to v2.7.1 --- conf/app.src | 4 ++-- manifest.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/conf/app.src b/conf/app.src index 31e3573..16afa0f 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/Z-Hub/Z-Push/archive/2.7.0.tar.gz -SOURCE_SUM=0d3507af509723c0a145a910c707dce81adb5535b83455c05ebf070880988c66 +SOURCE_URL=https://github.com/Z-Hub/Z-Push/archive/2.7.1.tar.gz +SOURCE_SUM=7aadddb5da06494a35c79e4b70d6ade6b2f62203f3df343077731f8952b64a41 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/manifest.json b/manifest.json index 900c066..c4874ba 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "ActiveSync frontend that helps you synchronize emails, calendar and contacts", "fr": "Frontend ActiveSync qui permet de synchroniser emails, calendrier et contacts" }, - "version": "2.7.0~ynh3", + "version": "2.7.1~ynh1", "url": "https://z-push.org", "upstream": { "license": "AGPL-3.0-or-later", From 5a20347262434377271b0f7419fff0b8472cb315 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Wed, 11 Oct 2023 06:23:16 +0000 Subject: [PATCH 02/16] Auto-update README --- README.md | 3 +-- README_fr.md | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 5e9cf5d..a1c586f 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in Z-Push is an Exchange ActiveSync fronted written in PHP which lets you synchronize emails (IMAP/SMTP backend) and calendar/contacts (cardDAV and caldDAV backend) -**Shipped version:** 2.7.0~ynh3 +**Shipped version:** 2.7.1~ynh1 ## Disclaimers / important information * would be better to create a dedicated domain: autodiscover.yourdomain.org @@ -29,7 +29,6 @@ Z-Push is an Exchange ActiveSync fronted written in PHP which lets you synchroni * Official app website: * Official admin documentation: * Upstream app code repository: -* YunoHost documentation for this app: * Report a bug: ## Developer info diff --git a/README_fr.md b/README_fr.md index 2ecba6d..c65774a 100644 --- a/README_fr.md +++ b/README_fr.md @@ -19,7 +19,7 @@ Si vous n’avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) po Z-Push is an Exchange ActiveSync fronted written in PHP which lets you synchronize emails (IMAP/SMTP backend) and calendar/contacts (cardDAV and caldDAV backend) -**Version incluse :** 2.7.0~ynh3 +**Version incluse :** 2.7.1~ynh1 ## Avertissements / informations importantes * would be better to create a dedicated domain: autodiscover.yourdomain.org @@ -29,7 +29,6 @@ Z-Push is an Exchange ActiveSync fronted written in PHP which lets you synchroni * Site officiel de l’app : * Documentation officielle de l’admin : * Dépôt de code officiel de l’app : -* Documentation YunoHost pour cette app : * Signaler un bug : ## Informations pour les développeurs From 366ed99d9947bc79defed910619bee599b1a3094 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Thu, 2 Nov 2023 21:43:27 +0100 Subject: [PATCH 03/16] v2 --- conf/app.src | 7 --- conf/config.php | 2 +- conf/nginx.conf | 8 ++-- manifest.toml | 48 +++++++++++++++++++ scripts/_common.sh | 6 +-- scripts/backup | 20 ++++---- scripts/install | 114 ++++++++++++++++++++++----------------------- scripts/remove | 24 +++++----- scripts/restore | 52 ++++++++++----------- scripts/upgrade | 100 +++++++++++++++++++-------------------- 10 files changed, 211 insertions(+), 170 deletions(-) delete mode 100644 conf/app.src create mode 100644 manifest.toml diff --git a/conf/app.src b/conf/app.src deleted file mode 100644 index 16afa0f..0000000 --- a/conf/app.src +++ /dev/null @@ -1,7 +0,0 @@ -SOURCE_URL=https://github.com/Z-Hub/Z-Push/archive/2.7.1.tar.gz -SOURCE_SUM=7aadddb5da06494a35c79e4b70d6ade6b2f62203f3df343077731f8952b64a41 -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=tar.gz -SOURCE_IN_SUBDIR=true -SOURCE_FILENAME= -SOURCE_EXTRACT=true diff --git a/conf/config.php b/conf/config.php index 14cabe9..e9e9c99 100644 --- a/conf/config.php +++ b/conf/config.php @@ -65,7 +65,7 @@ * State migration script is available, more informations: https://wiki.z-hub.io/x/xIAa */ define('STATE_MACHINE', 'FILE'); - define('STATE_DIR', '__DATADIR__/'); + define('STATE_DIR', '__DATA_DIR__/'); /********************************************************************************** * IPC - InterProcessCommunication diff --git a/conf/nginx.conf b/conf/nginx.conf index 2b61559..4fe0ecd 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -2,7 +2,7 @@ location /Microsoft-Server-ActiveSync { # Path to source - alias __FINALPATH__/; + alias __INSTALL_DIR__/; index index.php; @@ -27,7 +27,7 @@ location /Microsoft-Server-ActiveSync { } location /AutoDiscover/AutoDiscover.xml { - alias __FINALPATH__/autodiscover/autodiscover.php; + alias __INSTALL_DIR__/autodiscover/autodiscover.php; fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock; include fastcgi_params; fastcgi_param HTTPS on; @@ -35,7 +35,7 @@ location /AutoDiscover/AutoDiscover.xml { } location /Autodiscover/Autodiscover.xml { - alias __FINALPATH__/autodiscover/autodiscover.php; + alias __INSTALL_DIR__/autodiscover/autodiscover.php; fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock; include fastcgi_params; fastcgi_param HTTPS on; @@ -43,7 +43,7 @@ location /Autodiscover/Autodiscover.xml { } location /autodiscover/autodiscover.xml { - alias __FINALPATH__/autodiscover/autodiscover.php; + alias __INSTALL_DIR__/autodiscover/autodiscover.php; fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock; include fastcgi_params; fastcgi_param HTTPS on; diff --git a/manifest.toml b/manifest.toml new file mode 100644 index 0000000..fc9430b --- /dev/null +++ b/manifest.toml @@ -0,0 +1,48 @@ +packaging_format = 2 + +id = "z-push" +name = "Z-Push" +description.en = "ActiveSync frontend that helps you synchronize emails, calendar and contacts" +description.fr = "Frontend ActiveSync qui permet de synchroniser emails, calendrier et contacts" + +version = "2.7.1~ynh1" + +maintainers = ["yalh76"] + +[upstream] +license = "AGPL-3.0-or-later" +website = "http://z-push.org" +admindoc = "https://wiki.z-hub.io/display/ZP/Documentation" +code = "https://github.com/Z-Hub/Z-Push" +cpe = "???" # FIXME: optional but recommended if relevant, this is meant to contain the Common Platform Enumeration, which is sort of a standard id for applications defined by the NIST. In particular, Yunohost may use this is in the future to easily track CVE (=security reports) related to apps. The CPE may be obtained by searching here: https://nvd.nist.gov/products/cpe/search. For example, for Nextcloud, the CPE is 'cpe:2.3:a:nextcloud:nextcloud' (no need to include the version number) +fund = "???" # FIXME: optional but recommended (or remove if irrelevant / not applicable). This is meant to be an URL where people can financially support this app, especially when its development is based on volunteers and/or financed by its community. YunoHost may later advertise it in the webadmin. + +[integration] +yunohost = ">= 11.0.9" +architectures = "all" # FIXME: can be replaced by a list of supported archs using the dpkg --print-architecture nomenclature (amd64/i386/armhf/arm64), for example: ["amd64", "i386"] +multi_instance = true +ldap = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "sso" key : the "ldap" key corresponds to wether or not a user *can* login on the app using its YunoHost credentials. +sso = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "ldap" key : the "sso" key corresponds to wether or not a user is *automatically logged-in* on the app when logged-in on the YunoHost portal. +disk = "50M" # FIXME: replace with an **estimate** minimum disk requirement. e.g. 20M, 400M, 1G, ... +ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... +ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... + + [install.domain] + # this is a generic question - ask strings are automatically handled by Yunohost's core + type = "domain" + full_domain = true + +[resources] + [resources.sources.main] + url = "https://github.com/Z-Hub/Z-Push/archive/2.7.1.tar.gz" + sha256 = "7aadddb5da06494a35c79e4b70d6ade6b2f62203f3df343077731f8952b64a41" + + + [resources.system_user] + + [resources.install_dir] + + [resources.data_dir] + + [resources.permissions] + main.url = "/" diff --git a/scripts/_common.sh b/scripts/_common.sh index 1c72e28..ec2e5a0 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,12 +4,12 @@ # COMMON VARIABLES #================================================= -YNH_PHP_VERSION="7.4" +#REMOVEME? YNH_PHP_VERSION="7.4" -php_dependencies="php${YNH_PHP_VERSION}-soap php${YNH_PHP_VERSION}-imap php${YNH_PHP_VERSION}-xsl php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-ldap php${YNH_PHP_VERSION}-cli php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-memcached" +#REMOVEME? php_dependencies="php${YNH_PHP_VERSION}-soap php${YNH_PHP_VERSION}-imap php${YNH_PHP_VERSION}-xsl php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-ldap php${YNH_PHP_VERSION}-cli php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-memcached" # dependencies used by the app (must be on a single line) -pkg_dependencies="libawl-php $php_dependencies" +#REMOVEME? pkg_dependencies="libawl-php $php_dependencies" #================================================= diff --git a/scripts/backup b/scripts/backup index c271a32..2a933b9 100755 --- a/scripts/backup +++ b/scripts/backup @@ -14,24 +14,24 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { +#REMOVEME? ynh_clean_setup () { true } # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= ynh_print_info --message="Loading settings..." -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? app=$YNH_APP_INSTANCE_NAME -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -domain=$(ynh_app_setting_get --app=$app --key=domain) -phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) -datadir=$(ynh_app_setting_get --app=$app --key=datadir) -final_logpath=$(ynh_app_setting_get --app=$app --key=final_logpath) +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) +#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) +#REMOVEME? phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir) +#REMOVEME? final_logpath=$(ynh_app_setting_get --app=$app --key=final_logpath) #================================================= # DECLARE DATA AND CONF FILES TO BACKUP @@ -42,13 +42,13 @@ ynh_print_info --message="Declaring files to be backed up..." # BACKUP THE APP MAIN DIR #================================================= -ynh_backup --src_path="$final_path" +ynh_backup --src_path="$install_dir" #================================================= # BACKUP THE DATA DIR #================================================= -ynh_backup --src_path="$datadir" --is_big +ynh_backup --src_path="$data_dir" --is_big #================================================= # BACKUP THE NGINX CONFIGURATION diff --git a/scripts/install b/scripts/install index f3825c3..b36929c 100755 --- a/scripts/install +++ b/scripts/install @@ -13,75 +13,75 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { +#REMOVEME? ynh_clean_setup () { true } # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= -domain=$YNH_APP_ARG_DOMAIN -path_url="/Microsoft-Server-ActiveSync" +#REMOVEME? domain=$YNH_APP_ARG_DOMAIN +path="/Microsoft-Server-ActiveSync" -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= -ynh_script_progression --message="Validating installation parameters..." --weight=1 +#REMOVEME? ynh_script_progression --message="Validating installation parameters..." --weight=1 -final_path=/var/www/$app -test ! -e "$final_path" || ynh_die --message="This path already contains a folder" +#REMOVEME? install_dir=/var/www/$app +#REMOVEME? test ! -e "$install_dir" || ynh_die --message="This path already contains a folder" # Register (book) web path -ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url +#REMOVEME? ynh_webpath_register --app=$app --domain=$domain --path=$path #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -ynh_script_progression --message="Storing installation settings..." --weight=1 +#REMOVEME? 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 +#REMOVEME? ynh_app_setting_set --app=$app --key=domain --value=$domain +#REMOVEME? ynh_app_setting_set --app=$app --key=path --value=$path #================================================= # STANDARD MODIFICATIONS #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Installing dependencies..." --weight=1 -ynh_script_progression --message="Installing dependencies..." --weight=1 -ynh_script_progression --message="Installing dependencies..." --weight=1 -ynh_script_progression --message="Installing dependencies..." --weight=1 +#REMOVEME? ynh_script_progression --message="Installing dependencies..." --weight=1 +#REMOVEME? ynh_script_progression --message="Installing dependencies..." --weight=1 +#REMOVEME? ynh_script_progression --message="Installing dependencies..." --weight=1 +#REMOVEME? ynh_script_progression --message="Installing dependencies..." --weight=1 -ynh_install_app_dependencies $pkg_dependencies +#REMOVEME? ynh_install_app_dependencies $pkg_dependencies #================================================= # CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Configuring system user..." --weight=1 +#REMOVEME? ynh_script_progression --message="Configuring system user..." --weight=1 # Create a system user -ynh_system_user_create --username=$app --home_dir="$final_path" +#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Setting up source files..." --weight=1 -ynh_app_setting_set --app=$app --key=final_path --value=$final_path +#REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir # Download, check integrity, uncompress and patch the source from app.src -mkdir -p "$final_path/tmp" -ynh_setup_source --dest_dir="$final_path/tmp" -cp -af "$final_path/tmp/src/." "$final_path/." -ynh_secure_remove "$final_path/tmp" +mkdir -p "$install_dir/tmp" +ynh_setup_source --dest_dir="$install_dir/tmp" +cp -af "$install_dir/tmp/src/." "$install_dir/." +#REMOVEME? ynh_secure_remove "$install_dir/tmp" -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" +chmod 750 "$install_dir" +chmod -R o-rwx "$install_dir" +chown -R $app:www-data "$install_dir" #================================================= # PHP-FPM CONFIGURATION @@ -90,7 +90,7 @@ ynh_script_progression --message="Configuring PHP-FPM..." --weight=1 # Create a dedicated PHP-FPM config ynh_add_fpm_config --usage=low --footprint=low -phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +#REMOVEME? phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # NGINX CONFIGURATION @@ -107,14 +107,14 @@ ynh_add_nginx_config #================================================= ynh_script_progression --message="Creating a data directory..." --weight=1 -datadir=/home/yunohost.app/$app -ynh_app_setting_set --app=$app --key=datadir --value=$datadir +#REMOVEME? data_dir=/home/yunohost.app/$app +#REMOVEME? ynh_app_setting_set --app=$app --key=data_dir --value=$data_dir -mkdir -p $datadir +mkdir -p $data_dir -chmod 750 "$datadir" -chmod -R o-rwx "$datadir" -chown -R $app:www-data "$datadir" +chmod 750 "$data_dir" +chmod -R o-rwx "$data_dir" +chown -R $app:www-data "$data_dir" #================================================= # CREATE FINAL LOG PATH @@ -122,7 +122,7 @@ chown -R $app:www-data "$datadir" ynh_script_progression --message="Creating a final log path..." --weight=1 final_logpath="/var/log/$app" -ynh_app_setting_set --app=$app --key=final_logpath --value=$final_logpath +#REMOVEME? ynh_app_setting_set --app=$app --key=final_logpath --value=$final_logpath mkdir -p $final_logpath @@ -143,13 +143,13 @@ ynh_replace_string --match_string="__FINAL_LOGPATH__" --replace_string=$final_lo # Storage of state_dir in /home/yunohost.app # This contains the sync status in between device and z-push -ynh_replace_string --match_string="__DATADIR__" --replace_string=$datadir --target_file="../conf/config.php" +ynh_replace_string --match_string="__DATA_DIR__" --replace_string=$data_dir --target_file="../conf/config.php" # Enable caldav carddav support if yunohost app list | grep -q 'id: baikal' ; then echo "Detected Baikal" - bailkaldomain=$(ynh_app_setting_get --app="baikal" --key=domain) - bailkalpath=$(ynh_app_setting_get --app="baikal" --key=path) +#REMOVEME? bailkaldomain=$(ynh_app_setting_get --app="baikal" --key=domain) +#REMOVEME? bailkalpath=$(ynh_app_setting_get --app="baikal" --key=path) bailkalpath=${bailkalpath%/} # Configuration of backend @@ -169,15 +169,15 @@ if yunohost app list | grep -q 'id: baikal' ; then ynh_replace_string --match_string="__FLAGTOCHANGE__" --replace_string="true" --target_file="../conf/backend/config-imap.php" # Copy config - cp -af ../conf/backend/config-caldav.php $final_path/backend/caldav/config.php - cp -af ../conf/backend/config-carddav.php $final_path/backend/carddav/config.php - cp -af ../conf/backend/config-imap.php $final_path/backend/imap/config.php - cp -af ../conf/backend/config-combined.php $final_path/backend/combined/config.php + cp -af ../conf/backend/config-caldav.php $install_dir/backend/caldav/config.php + cp -af ../conf/backend/config-carddav.php $install_dir/backend/carddav/config.php + cp -af ../conf/backend/config-imap.php $install_dir/backend/imap/config.php + cp -af ../conf/backend/config-combined.php $install_dir/backend/combined/config.php elif yunohost app list | grep -q 'id: nextcloud' ; then echo "Detected NextCloud" - nextclouddomain=$(ynh_app_setting_get --app="nextcloud" --key=domain) - nextcloudpath=$(ynh_app_setting_get --app="nextcloud" --key=path) +#REMOVEME? nextclouddomain=$(ynh_app_setting_get --app="nextcloud" --key=domain) +#REMOVEME? nextcloudpath=$(ynh_app_setting_get --app="nextcloud" --key=path) nextcloudpath=${nextcloudpath%/} # Configuration of backend @@ -197,10 +197,10 @@ elif yunohost app list | grep -q 'id: nextcloud' ; then ynh_replace_string --match_string="__FLAGTOCHANGE__" --replace_string="true" --target_file="../conf/backend/config-imap.php" # Copy config - cp -af ../conf/backend/config-caldav.php $final_path/backend/caldav/config.php - cp -af ../conf/backend/config-carddav.php $final_path/backend/carddav/config.php - cp -af ../conf/backend/config-imap.php $final_path/backend/imap/config.php - cp -af ../conf/backend/config-combined.php $final_path/backend/combined/config.php + cp -af ../conf/backend/config-caldav.php $install_dir/backend/caldav/config.php + cp -af ../conf/backend/config-carddav.php $install_dir/backend/carddav/config.php + cp -af ../conf/backend/config-imap.php $install_dir/backend/imap/config.php + cp -af ../conf/backend/config-combined.php $install_dir/backend/combined/config.php else # Configuration of backend ynh_replace_string --match_string="__BACKEND__" --replace_string="BackendIMAP" --target_file="../conf/config.php" @@ -211,13 +211,13 @@ else ynh_replace_string --match_string="__FLAGTOCHANGE__" --replace_string="false" --target_file="../conf/backend/config-imap.php" # Copy config - cp -af ../conf/backend/config-imap.php $final_path/backend/imap/config.php + cp -af ../conf/backend/config-imap.php $install_dir/backend/imap/config.php fi # Copy config -cp -af ../conf/config.php $final_path/config.php -cp -af ../conf/backend/config-autodiscover.php $final_path/autodiscover/config.php -cp -af ../conf/backend/config-searchldap.php $final_path/backend/searchldap/config.php +cp -af ../conf/config.php $install_dir/config.php +cp -af ../conf/backend/config-autodiscover.php $install_dir/autodiscover/config.php +cp -af ../conf/backend/config-searchldap.php $install_dir/backend/searchldap/config.php #Copy XMLElement.php ln -s /usr/share/awl/inc/XML* /var/www/$app/include/ @@ -235,20 +235,20 @@ ynh_use_logrotate #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring permissions..." --weight=1 +#REMOVEME? ynh_script_progression --message="Configuring permissions..." --weight=1 # Make app public -ynh_permission_update --permission="main" --add="visitors" +#REMOVEME? ynh_permission_update --permission="main" --add="visitors" domain_regex=$(echo "$domain" | sed 's@-@.@g') -ynh_permission_create --permission="autodiscover" --url="re:$domain_regex/[Aa]uto[Dd]iscover/.*" --allowed="visitors" --show_tile="false" --protected="true" +#REMOVEME? ynh_permission_create --permission="autodiscover" --url="re:$domain_regex/[Aa]uto[Dd]iscover/.*" --allowed="visitors" --show_tile="false" --protected="true" #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 +#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1 -ynh_systemd_action --service_name=nginx --action=reload +#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT diff --git a/scripts/remove b/scripts/remove index d45761b..6e801de 100755 --- a/scripts/remove +++ b/scripts/remove @@ -14,12 +14,12 @@ source /usr/share/yunohost/helpers #================================================= ynh_script_progression --message="Loading settings..." --weight=1 -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get --app=$app --key=domain) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -datadir=$(ynh_app_setting_get --app=$app --key=datadir) -final_logpath=$(ynh_app_setting_get --app=$app --key=final_logpath) +#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) +#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir) +#REMOVEME? final_logpath=$(ynh_app_setting_get --app=$app --key=final_logpath) #================================================= # STANDARD REMOVE @@ -34,10 +34,10 @@ ynh_remove_logrotate #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_script_progression --message="Removing app main directory..." --weight=1 +#REMOVEME? ynh_script_progression --message="Removing app main directory..." --weight=1 # Remove the app directory securely -ynh_secure_remove --file="$final_path" +#REMOVEME? ynh_secure_remove --file="$install_dir" #================================================= # REMOVE DATA DIR @@ -47,7 +47,7 @@ ynh_secure_remove --file="$final_path" if [ "${YNH_APP_PURGE:-0}" -eq 1 ] then ynh_script_progression --message="Removing app data directory..." --weight=1 - ynh_secure_remove --file="$datadir" +#REMOVEME? ynh_secure_remove --file="$data_dir" fi #================================================= @@ -69,10 +69,10 @@ ynh_remove_fpm_config #================================================= # REMOVE DEPENDENCIES #================================================= -ynh_script_progression --message="Removing dependencies..." --weight=1 +#REMOVEME? ynh_script_progression --message="Removing dependencies..." --weight=1 # Remove metapackage and its dependencies -ynh_remove_app_dependencies +#REMOVEME? ynh_remove_app_dependencies #================================================= # SPECIFIC REMOVE @@ -88,10 +88,10 @@ ynh_secure_remove --file="$final_logpath" #================================================= # REMOVE DEDICATED USER #================================================= -ynh_script_progression --message="Removing the dedicated system user..." --weight=1 +#REMOVEME? ynh_script_progression --message="Removing the dedicated system user..." --weight=1 # Delete a system user -ynh_system_user_delete --username=$app +#REMOVEME? ynh_system_user_delete --username=$app #================================================= # END OF SCRIPT diff --git a/scripts/restore b/scripts/restore index ccf2024..f638b5b 100755 --- a/scripts/restore +++ b/scripts/restore @@ -14,77 +14,77 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { +#REMOVEME? ynh_clean_setup () { true } # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= ynh_script_progression --message="Loading settings..." --weight=1 -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get --app=$app --key=domain) -path_url=$(ynh_app_setting_get --app=$app --key=path) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) -datadir=$(ynh_app_setting_get --app=$app --key=datadir) -final_logpath=$(ynh_app_setting_get --app=$app --key=final_logpath) +#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) +#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path) +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) +#REMOVEME? phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir) +#REMOVEME? final_logpath=$(ynh_app_setting_get --app=$app --key=final_logpath) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= -ynh_script_progression --message="Validating restoration parameters..." --weight=1 +#REMOVEME? ynh_script_progression --message="Validating restoration parameters..." --weight=1 -test ! -d $final_path \ - || ynh_die --message="There is already a directory: $final_path " +#REMOVEME? test ! -d $install_dir \ + || ynh_die --message="There is already a directory: $install_dir " #================================================= # STANDARD RESTORATION STEPS #================================================= # RECREATE THE DEDICATED USER #================================================= -ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 +#REMOVEME? ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 # Create the dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir="$final_path" +#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" #================================================= # RESTORE THE APP MAIN DIR #================================================= ynh_script_progression --message="Restoring the app main directory..." --weight=1 -ynh_restore_file --origin_path="$final_path" +ynh_restore_file --origin_path="$install_dir" -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" +chmod 750 "$install_dir" +chmod -R o-rwx "$install_dir" +chown -R $app:www-data "$install_dir" #================================================= # RESTORE THE DATA DIRECTORY #================================================= ynh_script_progression --message="Restoring the data directory..." --weight=1 -ynh_restore_file --origin_path="$datadir" --not_mandatory +ynh_restore_file --origin_path="$data_dir" --not_mandatory -mkdir -p $datadir +mkdir -p $data_dir -chmod 750 "$datadir" -chmod -R o-rwx "$datadir" -chown -R $app:www-data "$datadir" +chmod 750 "$data_dir" +chmod -R o-rwx "$data_dir" +chown -R $app:www-data "$data_dir" #================================================= # SPECIFIC RESTORATION #================================================= # REINSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Reinstalling dependencies..." --weight=1 +#REMOVEME? ynh_script_progression --message="Reinstalling dependencies..." --weight=1 # Define and install dependencies -ynh_install_app_dependencies $pkg_dependencies +#REMOVEME? ynh_install_app_dependencies $pkg_dependencies #================================================= # RESTORE THE PHP-FPM CONFIGURATION @@ -95,7 +95,7 @@ ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" # Recreate a dedicated php-fpm config ynh_add_fpm_config --usage=low --footprint=low -phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +#REMOVEME? phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # RESTORE THE NGINX CONFIGURATION diff --git a/scripts/upgrade b/scripts/upgrade index 0e6ad2d..c5879ab 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -14,13 +14,13 @@ source /usr/share/yunohost/helpers #================================================= ynh_script_progression --message="Loading settings..." --weight=1 -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get --app=$app --key=domain) -path_url=$(ynh_app_setting_get --app=$app --key=path) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -datadir=$(ynh_app_setting_get --app=$app --key=datadir) -final_logpath=$(ynh_app_setting_get --app=$app --key=final_logpath) +#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) +#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path) +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) +#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir) +#REMOVEME? final_logpath=$(ynh_app_setting_get --app=$app --key=final_logpath) #================================================= # CHECK VERSION @@ -32,16 +32,16 @@ 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 +#REMOVEME? 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 () { +#REMOVEME? ynh_backup_before_upgrade +#REMOVEME? ynh_clean_setup () { # Restore it if the upgrade fails - ynh_restore_upgradebackup +#REMOVEME? ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # STANDARD UPGRADE STEPS @@ -51,34 +51,34 @@ ynh_abort_if_errors ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 # Cleaning legacy permissions -if ynh_legacy_permissions_exists; then - ynh_legacy_permissions_delete_all +#REMOVEME? if ynh_legacy_permissions_exists; then +#REMOVEME? ynh_legacy_permissions_delete_all ynh_app_setting_delete --app=$app --key=is_public fi -if [ -z "$datadir" ]; +if [ -z "$data_dir" ]; then - datadir="/home/yunohost.app/$app" - ynh_app_setting_set --app=$app --key=datadir --value=$datadir + data_dir="/home/yunohost.app/$app" +#REMOVEME? ynh_app_setting_set --app=$app --key=data_dir --value=$data_dir ynh_app_setting_delete --app=$app --key=statedir - mkdir -p $datadir + mkdir -p $data_dir fi if [ -z "$final_logpath" ]; then final_logpath="/var/log/$app" - ynh_app_setting_set --app=$app --key=final_logpath --value=$final_logpath +#REMOVEME? ynh_app_setting_set --app=$app --key=final_logpath --value=$final_logpath mkdir -p $final_logpath fi #================================================= # CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 +#REMOVEME? ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 # Create a dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir="$final_path" +#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -89,22 +89,22 @@ then ynh_script_progression --message="Upgrading source files..." --weight=1 # Download, check integrity, uncompress and patch the source from app.src - mkdir "$final_path/tmp" - ynh_setup_source --dest_dir="$final_path/tmp" - cp -af "$final_path/tmp/src/." "$final_path/." - ynh_secure_remove --file="$final_path/tmp" + mkdir "$install_dir/tmp" + ynh_setup_source --dest_dir="$install_dir/tmp" + cp -af "$install_dir/tmp/src/." "$install_dir/." +#REMOVEME? ynh_secure_remove --file="$install_dir/tmp" fi -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" +chmod 750 "$install_dir" +chmod -R o-rwx "$install_dir" +chown -R $app:www-data "$install_dir" #================================================= # UPGRADE DEPENDENCIES #================================================= -ynh_script_progression --message="Upgrading dependencies..." --weight=1 +#REMOVEME? ynh_script_progression --message="Upgrading dependencies..." --weight=1 -ynh_install_app_dependencies $pkg_dependencies +#REMOVEME? ynh_install_app_dependencies $pkg_dependencies #================================================= # PHP-FPM CONFIGURATION @@ -113,7 +113,7 @@ ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=1 # Create a dedicated PHP-FPM config ynh_add_fpm_config --usage=low --footprint=low -phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +#REMOVEME? phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # NGINX CONFIGURATION @@ -138,13 +138,13 @@ ynh_replace_string --match_string="__FINAL_LOGPATH__" --replace_string="$final_l # Storage of state_dir in /home/yunohost.app # This contains the sync status in between device and z-push -ynh_replace_string __DATADIR__ $datadir ../conf/config.php +ynh_replace_string __DATA_DIR__ $data_dir ../conf/config.php # Enable caldav carddav support if yunohost app list | grep -q 'id: baikal' ; then echo "Detected Baikal" - bailkaldomain=$(ynh_app_setting_get --app=baikal --key=domain) - bailkalpath=$(ynh_app_setting_get --app=baikal --key=path) +#REMOVEME? bailkaldomain=$(ynh_app_setting_get --app=baikal --key=domain) +#REMOVEME? bailkalpath=$(ynh_app_setting_get --app=baikal --key=path) bailkalpath=${bailkalpath%/} # Configuration of backend @@ -164,15 +164,15 @@ if yunohost app list | grep -q 'id: baikal' ; then ynh_replace_string --match_string="__FLAGTOCHANGE__" --replace_string="true" --target_file="../conf/backend/config-imap.php" # Copy config - cp -af ../conf/backend/config-caldav.php $final_path/backend/caldav/config.php - cp -af ../conf/backend/config-carddav.php $final_path/backend/carddav/config.php - cp -af ../conf/backend/config-imap.php $final_path/backend/imap/config.php - cp -af ../conf/backend/config-combined.php $final_path/backend/combined/config.php + cp -af ../conf/backend/config-caldav.php $install_dir/backend/caldav/config.php + cp -af ../conf/backend/config-carddav.php $install_dir/backend/carddav/config.php + cp -af ../conf/backend/config-imap.php $install_dir/backend/imap/config.php + cp -af ../conf/backend/config-combined.php $install_dir/backend/combined/config.php elif yunohost app list | grep -q 'id: nextcloud' ; then echo "Detected NextCloud" - nextclouddomain=$(ynh_app_setting_get --app=nextcloud --key=domain) - nextcloudpath=$(ynh_app_setting_get --app=nextcloud --key=path) +#REMOVEME? nextclouddomain=$(ynh_app_setting_get --app=nextcloud --key=domain) +#REMOVEME? nextcloudpath=$(ynh_app_setting_get --app=nextcloud --key=path) nextcloudpath=${nextcloudpath%/} # Configuration of backend @@ -192,10 +192,10 @@ elif yunohost app list | grep -q 'id: nextcloud' ; then ynh_replace_string --match_string="__FLAGTOCHANGE__" --replace_string="true" --target_file="../conf/backend/config-imap.php" # Copy config - cp -af ../conf/backend/config-caldav.php $final_path/backend/caldav/config.php - cp -af ../conf/backend/config-carddav.php $final_path/backend/carddav/config.php - cp -af ../conf/backend/config-imap.php $final_path/backend/imap/config.php - cp -af ../conf/backend/config-combined.php $final_path/backend/combined/config.php + cp -af ../conf/backend/config-caldav.php $install_dir/backend/caldav/config.php + cp -af ../conf/backend/config-carddav.php $install_dir/backend/carddav/config.php + cp -af ../conf/backend/config-imap.php $install_dir/backend/imap/config.php + cp -af ../conf/backend/config-combined.php $install_dir/backend/combined/config.php else # Configuration of backend ynh_replace_string --match_string="__BACKEND__" --replace_string="BackendIMAP" --target_file="../conf/config.php" @@ -206,16 +206,16 @@ else ynh_replace_string --match_string="__FLAGTOCHANGE__" --replace_string="false" --target_file="../conf/backend/config-imap.php" # Copy config - cp -af ../conf/backend/config-imap.php $final_path/backend/imap/config.php + cp -af ../conf/backend/config-imap.php $install_dir/backend/imap/config.php fi # Copy config -cp -af ../conf/config.php $final_path/config.php -cp -af ../conf/backend/config-autodiscover.php $final_path/autodiscover/config.php -cp -af ../conf/backend/config-searchldap.php $final_path/backend/searchldap/config.php +cp -af ../conf/config.php $install_dir/config.php +cp -af ../conf/backend/config-autodiscover.php $install_dir/autodiscover/config.php +cp -af ../conf/backend/config-searchldap.php $install_dir/backend/searchldap/config.php # Fixstates to avoid full resync of devices after version upgrades -$final_path/z-push-admin.php -a fixstates +$install_dir/z-push-admin.php -a fixstates #================================================= # GENERIC FINALIZATION @@ -230,9 +230,9 @@ ynh_use_logrotate --non-append #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 +#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1 -ynh_systemd_action --service_name=nginx --action=reload +#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT From 7f61efc750ecf2955d0b551c64c64192943b24e8 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Thu, 2 Nov 2023 20:43:32 +0000 Subject: [PATCH 04/16] Auto-update README --- README.md | 1 + README_fr.md | 1 + 2 files changed, 2 insertions(+) diff --git a/README.md b/README.md index a1c586f..795b6b8 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ Z-Push is an Exchange ActiveSync fronted written in PHP which lets you synchroni * Official app website: * Official admin documentation: * Upstream app code repository: +* YunoHost Store: * Report a bug: ## Developer info diff --git a/README_fr.md b/README_fr.md index c65774a..220716c 100644 --- a/README_fr.md +++ b/README_fr.md @@ -29,6 +29,7 @@ Z-Push is an Exchange ActiveSync fronted written in PHP which lets you synchroni * Site officiel de l’app : * Documentation officielle de l’admin : * Dépôt de code officiel de l’app : +* YunoHost Store: * Signaler un bug : ## Informations pour les développeurs From 0d6a2e8917001fa732e974a87598e1e12bf40325 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Thu, 2 Nov 2023 21:57:14 +0100 Subject: [PATCH 05/16] v2 --- .github/workflows/updater.sh | 106 ---------------------------------- .github/workflows/updater.yml | 49 ---------------- conf/config.php | 2 +- doc/DISCLAIMER.md | 1 - manifest.toml | 21 ++++--- scripts/_common.sh | 8 --- 6 files changed, 11 insertions(+), 176 deletions(-) delete mode 100644 .github/workflows/updater.sh delete mode 100644 .github/workflows/updater.yml delete mode 100644 doc/DISCLAIMER.md diff --git a/.github/workflows/updater.sh b/.github/workflows/updater.sh deleted file mode 100644 index 00febba..0000000 --- a/.github/workflows/updater.sh +++ /dev/null @@ -1,106 +0,0 @@ -#!/bin/bash - -#================================================= -# PACKAGE UPDATING HELPER -#================================================= - -# This script is meant to be run by GitHub Actions -# The YunoHost-Apps organisation offers a template Action to run this script periodically -# Since each app is different, maintainers can adapt its contents so as to perform -# automatic actions when a new upstream release is detected. - -#================================================= -# FETCHING LATEST RELEASE AND ITS ASSETS -#================================================= - -# Fetching information -current_version=$(cat manifest.json | jq -j '.version|split("~")[0]') -repo=$(cat manifest.json | jq -j '.upstream.code|split("https://github.com/")[1]') -# Some jq magic is needed, because the latest upstream release is not always the latest version (e.g. security patches for older versions) -version=$(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '.[] | select( .prerelease != true ) | .tag_name' | sort -V | tail -1) -assets="https://github.com/Z-Hub/Z-Push/archive/$version.tar.gz" - -# Later down the script, we assume the version has only digits and dots -# Sometimes the release name starts with a "v", so let's filter it out. -# You may need more tweaks here if the upstream repository has different naming conventions. -if [[ ${version:0:1} == "v" || ${version:0:1} == "V" ]]; then - version=${version:1} -fi - -# Setting up the environment variables -echo "Current version: $current_version" -echo "Latest release from upstream: $version" -echo "VERSION=$version" >> $GITHUB_ENV -# For the time being, let's assume the script will fail -echo "PROCEED=false" >> $GITHUB_ENV - -# Proceed only if the retrieved version is greater than the current one -if ! dpkg --compare-versions "$current_version" "lt" "$version" ; then - echo "::warning ::No new version available" - exit 0 -# Proceed only if a PR for this new version does not already exist -elif git ls-remote -q --exit-code --heads https://github.com/$GITHUB_REPOSITORY.git ci-auto-update-v$version ; then - echo "::warning ::A branch already exists for this update" - exit 0 -fi - -#================================================= -# UPDATE SOURCE FILES -#================================================= - -# Let's download source tarball -asset_url=$assets - -echo "Handling asset at $asset_url" - -src="app" - -# Create the temporary directory -tempdir="$(mktemp -d)" - -# Download sources and calculate checksum -filename=${asset_url##*/} -curl --silent -4 -L $asset_url -o "$tempdir/$filename" -checksum=$(sha256sum "$tempdir/$filename" | head -c 64) - -# Delete temporary directory -rm -rf $tempdir - -# Get extension -if [[ $filename == *.tar.gz ]]; then - extension=tar.gz -else - extension=${filename##*.} -fi - -# Rewrite source file -cat < conf/$src.src -SOURCE_URL=$asset_url -SOURCE_SUM=$checksum -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=$extension -SOURCE_IN_SUBDIR=true -SOURCE_FILENAME= -SOURCE_EXTRACT=true -EOT -echo "... conf/$src.src updated" - -#================================================= -# SPECIFIC UPDATE STEPS -#================================================= - -# Any action on the app's source code can be done. -# The GitHub Action workflow takes care of committing all changes after this script ends. - -#================================================= -# GENERIC FINALIZATION -#================================================= - -# Replace new version in manifest -echo "$(jq -s --indent 4 ".[] | .version = \"$version~ynh1\"" manifest.json)" > manifest.json - -# No need to update the README, yunohost-bot takes care of it - -# The Action will proceed only if the PROCEED environment variable is set to true -echo "PROCEED=true" >> $GITHUB_ENV -exit 0 diff --git a/.github/workflows/updater.yml b/.github/workflows/updater.yml deleted file mode 100644 index a56d7cb..0000000 --- a/.github/workflows/updater.yml +++ /dev/null @@ -1,49 +0,0 @@ -# This workflow allows GitHub Actions to automagically update your app whenever a new upstream release is detected. -# You need to enable Actions in your repository settings, and fetch this Action from the YunoHost-Apps organization. -# This file should be enough by itself, but feel free to tune it to your needs. -# It calls updater.sh, which is where you should put the app-specific update steps. -name: Check for new upstream releases -on: - # Allow to manually trigger the workflow - workflow_dispatch: - # Run it every day at 6:00 UTC - schedule: - - cron: '0 6 * * *' -jobs: - updater: - runs-on: ubuntu-latest - steps: - - name: Fetch the source code - uses: actions/checkout@v3 - with: - token: ${{ secrets.GITHUB_TOKEN }} - - name: Run the updater script - id: run_updater - run: | - # Setting up Git user - git config --global user.name 'yunohost-bot' - git config --global user.email 'yunohost-bot@users.noreply.github.com' - # Run the updater script - /bin/bash .github/workflows/updater.sh - - name: Commit changes - id: commit - if: ${{ env.PROCEED == 'true' }} - run: | - git commit -am "Upgrade to v$VERSION" - - name: Create Pull Request - id: cpr - if: ${{ env.PROCEED == 'true' }} - uses: peter-evans/create-pull-request@v4 - with: - token: ${{ secrets.GITHUB_TOKEN }} - commit-message: Update to version ${{ env.VERSION }} - committer: 'yunohost-bot ' - author: 'yunohost-bot ' - signoff: false - base: testing - branch: ci-auto-update-v${{ env.VERSION }} - delete-branch: true - title: 'Upgrade to version ${{ env.VERSION }}' - body: | - Upgrade to v${{ env.VERSION }} - draft: false diff --git a/conf/config.php b/conf/config.php index e9e9c99..389ae9d 100644 --- a/conf/config.php +++ b/conf/config.php @@ -120,7 +120,7 @@ $specialLogUsers = array(); // Filelog settings - define('LOGFILEDIR', '__FINAL_LOGPATH__/'); + define('LOGFILEDIR', '/var/log/__APP__/'); define('LOGFILE', LOGFILEDIR . 'z-push.log'); define('LOGERRORFILE', LOGFILEDIR . 'z-push-error.log'); diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md deleted file mode 100644 index c5645eb..0000000 --- a/doc/DISCLAIMER.md +++ /dev/null @@ -1 +0,0 @@ -* would be better to create a dedicated domain: autodiscover.yourdomain.org diff --git a/manifest.toml b/manifest.toml index fc9430b..92311d5 100644 --- a/manifest.toml +++ b/manifest.toml @@ -14,23 +14,19 @@ license = "AGPL-3.0-or-later" website = "http://z-push.org" admindoc = "https://wiki.z-hub.io/display/ZP/Documentation" code = "https://github.com/Z-Hub/Z-Push" -cpe = "???" # FIXME: optional but recommended if relevant, this is meant to contain the Common Platform Enumeration, which is sort of a standard id for applications defined by the NIST. In particular, Yunohost may use this is in the future to easily track CVE (=security reports) related to apps. The CPE may be obtained by searching here: https://nvd.nist.gov/products/cpe/search. For example, for Nextcloud, the CPE is 'cpe:2.3:a:nextcloud:nextcloud' (no need to include the version number) -fund = "???" # FIXME: optional but recommended (or remove if irrelevant / not applicable). This is meant to be an URL where people can financially support this app, especially when its development is based on volunteers and/or financed by its community. YunoHost may later advertise it in the webadmin. [integration] -yunohost = ">= 11.0.9" -architectures = "all" # FIXME: can be replaced by a list of supported archs using the dpkg --print-architecture nomenclature (amd64/i386/armhf/arm64), for example: ["amd64", "i386"] +yunohost = ">= 11.2" +architectures = "all" multi_instance = true -ldap = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "sso" key : the "ldap" key corresponds to wether or not a user *can* login on the app using its YunoHost credentials. -sso = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "ldap" key : the "sso" key corresponds to wether or not a user is *automatically logged-in* on the app when logged-in on the YunoHost portal. -disk = "50M" # FIXME: replace with an **estimate** minimum disk requirement. e.g. 20M, 400M, 1G, ... -ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... -ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... +ldap = false +sso = false +disk = "50M" +ram.build = "50M" +ram.runtime = "50M" [install.domain] - # this is a generic question - ask strings are automatically handled by Yunohost's core type = "domain" - full_domain = true [resources] [resources.sources.main] @@ -46,3 +42,6 @@ ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requiremen [resources.permissions] main.url = "/" + + [resources.apt] + packages = "php7.4-soap, php7.4-imap, php7.4-xsl, php7.4-curl, php7.4-xml, php7.4-ldap, php7.4-cli, php7.4-mbstring, php7.4-memcached, libawl-php" diff --git a/scripts/_common.sh b/scripts/_common.sh index ec2e5a0..944a65e 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,14 +4,6 @@ # COMMON VARIABLES #================================================= -#REMOVEME? YNH_PHP_VERSION="7.4" - -#REMOVEME? php_dependencies="php${YNH_PHP_VERSION}-soap php${YNH_PHP_VERSION}-imap php${YNH_PHP_VERSION}-xsl php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-ldap php${YNH_PHP_VERSION}-cli php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-memcached" - -# dependencies used by the app (must be on a single line) -#REMOVEME? pkg_dependencies="libawl-php $php_dependencies" - - #================================================= # PERSONAL HELPERS #================================================= From be67b74a790da71e0cc6fcca94733c69d770f9d8 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Thu, 2 Nov 2023 20:57:25 +0000 Subject: [PATCH 06/16] Auto-update README --- README.md | 4 ---- README_fr.md | 4 ---- 2 files changed, 8 deletions(-) diff --git a/README.md b/README.md index 795b6b8..3c2f16d 100644 --- a/README.md +++ b/README.md @@ -20,10 +20,6 @@ Z-Push is an Exchange ActiveSync fronted written in PHP which lets you synchroni **Shipped version:** 2.7.1~ynh1 -## Disclaimers / important information - -* would be better to create a dedicated domain: autodiscover.yourdomain.org - ## Documentation and resources * Official app website: diff --git a/README_fr.md b/README_fr.md index 220716c..219a37b 100644 --- a/README_fr.md +++ b/README_fr.md @@ -20,10 +20,6 @@ Z-Push is an Exchange ActiveSync fronted written in PHP which lets you synchroni **Version incluse :** 2.7.1~ynh1 -## Avertissements / informations importantes - -* would be better to create a dedicated domain: autodiscover.yourdomain.org - ## Documentations et ressources * Site officiel de l’app : From b53d7b879eebf9a3b5353123d4f063b9ce568e6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Thu, 2 Nov 2023 22:01:27 +0100 Subject: [PATCH 07/16] v2 --- check_process | 31 --------------- manifest.json | 45 --------------------- scripts/backup | 23 ----------- scripts/install | 102 ++++-------------------------------------------- scripts/remove | 66 ------------------------------- scripts/restore | 71 --------------------------------- scripts/upgrade | 98 +++------------------------------------------- tests.toml | 3 ++ 8 files changed, 17 insertions(+), 422 deletions(-) delete mode 100644 check_process delete mode 100644 manifest.json create mode 100644 tests.toml diff --git a/check_process b/check_process deleted file mode 100644 index 16cea20..0000000 --- a/check_process +++ /dev/null @@ -1,31 +0,0 @@ -;; Test complet - ; Manifest - domain="domain.tld" - path="/Microsoft-Server-ActiveSync" - ; Checks - pkg_linter=1 - setup_sub_dir=1 - setup_root=0 - setup_nourl=0 - setup_private=0 - setup_public=1 - upgrade=1 - # 2.5.1~ynh3 - # upgrade=1 from_commit=9e8a72669814237122dfc6f901c9377895c193db - # 2.5.2~ynh1 - # upgrade=1 from_commit=a857788c1fb369baa5f0608da12013b003cceed3 - # 2.6.1~ynh1 - # upgrade=1 from_commit=a05896f0e4f2b015dcf643c644ac6c98c2f6695b - # 2.6.1~ynh2 - upgrade=1 from_commit=8e99ec37fb90d1ac4f8eb2c838e6d2e1f5b0c905 - # 2.6.1~ynh3 - upgrade=1 from_commit=f101d8cb5701c46db0d6cf5aaa02b1e7f8e0dec2 - # 2.6.4~ynh1 - upgrade=1 from_commit=065dc9bf0076090cb6457ef54c87ef0200d72103 - backup_restore=1 - multi_instance=1 - port_already_use=0 - change_url=0 -;;; Options -Email=yalh@yahoo.com -Notification=all diff --git a/manifest.json b/manifest.json deleted file mode 100644 index c4874ba..0000000 --- a/manifest.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "name": "Z-Push", - "id": "z-push", - "packaging_format": 1, - "description": { - "en": "ActiveSync frontend that helps you synchronize emails, calendar and contacts", - "fr": "Frontend ActiveSync qui permet de synchroniser emails, calendrier et contacts" - }, - "version": "2.7.1~ynh1", - "url": "https://z-push.org", - "upstream": { - "license": "AGPL-3.0-or-later", - "website": "http://z-push.org", - "admindoc": "https://wiki.z-hub.io/display/ZP/Documentation", - "code": "https://github.com/Z-Hub/Z-Push" - }, - "license": "AGPL-3.0-or-later", - "maintainer": { - "name": "yalh76" - }, - "previous_maintainer": [ - { - "name": "beudbeud" - }, - { - "name": "polytan02" - } - ], - "requirements": { - "yunohost": ">= 11.0.9" - }, - "multi_instance": true, - "services": [ - "nginx", - "php7.4-fpm" - ], - "arguments": { - "install": [ - { - "name": "domain", - "type": "domain" - } - ] - } -} diff --git a/scripts/backup b/scripts/backup index 2a933b9..b0b2b76 100755 --- a/scripts/backup +++ b/scripts/backup @@ -10,29 +10,6 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -#REMOVEME? ynh_clean_setup () { - true -} -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_print_info --message="Loading settings..." - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) -#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) -#REMOVEME? phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) -#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir) -#REMOVEME? final_logpath=$(ynh_app_setting_get --app=$app --key=final_logpath) - #================================================= # DECLARE DATA AND CONF FILES TO BACKUP #================================================= diff --git a/scripts/install b/scripts/install index b36929c..ff2da61 100755 --- a/scripts/install +++ b/scripts/install @@ -9,77 +9,23 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -#REMOVEME? ynh_clean_setup () { - true -} -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= -#REMOVEME? domain=$YNH_APP_ARG_DOMAIN path="/Microsoft-Server-ActiveSync" -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#================================================= -# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS -#================================================= -#REMOVEME? ynh_script_progression --message="Validating installation parameters..." --weight=1 - -#REMOVEME? install_dir=/var/www/$app -#REMOVEME? test ! -e "$install_dir" || ynh_die --message="This path already contains a folder" - -# Register (book) web path -#REMOVEME? ynh_webpath_register --app=$app --domain=$domain --path=$path - -#================================================= -# STORE SETTINGS FROM MANIFEST -#================================================= -#REMOVEME? ynh_script_progression --message="Storing installation settings..." --weight=1 - -#REMOVEME? ynh_app_setting_set --app=$app --key=domain --value=$domain -#REMOVEME? ynh_app_setting_set --app=$app --key=path --value=$path - -#================================================= -# STANDARD MODIFICATIONS -#================================================= -# INSTALL DEPENDENCIES -#================================================= -#REMOVEME? ynh_script_progression --message="Installing dependencies..." --weight=1 -#REMOVEME? ynh_script_progression --message="Installing dependencies..." --weight=1 -#REMOVEME? ynh_script_progression --message="Installing dependencies..." --weight=1 -#REMOVEME? ynh_script_progression --message="Installing dependencies..." --weight=1 - -#REMOVEME? ynh_install_app_dependencies $pkg_dependencies - -#================================================= -# CREATE DEDICATED USER -#================================================= -#REMOVEME? ynh_script_progression --message="Configuring system user..." --weight=1 - -# Create a system user -#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Setting up source files..." --weight=1 -#REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir # Download, check integrity, uncompress and patch the source from app.src mkdir -p "$install_dir/tmp" ynh_setup_source --dest_dir="$install_dir/tmp" cp -af "$install_dir/tmp/src/." "$install_dir/." -#REMOVEME? ynh_secure_remove "$install_dir/tmp" +ynh_secure_remove "$install_dir/tmp" -chmod 750 "$install_dir" chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" @@ -89,40 +35,18 @@ chown -R $app:www-data "$install_dir" ynh_script_progression --message="Configuring PHP-FPM..." --weight=1 # Create a dedicated PHP-FPM config -ynh_add_fpm_config --usage=low --footprint=low -#REMOVEME? phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) - -#================================================= -# NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Configuring NGINX web server..." --weight=1 +ynh_add_fpm_config # Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# SPECIFIC SETUP -#================================================= -# CREATE DATA DIRECTORY -#================================================= -ynh_script_progression --message="Creating a data directory..." --weight=1 - -#REMOVEME? data_dir=/home/yunohost.app/$app -#REMOVEME? ynh_app_setting_set --app=$app --key=data_dir --value=$data_dir - -mkdir -p $data_dir - -chmod 750 "$data_dir" -chmod -R o-rwx "$data_dir" -chown -R $app:www-data "$data_dir" - #================================================= # CREATE FINAL LOG PATH #================================================= ynh_script_progression --message="Creating a final log path..." --weight=1 final_logpath="/var/log/$app" -#REMOVEME? ynh_app_setting_set --app=$app --key=final_logpath --value=$final_logpath +ynh_app_setting_set --app=$app --key=final_logpath --value=$final_logpath mkdir -p $final_logpath @@ -148,8 +72,8 @@ ynh_replace_string --match_string="__DATA_DIR__" --replace_string=$data_dir --ta # Enable caldav carddav support if yunohost app list | grep -q 'id: baikal' ; then echo "Detected Baikal" -#REMOVEME? bailkaldomain=$(ynh_app_setting_get --app="baikal" --key=domain) -#REMOVEME? bailkalpath=$(ynh_app_setting_get --app="baikal" --key=path) + bailkaldomain=$(ynh_app_setting_get --app="baikal" --key=domain) + bailkalpath=$(ynh_app_setting_get --app="baikal" --key=path) bailkalpath=${bailkalpath%/} # Configuration of backend @@ -176,8 +100,8 @@ if yunohost app list | grep -q 'id: baikal' ; then elif yunohost app list | grep -q 'id: nextcloud' ; then echo "Detected NextCloud" -#REMOVEME? nextclouddomain=$(ynh_app_setting_get --app="nextcloud" --key=domain) -#REMOVEME? nextcloudpath=$(ynh_app_setting_get --app="nextcloud" --key=path) + nextclouddomain=$(ynh_app_setting_get --app="nextcloud" --key=domain) + nextcloudpath=$(ynh_app_setting_get --app="nextcloud" --key=path) nextcloudpath=${nextcloudpath%/} # Configuration of backend @@ -237,19 +161,9 @@ ynh_use_logrotate #================================================= #REMOVEME? ynh_script_progression --message="Configuring permissions..." --weight=1 -# Make app public -#REMOVEME? ynh_permission_update --permission="main" --add="visitors" - -domain_regex=$(echo "$domain" | sed 's@-@.@g') +#domain_regex=$(echo "$domain" | sed 's@-@.@g') #REMOVEME? ynh_permission_create --permission="autodiscover" --url="re:$domain_regex/[Aa]uto[Dd]iscover/.*" --allowed="visitors" --show_tile="false" --protected="true" -#================================================= -# RELOAD NGINX -#================================================= -#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1 - -#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/remove b/scripts/remove index 6e801de..17a6924 100755 --- a/scripts/remove +++ b/scripts/remove @@ -9,18 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading settings..." --weight=1 - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) -#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir) -#REMOVEME? final_logpath=$(ynh_app_setting_get --app=$app --key=final_logpath) - #================================================= # STANDARD REMOVE #================================================= @@ -31,68 +19,14 @@ ynh_script_progression --message="Removing logrotate configuration..." --weight= # Remove the app-specific logrotate config ynh_remove_logrotate -#================================================= -# REMOVE APP MAIN DIR -#================================================= -#REMOVEME? ynh_script_progression --message="Removing app main directory..." --weight=1 - -# Remove the app directory securely -#REMOVEME? ynh_secure_remove --file="$install_dir" - -#================================================= -# REMOVE DATA DIR -#================================================= - -# Remove the data directory if --purge option is used -if [ "${YNH_APP_PURGE:-0}" -eq 1 ] -then - ynh_script_progression --message="Removing app data directory..." --weight=1 -#REMOVEME? ynh_secure_remove --file="$data_dir" -fi - -#================================================= -# REMOVE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1 - # Remove the dedicated NGINX config ynh_remove_nginx_config -#================================================= -# REMOVE PHP-FPM CONFIGURATION -#================================================= -ynh_script_progression --message="Removing PHP-FPM configuration..." --weight=1 - # Remove the dedicated PHP-FPM config ynh_remove_fpm_config -#================================================= -# REMOVE DEPENDENCIES -#================================================= -#REMOVEME? ynh_script_progression --message="Removing dependencies..." --weight=1 - -# Remove metapackage and its dependencies -#REMOVEME? ynh_remove_app_dependencies - -#================================================= -# SPECIFIC REMOVE -#================================================= -# REMOVE VARIOUS FILES -#================================================= -ynh_script_progression --message="Removing various files..." --weight=1 - ynh_secure_remove --file="$final_logpath" -#================================================= -# GENERIC FINALIZATION -#================================================= -# REMOVE DEDICATED USER -#================================================= -#REMOVEME? ynh_script_progression --message="Removing the dedicated system user..." --weight=1 - -# Delete a system user -#REMOVEME? ynh_system_user_delete --username=$app - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index f638b5b..739d7bc 100755 --- a/scripts/restore +++ b/scripts/restore @@ -10,48 +10,6 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -#REMOVEME? ynh_clean_setup () { - true -} -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading settings..." --weight=1 - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) -#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path) -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) -#REMOVEME? phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) -#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir) -#REMOVEME? final_logpath=$(ynh_app_setting_get --app=$app --key=final_logpath) - -#================================================= -# CHECK IF THE APP CAN BE RESTORED -#================================================= -#REMOVEME? ynh_script_progression --message="Validating restoration parameters..." --weight=1 - -#REMOVEME? test ! -d $install_dir \ - || ynh_die --message="There is already a directory: $install_dir " - -#================================================= -# STANDARD RESTORATION STEPS -#================================================= -# RECREATE THE DEDICATED USER -#================================================= -#REMOVEME? ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 - -# Create the dedicated user (if not existing) -#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" - #================================================= # RESTORE THE APP MAIN DIR #================================================= @@ -59,7 +17,6 @@ ynh_script_progression --message="Restoring the app main directory..." --weight= ynh_restore_file --origin_path="$install_dir" -chmod 750 "$install_dir" chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" @@ -70,22 +27,8 @@ ynh_script_progression --message="Restoring the data directory..." --weight=1 ynh_restore_file --origin_path="$data_dir" --not_mandatory -mkdir -p $data_dir - -chmod 750 "$data_dir" -chmod -R o-rwx "$data_dir" chown -R $app:www-data "$data_dir" -#================================================= -# SPECIFIC RESTORATION -#================================================= -# REINSTALL DEPENDENCIES -#================================================= -#REMOVEME? ynh_script_progression --message="Reinstalling dependencies..." --weight=1 - -# Define and install dependencies -#REMOVEME? ynh_install_app_dependencies $pkg_dependencies - #================================================= # RESTORE THE PHP-FPM CONFIGURATION #================================================= @@ -93,22 +36,8 @@ ynh_script_progression --message="Restoring the PHP-FPM configuration..." --weig ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" -# Recreate a dedicated php-fpm config -ynh_add_fpm_config --usage=low --footprint=low -#REMOVEME? phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) - -#================================================= -# RESTORE THE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1 - ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# RESTORE THE LOGROTATE CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1 - ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index c5879ab..075c4d9 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -9,77 +9,12 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading settings..." --weight=1 - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) -#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path) -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) -#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir) -#REMOVEME? final_logpath=$(ynh_app_setting_get --app=$app --key=final_logpath) - #================================================= # CHECK VERSION #================================================= -ynh_script_progression --message="Checking version..." --weight=1 upgrade_type=$(ynh_check_app_version_changed) -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -#REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1 - -# Backup the current version of the app -#REMOVEME? ynh_backup_before_upgrade -#REMOVEME? ynh_clean_setup () { - # Restore it if the upgrade fails -#REMOVEME? ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - -#================================================= -# STANDARD UPGRADE STEPS -#================================================= -# ENSURE DOWNWARD COMPATIBILITY -#================================================= -ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 - -# Cleaning legacy permissions -#REMOVEME? if ynh_legacy_permissions_exists; then -#REMOVEME? ynh_legacy_permissions_delete_all - - ynh_app_setting_delete --app=$app --key=is_public -fi - -if [ -z "$data_dir" ]; -then - data_dir="/home/yunohost.app/$app" -#REMOVEME? ynh_app_setting_set --app=$app --key=data_dir --value=$data_dir - ynh_app_setting_delete --app=$app --key=statedir - mkdir -p $data_dir -fi - -if [ -z "$final_logpath" ]; -then - final_logpath="/var/log/$app" -#REMOVEME? ynh_app_setting_set --app=$app --key=final_logpath --value=$final_logpath - mkdir -p $final_logpath -fi - -#================================================= -# CREATE DEDICATED USER -#================================================= -#REMOVEME? ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 - -# Create a dedicated user (if not existing) -#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -92,33 +27,19 @@ then mkdir "$install_dir/tmp" ynh_setup_source --dest_dir="$install_dir/tmp" cp -af "$install_dir/tmp/src/." "$install_dir/." -#REMOVEME? ynh_secure_remove --file="$install_dir/tmp" + ynh_secure_remove --file="$install_dir/tmp" fi -chmod 750 "$install_dir" chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" -#================================================= -# UPGRADE DEPENDENCIES -#================================================= -#REMOVEME? ynh_script_progression --message="Upgrading dependencies..." --weight=1 - -#REMOVEME? ynh_install_app_dependencies $pkg_dependencies - #================================================= # PHP-FPM CONFIGURATION #================================================= ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=1 # Create a dedicated PHP-FPM config -ynh_add_fpm_config --usage=low --footprint=low -#REMOVEME? phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) - -#================================================= -# NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1 +ynh_add_fpm_config # Create a dedicated NGINX config ynh_add_nginx_config @@ -143,8 +64,8 @@ ynh_replace_string __DATA_DIR__ $data_dir ../conf/config.php # Enable caldav carddav support if yunohost app list | grep -q 'id: baikal' ; then echo "Detected Baikal" -#REMOVEME? bailkaldomain=$(ynh_app_setting_get --app=baikal --key=domain) -#REMOVEME? bailkalpath=$(ynh_app_setting_get --app=baikal --key=path) + bailkaldomain=$(ynh_app_setting_get --app=baikal --key=domain) + bailkalpath=$(ynh_app_setting_get --app=baikal --key=path) bailkalpath=${bailkalpath%/} # Configuration of backend @@ -171,8 +92,8 @@ if yunohost app list | grep -q 'id: baikal' ; then elif yunohost app list | grep -q 'id: nextcloud' ; then echo "Detected NextCloud" -#REMOVEME? nextclouddomain=$(ynh_app_setting_get --app=nextcloud --key=domain) -#REMOVEME? nextcloudpath=$(ynh_app_setting_get --app=nextcloud --key=path) + nextclouddomain=$(ynh_app_setting_get --app=nextcloud --key=domain) + nextcloudpath=$(ynh_app_setting_get --app=nextcloud --key=path) nextcloudpath=${nextcloudpath%/} # Configuration of backend @@ -227,13 +148,6 @@ ynh_script_progression --message="Upgrading logrotate configuration..." --weight # Use logrotate to manage app-specific logfile(s) ynh_use_logrotate --non-append -#================================================= -# RELOAD NGINX -#================================================= -#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1 - -#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload - #================================================= # END OF SCRIPT #================================================= diff --git a/tests.toml b/tests.toml new file mode 100644 index 0000000..eb73b8d --- /dev/null +++ b/tests.toml @@ -0,0 +1,3 @@ +test_format = 1.0 + +[default] \ No newline at end of file From 8874077b2bce87acd7f062e6112454d77a85e791 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Thu, 2 Nov 2023 22:02:48 +0100 Subject: [PATCH 08/16] Update manifest.toml --- manifest.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.toml b/manifest.toml index 92311d5..c507539 100644 --- a/manifest.toml +++ b/manifest.toml @@ -23,7 +23,7 @@ ldap = false sso = false disk = "50M" ram.build = "50M" -ram.runtime = "50M" +ram.runtime = "50M" [install.domain] type = "domain" From 4c8766eca31ccb55f63353c6fa2902dda1a13775 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin <4533074+alexAubin@users.noreply.github.com> Date: Mon, 4 Dec 2023 23:21:30 +0100 Subject: [PATCH 09/16] Update conf/nginx.conf: redirect domain root to the microsoft endpoint --- conf/nginx.conf | 1 + 1 file changed, 1 insertion(+) diff --git a/conf/nginx.conf b/conf/nginx.conf index 4fe0ecd..b8f32b2 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,4 +1,5 @@ #sub_path_only rewrite ^Microsoft-Server-ActiveSync$ Microsoft-Server-ActiveSync/ permanent; +rewrite ^/$ Microsoft-Server-ActiveSync/ permanent; location /Microsoft-Server-ActiveSync { # Path to source From cd679074f91e85c53ffe8ab2cdf1941d64692690 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Mon, 4 Dec 2023 23:54:49 +0100 Subject: [PATCH 10/16] Improve the horendous configuration management using shitload of ynh_replace_string ... --- conf/backend/config-autodiscover.php | 2 +- conf/backend/config-imap.php | 2 +- conf/config.php | 2 +- manifest.toml | 3 + scripts/install | 122 ++++++++++----------------- scripts/remove | 2 +- scripts/upgrade | 107 ++++++++++------------- 7 files changed, 96 insertions(+), 144 deletions(-) diff --git a/conf/backend/config-autodiscover.php b/conf/backend/config-autodiscover.php index 2c232f9..6930b36 100644 --- a/conf/backend/config-autodiscover.php +++ b/conf/backend/config-autodiscover.php @@ -87,7 +87,7 @@ define('LOGBACKEND', 'filelog'); - define('LOGFILEDIR', '__FINAL_LOGPATH__/'); + define('LOGFILEDIR', '__LOG_DIR__/'); define('LOGFILE', LOGFILEDIR . 'autodiscover.log'); define('LOGERRORFILE', LOGFILEDIR . 'autodiscover-error.log'); define('LOGLEVEL', LOGLEVEL_ERROR); diff --git a/conf/backend/config-imap.php b/conf/backend/config-imap.php index e48d50b..156c120 100644 --- a/conf/backend/config-imap.php +++ b/conf/backend/config-imap.php @@ -217,7 +217,7 @@ define('SYSTEM_MIME_TYPES_MAPPING', '/etc/mime.types'); // Use BackendCalDAV for Meetings. You cannot hope to get that functionality working without a caldav backend. -define('IMAP_MEETING_USE_CALDAV', __FLAGTOCHANGE__); +define('IMAP_MEETING_USE_CALDAV', __IMAP_MEETING_USE_CALDAV__); // If your IMAP server allows authenticating via GSSAPI, php-imap will not fall back properly to other authentication // methods and you will be unable to log in. Uncomment the following line to disable that authentication method. diff --git a/conf/config.php b/conf/config.php index 389ae9d..19154b0 100644 --- a/conf/config.php +++ b/conf/config.php @@ -120,7 +120,7 @@ $specialLogUsers = array(); // Filelog settings - define('LOGFILEDIR', '/var/log/__APP__/'); + define('LOGFILEDIR', '__LOG_DIR__'); define('LOGFILE', LOGFILEDIR . 'z-push.log'); define('LOGERRORFILE', LOGFILEDIR . 'z-push-error.log'); diff --git a/manifest.toml b/manifest.toml index c507539..fd1f790 100644 --- a/manifest.toml +++ b/manifest.toml @@ -42,6 +42,9 @@ ram.runtime = "50M" [resources.permissions] main.url = "/" + + # FIXME: watdo with this ... + #REMOVEME? ynh_permission_create --permission="autodiscover" --url="re:$domain_regex/[Aa]uto[Dd]iscover/.*" --allowed="visitors" --show_tile="false" --protected="true" [resources.apt] packages = "php7.4-soap, php7.4-imap, php7.4-xsl, php7.4-curl, php7.4-xml, php7.4-ldap, php7.4-cli, php7.4-mbstring, php7.4-memcached, libawl-php" diff --git a/scripts/install b/scripts/install index ff2da61..4b48fb9 100755 --- a/scripts/install +++ b/scripts/install @@ -14,6 +14,8 @@ source /usr/share/yunohost/helpers #================================================= path="/Microsoft-Server-ActiveSync" +timezone="$(cat /etc/timezone)" +log_dir="/var/log/$app" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -45,58 +47,40 @@ ynh_add_nginx_config #================================================= ynh_script_progression --message="Creating a final log path..." --weight=1 -final_logpath="/var/log/$app" -ynh_app_setting_set --app=$app --key=final_logpath --value=$final_logpath - -mkdir -p $final_logpath - -chmod 750 "$final_logpath" -chmod -R o-rwx "$final_logpath" -chown -R $app:www-data "$final_logpath" +mkdir -p $log_dir +chmod 750 "$log_dir" +chmod -R o-rwx "$log_dir" +chown -R $app:www-data "$log_dir" #================================================= # ADD A CONFIGURATION #================================================= ynh_script_progression --message="Adding a configuration file..." --weight=1 -# Configuration -ynh_replace_string --match_string="__TIMEZONE__" --replace_string=$(cat /etc/timezone) --target_file="../conf/config.php" -ynh_replace_string --match_string="__TIMEZONE__" --replace_string=$(cat /etc/timezone) --target_file="../conf/backend/config-autodiscover.php" -ynh_replace_string --match_string="__FINAL_LOGPATH__" --replace_string=$final_logpath --target_file="../conf/config.php" -ynh_replace_string --match_string="__FINAL_LOGPATH__" --replace_string=$final_logpath --target_file="../conf/backend/config-autodiscover.php" - -# Storage of state_dir in /home/yunohost.app -# This contains the sync status in between device and z-push -ynh_replace_string --match_string="__DATA_DIR__" --replace_string=$data_dir --target_file="../conf/config.php" - # Enable caldav carddav support if yunohost app list | grep -q 'id: baikal' ; then echo "Detected Baikal" - bailkaldomain=$(ynh_app_setting_get --app="baikal" --key=domain) - bailkalpath=$(ynh_app_setting_get --app="baikal" --key=path) - bailkalpath=${bailkalpath%/} + baikaldomain=$(ynh_app_setting_get --app="baikal" --key=domain) + baikalpath=$(ynh_app_setting_get --app="baikal" --key=path) + baikalpath=${baikalpath%/} - # Configuration of backend - ynh_replace_string --match_string="__BACKEND__" --replace_string="BackendCombined" --target_file="../conf/config.php" - ynh_replace_string --match_string="__BACKEND__" --replace_string="BackendCombined" --target_file="../conf/backend/config-autodiscover.php" + # Variables to hydrate template + backend="BackendCombined" + caldav_server="$baikaldomain" + caldav_path="${baikalpath}/cal.php/calendars/%u/" + caldav_personal="default" - # Configuration baikal - ynh_replace_string --match_string="__CALDAV_SERVER__" --replace_string="${bailkaldomain}" --target_file="../conf/backend/config-caldav.php" - ynh_replace_string --match_string="__CALDAV_PATH__" --replace_string="${bailkalpath}/cal.php/calendars/%u/" --target_file="../conf/backend/config-caldav.php" - ynh_replace_string --match_string="__CALDAV_PERSONAL__" --replace_string="default" --target_file="../conf/backend/config-caldav.php" + carddav_server="$baikaldomain" + carddav_path="${baikalpath}/card.php/addressbooks/%u/" + carddav_default_path="${baikalpath}/card.php/addressbooks/%u/default" - ynh_replace_string --match_string="__CARDDAV_SERVER__" --replace_string="${bailkaldomain}" --target_file="../conf/backend/config-carddav.php" - ynh_replace_string --match_string="__CARDDAV_PATH__" --replace_string="${bailkalpath}/card.php/addressbooks/%u/" --target_file="../conf/backend/config-carddav.php" - ynh_replace_string --match_string="__CARDDAV_DEFAULT_PATH__" --replace_string="${bailkalpath}/card.php/addressbooks/%u/default" --target_file="../conf/backend/config-carddav.php" + imap_server="$domain" + imap_meeting_use_caldav="true" - ynh_replace_string --match_string="__IMAP_SERVER__" --replace_string="${domain}" --target_file="../conf/backend/config-imap.php" - ynh_replace_string --match_string="__FLAGTOCHANGE__" --replace_string="true" --target_file="../conf/backend/config-imap.php" - - # Copy config - cp -af ../conf/backend/config-caldav.php $install_dir/backend/caldav/config.php - cp -af ../conf/backend/config-carddav.php $install_dir/backend/carddav/config.php - cp -af ../conf/backend/config-imap.php $install_dir/backend/imap/config.php - cp -af ../conf/backend/config-combined.php $install_dir/backend/combined/config.php + ynh_add_config --template="backend/config-caldav.php" --destination="$install_dir/backend/caldav/config.php" + ynh_add_config --template="backend/config-carddav.php" --destination="$install_dir/backend/carddav/config.php" + ynh_add_config --template="backend/config-imap.php" --destination="$install_dir/backend/imap/config.php" + ynh_add_config --template="backend/config-combined.php" --destination="$install_dir/backend/combined/config.php" elif yunohost app list | grep -q 'id: nextcloud' ; then echo "Detected NextCloud" @@ -104,44 +88,36 @@ elif yunohost app list | grep -q 'id: nextcloud' ; then nextcloudpath=$(ynh_app_setting_get --app="nextcloud" --key=path) nextcloudpath=${nextcloudpath%/} - # Configuration of backend - ynh_replace_string --match_string="__BACKEND__" --replace_string="BackendCombined" --target_file="../conf/config.php" - ynh_replace_string --match_string="__BACKEND__" --replace_string="BackendCombined" --target_file="../conf/backend/config-autodiscover.php" + # Variables to hydrate template + backend="BackendCombined" + caldav_server="$nextclouddomain" + caldav_path="${nextcloudpath}/remote.php/dav/calendars/%u/" + caldav_personal="personal" - # Configuration nextcloud - ynh_replace_string --match_string="__CALDAV_SERVER__" --replace_string="${nextclouddomain}" --target_file="../conf/backend/config-caldav.php" - ynh_replace_string --match_string="__CALDAV_PATH__" --replace_string="${nextcloudpath}/remote.php/dav/calendars/%u/" --target_file="../conf/backend/config-caldav.php" - ynh_replace_string --match_string="__CALDAV_PERSONAL__" --replace_string="personal" --target_file="../conf/backend/config-caldav.php" + carddav_server="$nextclouddomain" + carddav_path="${nextcloudpath}/remote.php/dav/addressbooks/users/%u/" + carddav_default_path="${nextcloudpath}/remote.php/dav/addressbooks/users/%u/" - ynh_replace_string --match_string="__CARDDAV_SERVER__" --replace_string="${nextclouddomain}" --target_file="../conf/backend/config-carddav.php" - ynh_replace_string --match_string="__CARDDAV_PATH__" --replace_string="${nextcloudpath}/remote.php/dav/addressbooks/users/%u/" --target_file="../conf/backend/config-carddav.php" - ynh_replace_string --match_string="__CARDDAV_DEFAULT_PATH__" --replace_string="${nextcloudpath}/remote.php/dav/addressbooks/users/%u/" --target_file="../conf/backend/config-carddav.php" + imap_server="$domain" + imap_meeting_use_caldav="true" - ynh_replace_string --match_string="__IMAP_SERVER__" --replace_string="${domain}" --target_file="../conf/backend/config-imap.php" - ynh_replace_string --match_string="__FLAGTOCHANGE__" --replace_string="true" --target_file="../conf/backend/config-imap.php" + ynh_add_config --template="backend/config-caldav.php" --destination="$install_dir/backend/caldav/config.php" + ynh_add_config --template="backend/config-carddav.php" --destination="$install_dir/backend/carddav/config.php" + ynh_add_config --template="backend/config-imap.php" --destination="$install_dir/backend/imap/config.php" + ynh_add_config --template="backend/config-combined.php" --destination="$install_dir/backend/combined/config.php" - # Copy config - cp -af ../conf/backend/config-caldav.php $install_dir/backend/caldav/config.php - cp -af ../conf/backend/config-carddav.php $install_dir/backend/carddav/config.php - cp -af ../conf/backend/config-imap.php $install_dir/backend/imap/config.php - cp -af ../conf/backend/config-combined.php $install_dir/backend/combined/config.php else - # Configuration of backend - ynh_replace_string --match_string="__BACKEND__" --replace_string="BackendIMAP" --target_file="../conf/config.php" - ynh_replace_string --match_string="__BACKEND__" --replace_string="BackendIMAP" --target_file="../conf/backend/config-autodiscover.php" - - # Configuration imap - ynh_replace_string --match_string="__IMAP_SERVER__" --replace_string="${domain}" --target_file="../conf/backend/config-imap.php" - ynh_replace_string --match_string="__FLAGTOCHANGE__" --replace_string="false" --target_file="../conf/backend/config-imap.php" - - # Copy config - cp -af ../conf/backend/config-imap.php $install_dir/backend/imap/config.php + backend="BackendIMAP" + imap_server="$domain" + imap_meeting_use_caldav="false" + + ynh_add_config --template="backend/config-imap.php" --destination="$install_dir/backend/imap/config.php" fi # Copy config -cp -af ../conf/config.php $install_dir/config.php -cp -af ../conf/backend/config-autodiscover.php $install_dir/autodiscover/config.php -cp -af ../conf/backend/config-searchldap.php $install_dir/backend/searchldap/config.php +ynh_add_config --template="config.php" --destination="$install_dir/config.php" +ynh_add_config --template="backend/config-autodiscover.php" --destination="$install_dir/autodiscover/config.php" +ynh_add_config --template="backend/config-searchldap.php" --destination="$install_dir/backend/searchldap/config.php" #Copy XMLElement.php ln -s /usr/share/awl/inc/XML* /var/www/$app/include/ @@ -156,14 +132,6 @@ ynh_script_progression --message="Configuring log rotation..." --weight=1 # Use logrotate to manage application logfile(s) ynh_use_logrotate -#================================================= -# SETUP SSOWAT -#================================================= -#REMOVEME? ynh_script_progression --message="Configuring permissions..." --weight=1 - -#domain_regex=$(echo "$domain" | sed 's@-@.@g') -#REMOVEME? ynh_permission_create --permission="autodiscover" --url="re:$domain_regex/[Aa]uto[Dd]iscover/.*" --allowed="visitors" --show_tile="false" --protected="true" - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/remove b/scripts/remove index 17a6924..6822235 100755 --- a/scripts/remove +++ b/scripts/remove @@ -25,7 +25,7 @@ ynh_remove_nginx_config # Remove the dedicated PHP-FPM config ynh_remove_fpm_config -ynh_secure_remove --file="$final_logpath" +ynh_secure_remove --file="$log_dir" #================================================= # END OF SCRIPT diff --git a/scripts/upgrade b/scripts/upgrade index 075c4d9..fa2a4f5 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -15,6 +15,9 @@ source /usr/share/yunohost/helpers upgrade_type=$(ynh_check_app_version_changed) +timezone="$(cat /etc/timezone)" +log_dir="/var/log/$app" + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -51,89 +54,67 @@ ynh_add_nginx_config #================================================= ynh_script_progression --message="Updating a config file..." --weight=1 -# Configuration -ynh_replace_string --match_string="__TIMEZONE__" --replace_string="$(cat /etc/timezone)" --target_file="../conf/config.php" -ynh_replace_string --match_string="__TIMEZONE__" --replace_string="$(cat /etc/timezone)" --target_file="../conf/backend/config-autodiscover.php" -ynh_replace_string --match_string="__FINAL_LOGPATH__" --replace_string="$final_logpath" --target_file="../conf/config.php" -ynh_replace_string --match_string="__FINAL_LOGPATH__" --replace_string="$final_logpath" --target_file="../conf/backend/config-autodiscover.php" - -# Storage of state_dir in /home/yunohost.app -# This contains the sync status in between device and z-push -ynh_replace_string __DATA_DIR__ $data_dir ../conf/config.php - # Enable caldav carddav support if yunohost app list | grep -q 'id: baikal' ; then echo "Detected Baikal" - bailkaldomain=$(ynh_app_setting_get --app=baikal --key=domain) - bailkalpath=$(ynh_app_setting_get --app=baikal --key=path) - bailkalpath=${bailkalpath%/} + baikaldomain=$(ynh_app_setting_get --app="baikal" --key=domain) + baikalpath=$(ynh_app_setting_get --app="baikal" --key=path) + baikalpath=${baikalpath%/} - # Configuration of backend - ynh_replace_string --match_string="__BACKEND__" --replace_string="BackendCombined" --target_file="../conf/config.php" - ynh_replace_string --match_string="__BACKEND__" --replace_string="BackendCombined" --target_file="../conf/backend/config-autodiscover.php" + # Variables to hydrate template + backend="BackendCombined" + caldav_server="$baikaldomain" + caldav_path="${baikalpath}/cal.php/calendars/%u/" + caldav_personal="default" - # Configuration baikal - ynh_replace_string --match_string="__CALDAV_SERVER__" --replace_string="${bailkaldomain}" --target_file="../conf/backend/config-caldav.php" - ynh_replace_string --match_string="__CALDAV_PATH__" --replace_string="${bailkalpath}/cal.php/calendars/%u/" --target_file="../conf/backend/config-caldav.php" - ynh_replace_string --match_string="__CALDAV_PERSONAL__" --replace_string="default" --target_file="../conf/backend/config-caldav.php" + carddav_server="$baikaldomain" + carddav_path="${baikalpath}/card.php/addressbooks/%u/" + carddav_default_path="${baikalpath}/card.php/addressbooks/%u/default" - ynh_replace_string --match_string="__CARDDAV_SERVER__" --replace_string="${bailkaldomain}" --target_file="../conf/backend/config-carddav.php" - ynh_replace_string --match_string="__CARDDAV_PATH__" --replace_string="${bailkalpath}/card.php/addressbooks/%u/" --target_file="../conf/backend/config-carddav.php" - ynh_replace_string --match_string="__CARDDAV_DEFAULT_PATH__" --replace_string="${bailkalpath}/card.php/addressbooks/%u/default" --target_file="../conf/backend/config-carddav.php" + imap_server="$domain" + imap_meeting_use_caldav="true" - ynh_replace_string --match_string="__IMAP_SERVER__" --replace_string="${domain}" --target_file="../conf/backend/config-imap.php" - ynh_replace_string --match_string="__FLAGTOCHANGE__" --replace_string="true" --target_file="../conf/backend/config-imap.php" - - # Copy config - cp -af ../conf/backend/config-caldav.php $install_dir/backend/caldav/config.php - cp -af ../conf/backend/config-carddav.php $install_dir/backend/carddav/config.php - cp -af ../conf/backend/config-imap.php $install_dir/backend/imap/config.php - cp -af ../conf/backend/config-combined.php $install_dir/backend/combined/config.php + ynh_add_config --template="backend/config-caldav.php" --destination="$install_dir/backend/caldav/config.php" + ynh_add_config --template="backend/config-carddav.php" --destination="$install_dir/backend/carddav/config.php" + ynh_add_config --template="backend/config-imap.php" --destination="$install_dir/backend/imap/config.php" + ynh_add_config --template="backend/config-combined.php" --destination="$install_dir/backend/combined/config.php" elif yunohost app list | grep -q 'id: nextcloud' ; then echo "Detected NextCloud" - nextclouddomain=$(ynh_app_setting_get --app=nextcloud --key=domain) - nextcloudpath=$(ynh_app_setting_get --app=nextcloud --key=path) + nextclouddomain=$(ynh_app_setting_get --app="nextcloud" --key=domain) + nextcloudpath=$(ynh_app_setting_get --app="nextcloud" --key=path) nextcloudpath=${nextcloudpath%/} - # Configuration of backend - ynh_replace_string --match_string="__BACKEND__" --replace_string="BackendCombined" --target_file="../conf/config.php" - ynh_replace_string --match_string="__BACKEND__" --replace_string="BackendCombined" --target_file="../conf/backend/config-autodiscover.php" + # Variables to hydrate template + backend="BackendCombined" + caldav_server="$nextclouddomain" + caldav_path="${nextcloudpath}/remote.php/dav/calendars/%u/" + caldav_personal="personal" - # Configuration nextcloud - ynh_replace_string --match_string="__CALDAV_SERVER__" --replace_string="${nextclouddomain}" --target_file="../conf/backend/config-caldav.php" - ynh_replace_string --match_string="__CALDAV_PATH__" --replace_string="${nextcloudpath}/remote.php/dav/calendars/%u/" --target_file="../conf/backend/config-caldav.php" - ynh_replace_string --match_string="__CALDAV_PERSONAL__" --replace_string="personal" --target_file="../conf/backend/config-caldav.php" + carddav_server="$nextclouddomain" + carddav_path="${nextcloudpath}/remote.php/dav/addressbooks/users/%u/" + carddav_default_path="${nextcloudpath}/remote.php/dav/addressbooks/users/%u/" - ynh_replace_string --match_string="__CARDDAV_SERVER__" --replace_string="${nextclouddomain}" --target_file="../conf/backend/config-carddav.php" - ynh_replace_string --match_string="__CARDDAV_PATH__" --replace_string="${nextcloudpath}/remote.php/dav/addressbooks/users/%u/contacts/" --target_file="../conf/backend/config-carddav.php" - ynh_replace_string --match_string="__CARDDAV_DEFAULT_PATH__" --replace_string="${nextcloudpath}/remote.php/dav/addressbooks/users/%u/contacts/" --target_file="../conf/backend/config-carddav.php" + imap_server="$domain" + imap_meeting_use_caldav="true" - ynh_replace_string --match_string="__IMAP_SERVER__" --replace_string="${domain}" --target_file="../conf/backend/config-imap.php" - ynh_replace_string --match_string="__FLAGTOCHANGE__" --replace_string="true" --target_file="../conf/backend/config-imap.php" + ynh_add_config --template="backend/config-caldav.php" --destination="$install_dir/backend/caldav/config.php" + ynh_add_config --template="backend/config-carddav.php" --destination="$install_dir/backend/carddav/config.php" + ynh_add_config --template="backend/config-imap.php" --destination="$install_dir/backend/imap/config.php" + ynh_add_config --template="backend/config-combined.php" --destination="$install_dir/backend/combined/config.php" - # Copy config - cp -af ../conf/backend/config-caldav.php $install_dir/backend/caldav/config.php - cp -af ../conf/backend/config-carddav.php $install_dir/backend/carddav/config.php - cp -af ../conf/backend/config-imap.php $install_dir/backend/imap/config.php - cp -af ../conf/backend/config-combined.php $install_dir/backend/combined/config.php else - # Configuration of backend - ynh_replace_string --match_string="__BACKEND__" --replace_string="BackendIMAP" --target_file="../conf/config.php" - ynh_replace_string --match_string="__BACKEND__" --replace_string="BackendIMAP" --target_file="../conf/backend/config-autodiscover.php" - - # Configuration imap - ynh_replace_string --match_string="__IMAP_SERVER__" --replace_string="${domain}" --target_file="../conf/backend/config-imap.php" - ynh_replace_string --match_string="__FLAGTOCHANGE__" --replace_string="false" --target_file="../conf/backend/config-imap.php" - - # Copy config - cp -af ../conf/backend/config-imap.php $install_dir/backend/imap/config.php + backend="BackendIMAP" + imap_server="$domain" + imap_meeting_use_caldav="false" + + ynh_add_config --template="backend/config-imap.php" --destination="$install_dir/backend/imap/config.php" fi # Copy config -cp -af ../conf/config.php $install_dir/config.php -cp -af ../conf/backend/config-autodiscover.php $install_dir/autodiscover/config.php -cp -af ../conf/backend/config-searchldap.php $install_dir/backend/searchldap/config.php +ynh_add_config --template="config.php" --destination="$install_dir/config.php" +ynh_add_config --template="backend/config-autodiscover.php" --destination="$install_dir/autodiscover/config.php" +ynh_add_config --template="backend/config-searchldap.php" --destination="$install_dir/backend/searchldap/config.php" # Fixstates to avoid full resync of devices after version upgrades $install_dir/z-push-admin.php -a fixstates From ca1a761d2c019be8bf167e7ca8b671901bae86b1 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Tue, 5 Dec 2023 01:31:04 +0100 Subject: [PATCH 11/16] z-push wants the log dir to end with a trailign slash >_> --- scripts/install | 24 ++++++------------------ scripts/restore | 5 +++++ scripts/upgrade | 25 +++++++++++-------------- 3 files changed, 22 insertions(+), 32 deletions(-) diff --git a/scripts/install b/scripts/install index 4b48fb9..8ae9a48 100755 --- a/scripts/install +++ b/scripts/install @@ -15,12 +15,12 @@ source /usr/share/yunohost/helpers path="/Microsoft-Server-ActiveSync" timezone="$(cat /etc/timezone)" -log_dir="/var/log/$app" +log_dir="/var/log/$app/" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Setting up source files..." --weight=1 +ynh_script_progression --message="Setting up source files..." # Download, check integrity, uncompress and patch the source from app.src mkdir -p "$install_dir/tmp" @@ -34,7 +34,7 @@ chown -R $app:www-data "$install_dir" #================================================= # PHP-FPM CONFIGURATION #================================================= -ynh_script_progression --message="Configuring PHP-FPM..." --weight=1 +ynh_script_progression --message="Installing system configurations..." # Create a dedicated PHP-FPM config ynh_add_fpm_config @@ -42,20 +42,17 @@ ynh_add_fpm_config # Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# CREATE FINAL LOG PATH -#================================================= -ynh_script_progression --message="Creating a final log path..." --weight=1 - mkdir -p $log_dir chmod 750 "$log_dir" chmod -R o-rwx "$log_dir" chown -R $app:www-data "$log_dir" +ynh_use_logrotate + #================================================= # ADD A CONFIGURATION #================================================= -ynh_script_progression --message="Adding a configuration file..." --weight=1 +ynh_script_progression --message="Adding a configuration file..." # Enable caldav carddav support if yunohost app list | grep -q 'id: baikal' ; then @@ -122,15 +119,6 @@ ynh_add_config --template="backend/config-searchldap.php" --destination="$instal #Copy XMLElement.php ln -s /usr/share/awl/inc/XML* /var/www/$app/include/ -#================================================= -# GENERIC FINALIZATION -#================================================= -# SETUP LOGROTATE -#================================================= -ynh_script_progression --message="Configuring log rotation..." --weight=1 - -# Use logrotate to manage application logfile(s) -ynh_use_logrotate #================================================= # END OF SCRIPT diff --git a/scripts/restore b/scripts/restore index 739d7bc..e980697 100755 --- a/scripts/restore +++ b/scripts/restore @@ -40,6 +40,11 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file --origin_path="/etc/logrotate.d/$app" +mkdir -p $log_dir +chmod 750 "$log_dir" +chmod -R o-rwx "$log_dir" +chown -R $app:www-data "$log_dir" + #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index fa2a4f5..2f88a74 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -16,7 +16,7 @@ source /usr/share/yunohost/helpers upgrade_type=$(ynh_check_app_version_changed) timezone="$(cat /etc/timezone)" -log_dir="/var/log/$app" +log_dir="/var/log/$app/" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -24,7 +24,7 @@ log_dir="/var/log/$app" if [ "$upgrade_type" == "UPGRADE_APP" ] then - ynh_script_progression --message="Upgrading source files..." --weight=1 + ynh_script_progression --message="Upgrading source files..." # Download, check integrity, uncompress and patch the source from app.src mkdir "$install_dir/tmp" @@ -39,7 +39,7 @@ chown -R $app:www-data "$install_dir" #================================================= # PHP-FPM CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=1 +ynh_script_progression --message="Installing system configurations..." # Create a dedicated PHP-FPM config ynh_add_fpm_config @@ -47,12 +47,19 @@ ynh_add_fpm_config # Create a dedicated NGINX config ynh_add_nginx_config +mkdir -p $log_dir +chmod 750 "$log_dir" +chmod -R o-rwx "$log_dir" +chown -R $app:www-data "$log_dir" + +ynh_use_logrotate --non-append + #================================================= # SPECIFIC UPGRADE #================================================= # UPDATE A CONFIG FILE #================================================= -ynh_script_progression --message="Updating a config file..." --weight=1 +ynh_script_progression --message="Updating a config file..." # Enable caldav carddav support if yunohost app list | grep -q 'id: baikal' ; then @@ -119,16 +126,6 @@ ynh_add_config --template="backend/config-searchldap.php" --destination="$instal # Fixstates to avoid full resync of devices after version upgrades $install_dir/z-push-admin.php -a fixstates -#================================================= -# GENERIC FINALIZATION -#================================================= -# SETUP LOGROTATE -#================================================= -ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1 - -# Use logrotate to manage app-specific logfile(s) -ynh_use_logrotate --non-append - #================================================= # END OF SCRIPT #================================================= From 9b56411c76b052e6ee38f60c60ccd6497b6da9a7 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Tue, 5 Dec 2023 01:46:22 +0100 Subject: [PATCH 12/16] Zbmlgrerg --- scripts/restore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/restore b/scripts/restore index e980697..6e26b08 100755 --- a/scripts/restore +++ b/scripts/restore @@ -10,6 +10,8 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers +log_dir="/var/log/$app/" + #================================================= # RESTORE THE APP MAIN DIR #================================================= From 77a15b6e283f945c919522c98809b55f0024a85e Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Tue, 5 Dec 2023 01:56:50 +0100 Subject: [PATCH 13/16] Keep conf files during upgrades >_> --- scripts/upgrade | 48 ++++++++++++++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 2f88a74..d9f4351 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -24,13 +24,33 @@ log_dir="/var/log/$app/" if [ "$upgrade_type" == "UPGRADE_APP" ] then - ynh_script_progression --message="Upgrading source files..." + ynh_script_progression --message="Upgrading source files..." - # Download, check integrity, uncompress and patch the source from app.src - mkdir "$install_dir/tmp" - ynh_setup_source --dest_dir="$install_dir/tmp" - cp -af "$install_dir/tmp/src/." "$install_dir/." - ynh_secure_remove --file="$install_dir/tmp" + mkdir "$install_dir/bkp" + conf_files_to_keep="backend/caldav/config.php backend/carddav/config.php backend/imap/config.php backend/combined/config.php autodiscover/config.php backend/searchldap/config.php" + for file in $conf_files_to_keep + do + if [ -e $install_dir/$file ] + then + mkdir -p $install_dir/bkp/$(dirname $file) + cp $install_dir/$file $install_dir/bkp/$file + fi + done + + # Download, check integrity, uncompress and patch the source from app.src + mkdir "$install_dir/tmp" + ynh_setup_source --dest_dir="$install_dir/tmp" + cp -af "$install_dir/tmp/src/." "$install_dir/." + ynh_secure_remove --file="$install_dir/tmp" + + for file in $conf_files_to_keep + do + if [ -e $install_dir/bkp/$file ] + then + cp $install_dir/bkp/$file $install_dir/$file + fi + done + ynh_secure_remove --file="$install_dir/bkp" fi chmod -R o-rwx "$install_dir" @@ -63,10 +83,10 @@ ynh_script_progression --message="Updating a config file..." # Enable caldav carddav support if yunohost app list | grep -q 'id: baikal' ; then - echo "Detected Baikal" - baikaldomain=$(ynh_app_setting_get --app="baikal" --key=domain) - baikalpath=$(ynh_app_setting_get --app="baikal" --key=path) - baikalpath=${baikalpath%/} + echo "Detected Baikal" + baikaldomain=$(ynh_app_setting_get --app="baikal" --key=domain) + baikalpath=$(ynh_app_setting_get --app="baikal" --key=path) + baikalpath=${baikalpath%/} # Variables to hydrate template backend="BackendCombined" @@ -87,10 +107,10 @@ if yunohost app list | grep -q 'id: baikal' ; then ynh_add_config --template="backend/config-combined.php" --destination="$install_dir/backend/combined/config.php" elif yunohost app list | grep -q 'id: nextcloud' ; then - echo "Detected NextCloud" - nextclouddomain=$(ynh_app_setting_get --app="nextcloud" --key=domain) - nextcloudpath=$(ynh_app_setting_get --app="nextcloud" --key=path) - nextcloudpath=${nextcloudpath%/} + echo "Detected NextCloud" + nextclouddomain=$(ynh_app_setting_get --app="nextcloud" --key=domain) + nextcloudpath=$(ynh_app_setting_get --app="nextcloud" --key=path) + nextcloudpath=${nextcloudpath%/} # Variables to hydrate template backend="BackendCombined" From 28d024a5045c8cc2c30107da475d20864c9d3d76 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Tue, 5 Dec 2023 02:36:19 +0100 Subject: [PATCH 14/16] aaaand forgot the main conf ofc --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index d9f4351..d148951 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -27,7 +27,7 @@ then ynh_script_progression --message="Upgrading source files..." mkdir "$install_dir/bkp" - conf_files_to_keep="backend/caldav/config.php backend/carddav/config.php backend/imap/config.php backend/combined/config.php autodiscover/config.php backend/searchldap/config.php" + conf_files_to_keep="config.php backend/caldav/config.php backend/carddav/config.php backend/imap/config.php backend/combined/config.php autodiscover/config.php backend/searchldap/config.php" for file in $conf_files_to_keep do if [ -e $install_dir/$file ] From fe0256da08d81a4ffbded4e19f12881ce59e4a87 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Tue, 5 Dec 2023 02:37:03 +0100 Subject: [PATCH 15/16] Fix path traversal issue ? --- conf/nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index b8f32b2..8c759d7 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,6 +1,6 @@ #sub_path_only rewrite ^Microsoft-Server-ActiveSync$ Microsoft-Server-ActiveSync/ permanent; rewrite ^/$ Microsoft-Server-ActiveSync/ permanent; -location /Microsoft-Server-ActiveSync { +location /Microsoft-Server-ActiveSync/ { # Path to source alias __INSTALL_DIR__/; From 88fc5e426d94962ed2a0e66a5727c5ccab69def8 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Tue, 5 Dec 2023 02:38:15 +0100 Subject: [PATCH 16/16] Initialize main perm --- manifest.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/manifest.toml b/manifest.toml index fd1f790..2e4a121 100644 --- a/manifest.toml +++ b/manifest.toml @@ -25,6 +25,8 @@ disk = "50M" ram.build = "50M" ram.runtime = "50M" +[install] + [install.domain] type = "domain" @@ -42,6 +44,7 @@ ram.runtime = "50M" [resources.permissions] main.url = "/" + main.allowed = "visitors" # should it always be public ? # FIXME: watdo with this ... #REMOVEME? ynh_permission_create --permission="autodiscover" --url="re:$domain_regex/[Aa]uto[Dd]iscover/.*" --allowed="visitors" --show_tile="false" --protected="true"