From 96fda9562e947c0cf081d4c0b3c74e5ec2a3062d Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 30 Mar 2019 22:28:14 +0100 Subject: [PATCH 01/16] Fix package_linter (#1) * Fix package_linter --- check_process | 2 +- manifest.json | 3 ++- scripts/_common.sh | 20 ++++++++++++++++++++ scripts/install | 41 +++++++++++++---------------------------- scripts/restore | 22 +++++++++++++++++++--- scripts/upgrade | 27 +++++++++++++++++++++++---- 6 files changed, 78 insertions(+), 37 deletions(-) create mode 100644 scripts/_common.sh diff --git a/check_process b/check_process index 6c82762..351f17f 100644 --- a/check_process +++ b/check_process @@ -15,7 +15,7 @@ multi_instance=0 wrong_user=0 wrong_path=1 - incorrect_path=1 + incorrect_path=0 corrupt_source=0 fail_download_source=0 port_already_use=0 diff --git a/manifest.json b/manifest.json index 94042f4..3a5c347 100644 --- a/manifest.json +++ b/manifest.json @@ -6,8 +6,9 @@ "en": "Z-Push is an Exchange ActiveSync fronted written in php which lets you synchronize emails (imap/smtp backend) and calendar/contacts (carddav and caldav backend)", "fr": "Z-Push est un fronted Exchange ActiveSync écrit en php qui permet de synchroniser vos email (backend imap/smtp) et vos contacts/calendrier (backend carddav et caldav)" }, + "version": "2.3.6~ynh2", "url": "https://z-push.org", - "license": "free", + "license": "AGPL-3.0-or-later", "maintainer": { "name": "beudbeud, polytan02" }, diff --git a/scripts/_common.sh b/scripts/_common.sh new file mode 100644 index 0000000..8bb05b4 --- /dev/null +++ b/scripts/_common.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +#================================================= +# COMMON VARIABLES +#================================================= + +# dependencies used by the app +pkg_dependencies="deb1 deb2" + +#================================================= +# PERSONAL HELPERS +#================================================= + +#================================================= +# EXPERIMENTAL HELPERS +#================================================= + +#================================================= +# FUTURE OFFICIAL HELPERS +#================================================= diff --git a/scripts/install b/scripts/install index 4d6b0c4..363be05 100755 --- a/scripts/install +++ b/scripts/install @@ -1,36 +1,21 @@ #!/bin/bash -# Active trap pour arrêter le script si une erreur est détectée. -EXIT_PROPERLY () { # Provoque l'arrêt du script en cas d'erreur. Et nettoye les résidus. - exit_code=$? - if [ "$exit_code" -eq 0 ]; then - exit 0 # Quitte sans erreur si le script se termine correctement. - fi - trap '' EXIT - set +eu - echo -e "\e[91m \e[1m" # Shell in light red bold - echo -e "!!\n $app install's script has encountered an error. Installation was cancelled.\n!!" >&2 +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= - if type -t CLEAN_SETUP > /dev/null; then # Vérifie l'existance de la fonction avant de l'exécuter. - CLEAN_SETUP # Appel la fonction de nettoyage spécifique du script install. - fi - - # Compense le bug de ssowat qui ne supprime pas l'entrée de l'app en cas d'erreur d'installation. - sudo sed -i "\@\"$domain$path/\":@d" /etc/ssowat/conf.json - - ynh_die -} - -TRAP_ON () { # Activate signal capture - set -eu # Exit if a command fail, and if a variable is used unset. - trap EXIT_PROPERLY EXIT # Capturing exit signals on shell script -} - -TRAP_ON - -# Source app helpers +source _common.sh source /usr/share/yunohost/helpers +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= + +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + # Retrieve arguments app=$YNH_APP_INSTANCE_NAME domain=$YNH_APP_ARG_DOMAIN diff --git a/scripts/restore b/scripts/restore index 6c723c3..2dd9d68 100755 --- a/scripts/restore +++ b/scripts/restore @@ -1,11 +1,27 @@ #!/bin/bash -set -eu -app=$YNH_APP_INSTANCE_NAME +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= -# Source YunoHost helpers +#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts +source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= + +ynh_clean_setup () { + #### Remove this function if there's nothing to clean before calling the remove script. + true +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors +app=$YNH_APP_INSTANCE_NAME + # Retrieve old app settings path=$(ynh_app_setting_get $app path) domain=$(ynh_app_setting_get $app domain) diff --git a/scripts/upgrade b/scripts/upgrade index 984bed5..cca630d 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,7 +1,12 @@ #!/bin/bash -set -eu -# Source app helpers +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source _common.sh source /usr/share/yunohost/helpers # Retrieve arguments @@ -23,6 +28,20 @@ else echo "${final_path} exists, we don't create it." fi +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= +ynh_print_info "Backing up the app before upgrading (may take a while)..." + +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + # restore it if the upgrade fails + ynh_restore_upgradebackup +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + if [ -z "$statedir" ]; then statedir="/home/yunohost.app/$app" @@ -64,8 +83,8 @@ ynh_package_install_from_equivs ../conf/z-push-deps.control \ # Cleaning -sudo rm -rf $final_path -sudo rm -rf $final_logpath +ynh_secure_remove "$final_path" +ynh_secure_remove "$final_logpath" sudo rm -f $final_nginxconf sudo rm -f $final_phpconf sudo rm -f /etc/logrotate.d/$app From 71cbe948ee7f036c46a4781d2133a5ffb4ac7849 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 31 Mar 2019 04:34:31 +0200 Subject: [PATCH 02/16] 2 example ynh (#2) * Fix package_linter errors * Apply example_ynh on check_process * Apply example_ynh on install script * Fix timezone * Apply example_ynh on remove script * Apply example_ynh to backup script * Apply example_ynh on restore script * Fix to php7 * remove sudo * Fix dependencies list * Fix to PHP 7.0 * Fix Yunohost version * Apply example_ynh to upgrade script * Remove sudo * apply example_ynh on php-fpm.conf * Apply example_ynh to readme * Scripts fix * Setup Public * Reorder --- README.md | 43 +++++ check_process | 28 ++- conf/app.src | 6 + conf/backend/config-caldav.php | 4 +- conf/backend/config-carddav.php | 4 +- conf/backend/config-imap.php | 4 +- conf/config.php | 8 +- conf/logrotate | 31 ---- conf/nginx.conf | 6 +- conf/php-fpm.conf | 302 +++++++++++++++++++++++++------- conf/z-push-deps.control | 16 -- manifest.json | 14 +- scripts/_common.sh | 2 +- scripts/backup | 72 ++++++-- scripts/install | 259 +++++++++++++-------------- scripts/remove | 135 +++++++------- scripts/restore | 105 ++++++----- scripts/upgrade | 249 ++++++++++++++------------ sources/source_file | 1 - sources/source_md5 | 1 - sources/source_url | 1 - 21 files changed, 780 insertions(+), 511 deletions(-) create mode 100644 conf/app.src delete mode 100644 conf/logrotate delete mode 100644 conf/z-push-deps.control delete mode 100644 sources/source_file delete mode 100644 sources/source_md5 delete mode 100644 sources/source_url diff --git a/README.md b/README.md index 5e81c55..c0d4598 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,15 @@ # Z-Push For Yunohost +[![Integration level](https://dash.yunohost.org/integration/z-push.svg)](https://dash.yunohost.org/appci/app/z-push) +[![Install z-push with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=z-push) + +> *This package allow you to install Z-Push quickly and simply on a YunoHost server. +If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.* + +## Overview +Z-Push is an Exchange ActiveSync fronted written in php which lets you synchronize emails (imap/smtp backend) and calendar/contacts (carddav and caldav backend) + +**Shipped version:** 2.3.6 + * * * ### Known bug : - [ ] [Issue 25](https://github.com/YunoHost-Apps/z-push_ynh/issues/25) : z-push seems unable to create mailboxes folders. It means that you must send at least one email from roundcube or rainloop to have the mailboxes created. After than it all works fine. @@ -15,3 +26,35 @@ - [x] The sources are based on http://download.z-push.org/final/ - [x] Use of version 2.3.6 final +## Documentation + + * Official documentation: https://wiki.z-hub.io/display/ZP/Documentation + +#### Supported architectures + +* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/z-push%20%28Community%29.svg)](https://ci-apps.yunohost.org/ci/apps/z-push/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/z-push%20%28Community%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/z-push/) +* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/z-push%20%28Community%29.svg)](https://ci-stretch.nohost.me/ci/apps/z-push/) + + +## Links + + * Report a bug: https://github.com/YunoHost-Apps/z-push_ynh/issues + * App website: http://z-push.org/ + * App github website: https://github.com/Z-Hub/Z-Push + * YunoHost website: https://yunohost.org/ + +--- + +Developers info +---------------- + +**Only if you want to use a testing branch for coding, instead of merging directly into master.** +Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/z-push_ynh/tree/testing). + +To try the testing branch, please proceed like that. +``` +sudo yunohost app install https://github.com/YunoHost-Apps/z-push_ynh/tree/testing --debug +or +sudo yunohost app upgrade z-push -u https://github.com/YunoHost-Apps/z-push_ynh/tree/testing --debug +``` diff --git a/check_process b/check_process index 351f17f..6b19827 100644 --- a/check_process +++ b/check_process @@ -9,25 +9,23 @@ setup_root=0 setup_nourl=0 setup_private=0 - setup_public=0 + setup_public=1 upgrade=1 + upgrade=1 from_commit=bdac42b709cd2bc663a68422f69ac6bfd43a1ce5 backup_restore=1 multi_instance=0 - wrong_user=0 - wrong_path=1 incorrect_path=0 - corrupt_source=0 - fail_download_source=0 port_already_use=0 - final_path_already_use=0 + change_url=0 ;;; Levels - Level 1=auto - Level 2=auto - Level 3=auto -# ? - Level 4=1 -# ? - Level 5=1 - Level 6=auto - Level 7=auto + Level 1=auto + Level 2=auto + Level 3=auto + Level 4=0 + Level 5=auto + Level 6=auto + Level 7=auto + Level 8=0 + Level 9=0 + Level 10=0 diff --git a/conf/app.src b/conf/app.src new file mode 100644 index 0000000..506e928 --- /dev/null +++ b/conf/app.src @@ -0,0 +1,6 @@ +SOURCE_URL=http://download.z-push.org/final/2.3/z-push-2.3.6.tar.gz +SOURCE_SUM=9f86e4f6d822558bffdf05bebce4f1157ed7d8784b52d488935ef6d02efc27d7 +SOURCE_SUM_PRG=sha256sum +SOURCE_FORMAT=tar.gz +SOURCE_IN_SUBDIR=true +SOURCE_FILENAME= diff --git a/conf/backend/config-caldav.php b/conf/backend/config-caldav.php index 8a8d627..d90ddb5 100644 --- a/conf/backend/config-caldav.php +++ b/conf/backend/config-caldav.php @@ -33,13 +33,13 @@ define('CALDAV_PROTOCOL', 'https'); // Server name -define('CALDAV_SERVER', 'BAIKALDOMAIN'); +define('CALDAV_SERVER', '__BAIKALDOMAIN__'); // Server port define('CALDAV_PORT', '443'); // Path -define('CALDAV_PATH', 'BAIKALPATH/cal.php/calendars/%u/'); +define('CALDAV_PATH', '__BAIKALPATH__/cal.php/calendars/%u/'); // Default CalDAV folder (calendar folder/principal). This will be marked as the default calendar in the mobile define('CALDAV_PERSONAL', 'default'); diff --git a/conf/backend/config-carddav.php b/conf/backend/config-carddav.php index e4a0e4b..95d1103 100644 --- a/conf/backend/config-carddav.php +++ b/conf/backend/config-carddav.php @@ -31,7 +31,7 @@ define('CARDDAV_PROTOCOL', 'https'); // Server name -define('CARDDAV_SERVER', 'BAIKALDOMAIN'); +define('CARDDAV_SERVER', '__BAIKALDOMAIN__'); // Server port define('CARDDAV_PORT', '443'); @@ -45,7 +45,7 @@ define('CARDDAV_PORT', '443'); // %u: replaced with the username // %d: replaced with the domain // Add the trailing / -define('CARDDAV_PATH', 'BAIKALPATH/card.php/addressbooks/%u/'); +define('CARDDAV_PATH', '__BAIKALPATH__/card.php/addressbooks/%u/'); // Server path to the default addressbook diff --git a/conf/backend/config-imap.php b/conf/backend/config-imap.php index b6c2d16..664a172 100644 --- a/conf/backend/config-imap.php +++ b/conf/backend/config-imap.php @@ -203,7 +203,7 @@ global $imap_smtp_params; // IMPORTANT: To use SSL you must use PHP 5.1 or later, install openssl libs and use ssl:// within the host variable // IMPORTANT: To use SSL with PHP 5.6 you should set verify_peer, verify_peer_name and allow_self_signed //$imap_smtp_params = array('host' => 'ssl://localhost', 'port' => 465, 'auth' => true, 'username' => 'imap_username', 'password' => 'imap_password'); -$imap_smtp_params = array('host' => 'tcp://DOMAINTOCHANGE', 'port' => 587, 'auth' => true, 'username' => 'imap_username', 'password' => 'imap_password', 'localhost' => 'DOMAINTOCHANGE', 'verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true); +$imap_smtp_params = array('host' => 'tcp://__DOMAINTOCHANGE__', 'port' => 587, 'auth' => true, 'username' => 'imap_username', 'password' => 'imap_password', 'localhost' => '__DOMAINTOCHANGE__', 'verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true); @@ -219,4 +219,4 @@ 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', __FLAGTOCHANGE__); diff --git a/conf/config.php b/conf/config.php index 0c3ed7f..c0877a0 100644 --- a/conf/config.php +++ b/conf/config.php @@ -27,7 +27,7 @@ * Default settings */ // Defines the default time zone, change e.g. to "Europe/London" if necessary - define('TIMEZONE', ''); + define('TIMEZONE', '__TIMEZONE__'); // Defines the base path on the server define('BASE_PATH', dirname($_SERVER['SCRIPT_FILENAME']). '/'); @@ -61,7 +61,7 @@ * State migration script is available, more informations: https://wiki.z-hub.io/x/xIAa */ define('STATE_MACHINE', 'FILE'); - define('STATE_DIR', 'STATEDIRTOCHANGE/'); + define('STATE_DIR', '__STATEDIR__/'); /********************************************************************************** * IPC - InterProcessCommunication @@ -110,7 +110,7 @@ $specialLogUsers = array(); // Filelog settings - define('LOGFILEDIR', 'LOGTOCHANGE/'); + define('LOGFILEDIR', '__FINAL_LOGPATH__/'); define('LOGFILE', LOGFILEDIR . 'z-push.log'); define('LOGERRORFILE', LOGFILEDIR . 'z-push-error.log'); @@ -266,7 +266,7 @@ * Backend settings */ // the backend data provider - define('BACKEND_PROVIDER', 'BACKENDTOCHANGE'); + define('BACKEND_PROVIDER', '__BACKEND__'); /********************************************************************************** * Search provider settings diff --git a/conf/logrotate b/conf/logrotate deleted file mode 100644 index 97da905..0000000 --- a/conf/logrotate +++ /dev/null @@ -1,31 +0,0 @@ - -LOGTOCHANGE/*.log { - -# Rotate if the logfile exceeds 100Mo - size 10M - -# From https://stash.z-hub.io/projects/ZP/repos/z-push/browse/config/z-push.lr - create www-data www-data - -# Keep 12 old log maximum - rotate 10 - -# Compress the logs with gzip - compress - -# Compress the log at the next cycle. So keep always 2 non compressed logs - delaycompress - -# Copy and truncate the log to allow to continue write on it. Instead of move the log. - copytruncate - -# Do not do an error if the log is missing - missingok - -# Not rotate if the log is empty - notifempty - -# Keep old logs in the same dir - noolddir - -} diff --git a/conf/nginx.conf b/conf/nginx.conf index bf1430d..35df35c 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,5 +1,5 @@ location /Microsoft-Server-ActiveSync { - alias ALIASTOCHANGE; + alias __FINALPATH__/ ; if ($scheme = http) { rewrite ^ https://$server_name$request_uri? permanent; } @@ -9,7 +9,8 @@ location /Microsoft-Server-ActiveSync { rewrite ^(.*)$ /Microsoft-Server-ActiveSync/index.php last; location ~ [^/]\.php(/|$) { fastcgi_split_path_info ^(.+?\.php)(/.*)$; - fastcgi_pass unix:/var/run/php5-fpm-NAMETOCHANGE.sock; + fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock; + fastcgi_index index.php; include fastcgi_params; fastcgi_param HTTPS on; @@ -20,4 +21,3 @@ location /Microsoft-Server-ActiveSync { # Include SSOWAT user panel. include conf.d/yunohost_panel.conf.inc; } - diff --git a/conf/php-fpm.conf b/conf/php-fpm.conf index c04f35e..6de65f1 100644 --- a/conf/php-fpm.conf +++ b/conf/php-fpm.conf @@ -1,10 +1,11 @@ ; Start a new pool named 'www'. -; the variable $pool can we used in any directive and will be replaced by the +; the variable $pool can be used in any directive and will be replaced by the ; pool name ('www' here) -[NAMETOCHANGE] +[__NAMETOCHANGE__] ; Per pool prefix ; It only applies on the following directives: +; - 'access.log' ; - 'slowlog' ; - 'listen' (unixsocket) ; - 'chroot' @@ -16,21 +17,43 @@ ; Default Value: none ;prefix = /path/to/pools/$pool +; Unix user/group of processes +; Note: The user is mandatory. If the group is not set, the default user's group +; will be used. +user = www-data +group = www-data + ; The address on which to accept FastCGI requests. ; Valid syntaxes are: -; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific address on +; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on ; a specific port; -; 'port' - to listen on a TCP socket to all addresses on a -; specific port; +; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on +; a specific port; +; 'port' - to listen on a TCP socket to all addresses +; (IPv6 and IPv4-mapped) on a specific port; ; '/path/to/unix/socket' - to listen on a unix socket. ; Note: This value is mandatory. -listen = /var/run/php5-fpm-NAMETOCHANGE.sock +listen = /var/run/php/php7.0-fpm-__NAMETOCHANGE__.sock -; Set listen(2) backlog. A value of '-1' means unlimited. -; Default Value: 128 (-1 on FreeBSD and OpenBSD) -;listen.backlog = -1 +; Set listen(2) backlog. +; Default Value: 511 (-1 on FreeBSD and OpenBSD) +;listen.backlog = 511 -; List of ipv4 addresses of FastCGI clients which are allowed to connect. +; Set permissions for unix socket, if one is used. In Linux, read/write +; permissions must be set in order to allow connections from a web server. Many +; BSD-derived systems allow connections regardless of permissions. +; Default Values: user and group are set as the running user +; mode is set to 0660 +listen.owner = www-data +listen.group = www-data +listen.mode = 0600 +; When POSIX Access Control Lists are supported you can set them using +; these options, value is a comma separated list of user/group names. +; When set, listen.owner and listen.group are ignored +;listen.acl_users = +;listen.acl_groups = + +; List of addresses (IPv4/IPv6) of FastCGI clients which are allowed to connect. ; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original ; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address ; must be separated by a comma. If this value is left blank, connections will be @@ -38,26 +61,26 @@ listen = /var/run/php5-fpm-NAMETOCHANGE.sock ; Default Value: any ;listen.allowed_clients = 127.0.0.1 -; Set permissions for unix socket, if one is used. In Linux, read/write -; permissions must be set in order to allow connections from a web server. Many -; BSD-derived systems allow connections regardless of permissions. -; Default Values: user and group are set as the running user -; mode is set to 0666 -listen.owner = www-data -listen.group = www-data -listen.mode = 0600 +; Specify the nice(2) priority to apply to the pool processes (only if set) +; The value can vary from -19 (highest priority) to 20 (lower priority) +; Note: - It will only work if the FPM master process is launched as root +; - The pool processes will inherit the master process priority +; unless it specified otherwise +; Default Value: no set +; process.priority = -19 -; Unix user/group of processes -; Note: The user is mandatory. If the group is not set, the default user's group -; will be used. -user = www-data -group = www-data +; Set the process dumpable flag (PR_SET_DUMPABLE prctl) even if the process user +; or group is differrent than the master process user. It allows to create process +; core dump and ptrace the process for the pool user. +; Default Value: no +; process.dumpable = yes ; Choose how the process manager will control the number of child processes. ; Possible Values: ; static - a fixed number (pm.max_children) of child processes; ; dynamic - the number of child processes are set dynamically based on the -; following directives: +; following directives. With this process management, there will be +; always at least 1 children. ; pm.max_children - the maximum number of children that can ; be alive at the same time. ; pm.start_servers - the number of children created on startup. @@ -69,16 +92,23 @@ group = www-data ; state (waiting to process). If the number ; of 'idle' processes is greater than this ; number then some children will be killed. +; ondemand - no children are created at startup. Children will be forked when +; new requests will connect. The following parameter are used: +; pm.max_children - the maximum number of children that +; can be alive at the same time. +; pm.process_idle_timeout - The number of seconds after which +; an idle process will be killed. ; Note: This value is mandatory. pm = dynamic ; The number of child processes to be created when pm is set to 'static' and the -; maximum number of child processes to be created when pm is set to 'dynamic'. +; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'. ; This value sets the limit on the number of simultaneous requests that will be ; served. Equivalent to the ApacheMaxClients directive with mpm_prefork. ; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP -; CGI. -; Note: Used when pm is set to either 'static' or 'dynamic' +; CGI. The below defaults are based on a server without much resources. Don't +; forget to tweak pm.* to fit your needs. +; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand' ; Note: This value is mandatory. pm.max_children = 10 @@ -97,6 +127,11 @@ pm.min_spare_servers = 3 ; Note: Mandatory when pm is set to 'dynamic' pm.max_spare_servers = 5 +; The number of seconds after which an idle process will be killed. +; Note: Used only when pm is set to 'ondemand' +; Default Value: 10s +;pm.process_idle_timeout = 10s; + ; The number of requests each child process should execute before respawning. ; This can be useful to work around memory leaks in 3rd party libraries. For ; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS. @@ -104,33 +139,98 @@ pm.max_spare_servers = 5 pm.max_requests = 0 ; The URI to view the FPM status page. If this value is not set, no URI will be -; recognized as a status page. By default, the status page shows the following -; information: -; accepted conn - the number of request accepted by the pool; +; recognized as a status page. It shows the following informations: ; pool - the name of the pool; -; process manager - static or dynamic; +; process manager - static, dynamic or ondemand; +; start time - the date and time FPM has started; +; start since - number of seconds since FPM has started; +; accepted conn - the number of request accepted by the pool; +; listen queue - the number of request in the queue of pending +; connections (see backlog in listen(2)); +; max listen queue - the maximum number of requests in the queue +; of pending connections since FPM has started; +; listen queue len - the size of the socket queue of pending connections; ; idle processes - the number of idle processes; ; active processes - the number of active processes; -; total processes - the number of idle + active processes. +; total processes - the number of idle + active processes; +; max active processes - the maximum number of active processes since FPM +; has started; ; max children reached - number of times, the process limit has been reached, ; when pm tries to start more children (works only for -; pm 'dynamic') -; The values of 'idle processes', 'active processes' and 'total processes' are -; updated each second. The value of 'accepted conn' is updated in real time. +; pm 'dynamic' and 'ondemand'); +; Value are updated in real time. ; Example output: -; accepted conn: 12073 ; pool: www ; process manager: static -; idle processes: 35 -; active processes: 65 -; total processes: 100 -; max children reached: 1 +; start time: 01/Jul/2011:17:53:49 +0200 +; start since: 62636 +; accepted conn: 190460 +; listen queue: 0 +; max listen queue: 1 +; listen queue len: 42 +; idle processes: 4 +; active processes: 11 +; total processes: 15 +; max active processes: 12 +; max children reached: 0 +; ; By default the status page output is formatted as text/plain. Passing either -; 'html' or 'json' as a query string will return the corresponding output -; syntax. Example: +; 'html', 'xml' or 'json' in the query string will return the corresponding +; output syntax. Example: ; http://www.foo.bar/status ; http://www.foo.bar/status?json ; http://www.foo.bar/status?html +; http://www.foo.bar/status?xml +; +; By default the status page only outputs short status. Passing 'full' in the +; query string will also return status for each pool process. +; Example: +; http://www.foo.bar/status?full +; http://www.foo.bar/status?json&full +; http://www.foo.bar/status?html&full +; http://www.foo.bar/status?xml&full +; The Full status returns for each process: +; pid - the PID of the process; +; state - the state of the process (Idle, Running, ...); +; start time - the date and time the process has started; +; start since - the number of seconds since the process has started; +; requests - the number of requests the process has served; +; request duration - the duration in µs of the requests; +; request method - the request method (GET, POST, ...); +; request URI - the request URI with the query string; +; content length - the content length of the request (only with POST); +; user - the user (PHP_AUTH_USER) (or '-' if not set); +; script - the main script called (or '-' if not set); +; last request cpu - the %cpu the last request consumed +; it's always 0 if the process is not in Idle state +; because CPU calculation is done when the request +; processing has terminated; +; last request memory - the max amount of memory the last request consumed +; it's always 0 if the process is not in Idle state +; because memory calculation is done when the request +; processing has terminated; +; If the process is in Idle state, then informations are related to the +; last request the process has served. Otherwise informations are related to +; the current request being served. +; Example output: +; ************************ +; pid: 31330 +; state: Running +; start time: 01/Jul/2011:17:53:49 +0200 +; start since: 63087 +; requests: 12808 +; request duration: 1250261 +; request method: GET +; request URI: /test_mem.php?N=10000 +; content length: 0 +; user: - +; script: /home/fat/web/docs/php/test_mem.php +; last request cpu: 0.00 +; last request memory: 0 +; +; Note: There is a real-time FPM status monitoring sample web page available +; It's available in: /usr/share/php/7.0/fpm/status.html +; ; Note: The value must start with a leading slash (/). The value can be ; anything, but it may not be a good idea to use the .php extension or it ; may conflict with a real PHP file. @@ -154,12 +254,73 @@ ping.path = /ping ; Default Value: pong ;ping.response = pong -; The timeout for serving a single request after which the worker process will -; be killed. This option should be used when the 'max_execution_time' ini option -; does not stop script execution for some reason. A value of '0' means 'off'. -; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) -; Default Value: 0 -request_terminate_timeout = 700s +; The access log file +; Default: not set +;access.log = log/$pool.access.log + +; The access log format. +; The following syntax is allowed +; %%: the '%' character +; %C: %CPU used by the request +; it can accept the following format: +; - %{user}C for user CPU only +; - %{system}C for system CPU only +; - %{total}C for user + system CPU (default) +; %d: time taken to serve the request +; it can accept the following format: +; - %{seconds}d (default) +; - %{miliseconds}d +; - %{mili}d +; - %{microseconds}d +; - %{micro}d +; %e: an environment variable (same as $_ENV or $_SERVER) +; it must be associated with embraces to specify the name of the env +; variable. Some exemples: +; - server specifics like: %{REQUEST_METHOD}e or %{SERVER_PROTOCOL}e +; - HTTP headers like: %{HTTP_HOST}e or %{HTTP_USER_AGENT}e +; %f: script filename +; %l: content-length of the request (for POST request only) +; %m: request method +; %M: peak of memory allocated by PHP +; it can accept the following format: +; - %{bytes}M (default) +; - %{kilobytes}M +; - %{kilo}M +; - %{megabytes}M +; - %{mega}M +; %n: pool name +; %o: output header +; it must be associated with embraces to specify the name of the header: +; - %{Content-Type}o +; - %{X-Powered-By}o +; - %{Transfert-Encoding}o +; - .... +; %p: PID of the child that serviced the request +; %P: PID of the parent of the child that serviced the request +; %q: the query string +; %Q: the '?' character if query string exists +; %r: the request URI (without the query string, see %q and %Q) +; %R: remote IP address +; %s: status (response code) +; %t: server time the request was received +; it can accept a strftime(3) format: +; %d/%b/%Y:%H:%M:%S %z (default) +; The strftime(3) format must be encapsuled in a %{}t tag +; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t +; %T: time the log has been written (the request has finished) +; it can accept a strftime(3) format: +; %d/%b/%Y:%H:%M:%S %z (default) +; The strftime(3) format must be encapsuled in a %{}t tag +; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t +; %u: remote user +; +; Default: "%R - %u %t \"%m %r\" %s" +;access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%" + +; The log file for slow requests +; Default Value: not set +; Note: slowlog is mandatory if request_slowlog_timeout is set +slowlog = /var/log/nginx/__NAMETOCHANGE__.slow.log ; The timeout for serving a single request after which a PHP backtrace will be ; dumped to the 'slowlog' file. A value of '0s' means 'off'. @@ -167,10 +328,12 @@ request_terminate_timeout = 700s ; Default Value: 0 request_slowlog_timeout = 5s -; The log file for slow requests -; Default Value: not set -; Note: slowlog is mandatory if request_slowlog_timeout is set -slowlog = /var/log/nginx/NAMETOCHANGE.slow.log +; The timeout for serving a single request after which the worker process will +; be killed. This option should be used when the 'max_execution_time' ini option +; does not stop script execution for some reason. A value of '0' means 'off'. +; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) +; Default Value: 0 +request_terminate_timeout = 700s ; Set open file descriptor rlimit. ; Default Value: system defined value @@ -195,7 +358,7 @@ rlimit_core = 0 ; Chdir to this directory at the start. ; Note: relative path can be used. ; Default Value: current directory or / when chroot -chdir = /var/www/NAMETOCHANGE +chdir = /var/www/__NAMETOCHANGE__ ; Redirect worker stdout and stderr into main error log. If not set, stdout and ; stderr will be redirected to /dev/null according to FastCGI specs. @@ -204,6 +367,23 @@ chdir = /var/www/NAMETOCHANGE ; Default Value: no catch_workers_output = yes +; Clear environment in FPM workers +; Prevents arbitrary environment variables from reaching FPM worker processes +; by clearing the environment in workers before env vars specified in this +; pool configuration are added. +; Setting to "no" will make all environment variables available to PHP code +; via getenv(), $_ENV and $_SERVER. +; Default Value: yes +;clear_env = no + +; Limits the extensions of the main script FPM will allow to parse. This can +; prevent configuration mistakes on the web server side. You should only limit +; FPM to .php extensions to prevent malicious users to use other extensions to +; execute php code. +; Note: set an empty value to allow all extensions. +; Default Value: .php +;security.limit_extensions = .php .php3 .php4 .php5 .php7 + ; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from ; the current environment. ; Default Value: clean env @@ -238,11 +418,13 @@ catch_workers_output = yes ;php_admin_flag[log_errors] = on ;php_admin_value[memory_limit] = 32M -php_value[upload_max_filesize] = 50M -php_value[post_max_size] = 50M -php_value[mail.add_x_header] = Off -php_value[max_execution_time] = 600 -php_value[max_input_time] = 300 -php_value[memory_limit] = 256M -php_value[short_open_tag] = On +; Common values to change to increase file upload limit +php_admin_value[upload_max_filesize] = 50M +php_admin_value[post_max_size] = 50M +php_admin_flag[mail.add_x_header] = Off +; Other common parameters +php_admin_value[max_execution_time] = 600 +php_admin_value[max_input_time] = 300 +php_admin_value[memory_limit] = 256M +php_admin_flag[short_open_tag] = On diff --git a/conf/z-push-deps.control b/conf/z-push-deps.control deleted file mode 100644 index af76e6a..0000000 --- a/conf/z-push-deps.control +++ /dev/null @@ -1,16 +0,0 @@ -Section: misc -Priority: optional -Homepage: http://z-push.org/ -Standards-Version: 2.3.4 - -Package: z-push-deps -Version: 1.2-1 -Depends: php-soap, php5-imap, libawl-php, php5-xsl -Architecture: all -Description: meta package for z-push dependencies - Z-Push is an open-source application to synchronize - ActiveSync compatible devices such as mobile phones, - tablets and Outlook 2013 and above. - . - . - This meta-package is only responsible of installing its dependencies. diff --git a/manifest.json b/manifest.json index 3a5c347..fc797b2 100644 --- a/manifest.json +++ b/manifest.json @@ -13,11 +13,11 @@ "name": "beudbeud, polytan02" }, "requirements": { - "yunohost": ">=2.4.0" + "yunohost": ">= 3.4" }, "services": [ "nginx", - "php5-fpm" + "php7.0-fpm" ], "multi_instance": true, "arguments": { @@ -30,16 +30,6 @@ "fr": "Choisissez un domaine pour Z-push" }, "example": "domain.org" - }, - { - "name": "path", - "type": "path", - "ask": { - "en": "No choice, it must be /Microsoft-Server-ActiveSync", - "fr": "Pas de choix, cela doit être /Microsoft-Server-ActiveSync" - }, - "choices": ["/Microsoft-Server-ActiveSync"], - "default": "/Microsoft-Server-ActiveSync" } ] } diff --git a/scripts/_common.sh b/scripts/_common.sh index 8bb05b4..b4c32ea 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,7 +5,7 @@ #================================================= # dependencies used by the app -pkg_dependencies="deb1 deb2" +pkg_dependencies="php-soap php5-imap libawl-php php5-xsl" #================================================= # PERSONAL HELPERS diff --git a/scripts/backup b/scripts/backup index 2cef500..717ccbd 100755 --- a/scripts/backup +++ b/scripts/backup @@ -1,30 +1,70 @@ #!/bin/bash -set -eu + +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts +source ../settings/scripts/_common.sh +source /usr/share/yunohost/helpers + +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= + +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + +#================================================= +# LOAD SETTINGS +#================================================= +ynh_print_info "Loading installation settings..." app=$YNH_APP_INSTANCE_NAME -# Source YunoHost helpers -source /usr/share/yunohost/helpers - final_path=$(ynh_app_setting_get $app final_path) +domain=$(ynh_app_setting_get $app domain) statedir=$(ynh_app_setting_get $app statedir) final_logpath=$(ynh_app_setting_get $app final_logpath) -final_nginxconf=$(ynh_app_setting_get $app final_nginxconf) -final_phpconf=$(ynh_app_setting_get $app final_phpconf) -# Backup sources & data -# Note: the last argument is where to save this path, see the restore script. -ynh_backup "$final_path" "sources" +#================================================= +# STANDARD BACKUP STEPS +#================================================= +# BACKUP THE APP MAIN DIR +#================================================= +ynh_print_info "Backing up the main app directory..." + +ynh_backup "$final_path" # Backup statedir -ynh_backup "$statedir" "statedir" +ynh_backup "$statedir" # Backup logs -ynh_backup "$final_logpath" "logs" -ynh_backup "/etc/logrotate.d/$app" "logrotate" +ynh_backup "$final_logpath" -# Copy NGINX configuration -ynh_backup "$final_nginxconf" "nginx.conf" +#================================================= +# BACKUP THE NGINX CONFIGURATION +#================================================= +ynh_print_info "Backing up nginx web server configuration..." -# Copy PHP-FPM configuration -ynh_backup "$final_phpconf" "php-fpm.conf" +ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" + +#================================================= +# BACKUP THE PHP-FPM CONFIGURATION +#================================================= +ynh_print_info "Backing up php-fpm configuration..." + +ynh_backup "/etc/php/7.0/fpm/pool.d/$app.conf" +# BACKUP LOGROTATE +#================================================= +ynh_print_info "Backing up logrotate configuration..." + +ynh_backup "/etc/logrotate.d/$app" + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/install b/scripts/install index 363be05..d1b0937 100755 --- a/scripts/install +++ b/scripts/install @@ -16,172 +16,175 @@ source /usr/share/yunohost/helpers # Exit if an error occurs during the execution of the script ynh_abort_if_errors -# Retrieve arguments -app=$YNH_APP_INSTANCE_NAME +#================================================= +# RETRIEVE ARGUMENTS FROM THE MANIFEST +#================================================= + domain=$YNH_APP_ARG_DOMAIN -path=$YNH_APP_ARG_PATH -# We check variables are not empty -CHECK_VAR () { # Vérifie que la variable n'est pas vide. -# $1 = Variable à vérifier -# $2 = Texte à afficher en cas d'erreur - test -n "$1" || (echo "$2" >&2 && false) -} +path="/Microsoft-Server-ActiveSync" +app=$YNH_APP_INSTANCE_NAME -CHECK_VAR "$app" "app name not set" +#================================================= +# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS +#================================================= +ynh_print_info "Validating installation parameters..." -# Check the path value and correct it (adds / at begining and removes it at the end) -CHECK_PATH () { # Vérifie la présence du / en début de path. Et son absence à la fin. - if [ "${path:0:1}" != "/" ]; then # Si le premier caractère n'est pas un / - path="/$path" # Ajoute un / en début de path - fi - if [ "${path:${#path}-1}" == "/" ] && [ ${#path} -gt 1 ]; then # Si le dernier caractère est un / et que ce n'est pas l$ - path="${path:0:${#path}-1}" # Supprime le dernier caractère - fi -} - -CHECK_PATH; - -# Check domain and path availibility -CHECK_DOMAINPATH () { # Vérifie la disponibilité du path et du domaine. - sudo yunohost app checkurl $domain$path -a $app -} - -CHECK_DOMAINPATH - -# Prereqs -#sudo apt-get install php-soap php5-imap libawl-php php5-xsl -y - -# Install dependencies using Helpers -ynh_package_install_from_equivs ../conf/z-push-deps.control \ -|| ynh_die "Unable to install dependencies" - - -final_path="/var/www/$app" - -CHECK_FINALPATH () { # Vérifie que le dossier de destination n'est pas déjà utilisé. - if [ -e "$final_path" ] - then - echo "This path already contains a folder" >&2 - false - fi -} - -CHECK_FINALPATH +final_path=/var/www/$app +test ! -e "$final_path" || ynh_die "This path already contains a folder" statedir="/home/yunohost.app/$app" - -CHECK_STATEDIRPATH () { # Vérifie que le dossier de destination n'est pas déjà utilisé. - if [ -e "$statedir" ] - then - echo "This path already contains a folder" >&2 - false - fi -} - -CHECK_STATEDIRPATH - - -# Define variables and Save app settings -ynh_app_setting_set "$app" domain "$domain" -ynh_app_setting_set "$app" final_path "$final_path" -ynh_app_setting_set "$app" statedir "$statedir" +test ! -e "$statedir" || ynh_die "This path already contains a folder" final_logpath="/var/log/$app" -ynh_app_setting_set "$app" final_logpath "$final_logpath" -final_nginxconf="/etc/nginx/conf.d/${domain}.d/${app}.conf" -ynh_app_setting_set "$app" final_nginxconf "$final_nginxconf" +# Register (book) web path +ynh_webpath_register $app $domain $path -final_phpconf="/etc/php5/fpm/pool.d/${app}.conf" -ynh_app_setting_set "$app" final_phpconf "$final_phpconf" +#================================================= +# STORE SETTINGS FROM MANIFEST +#================================================= +ynh_print_info "Storing installation settings..." -# Copy files to the right place -sudo mkdir -p $final_path +ynh_app_setting_set $app domain $domain +ynh_app_setting_set $app path $path -# We download the sources and check the md5sum -SFILE=`sudo cat ../sources/source_file`; -sudo wget -nv -i ../sources/source_url -O ${SFILE}.tar.gz -sudo md5sum -c ../sources/source_md5 --status || (echo "Corrupt source" >&2 && false) -sudo tar xvf ${SFILE}.tar.gz -C ../sources/ -sudo cp -a ../sources/$SFILE/. $final_path/ +ynh_app_setting_set $app statedir "$statedir" +ynh_app_setting_set $app final_logpath "$final_logpath" + +#================================================= +# INSTALL DEPENDENCIES +#================================================= +ynh_print_info "Installing dependencies..." + +ynh_install_app_dependencies $pkg_dependencies + +#================================================= +# DOWNLOAD, CHECK AND UNPACK SOURCE +#================================================= +ynh_print_info "Setting up source files..." + +ynh_app_setting_set $app final_path $final_path +# Download, check integrity, uncompress and patch the source from app.src +ynh_setup_source "$final_path" + +#================================================= +# NGINX CONFIGURATION +#================================================= +ynh_print_info "Configuring nginx web server..." + +### `ynh_add_nginx_config` will use the file conf/nginx.conf + +# Create a dedicated nginx config +ynh_add_nginx_config + +#================================================= +# PHP-FPM CONFIGURATION +#================================================= +ynh_print_info "Configuring php-fpm..." + +# Create a dedicated php-fpm config +ynh_add_fpm_config + +#================================================= +# SPECIFIC SETUP +#================================================= +# CREATE STATEDIR AND FINAL_LOGPATH +#================================================= +ynh_print_info "Creating statedir and final_logpath..." + +mkdir -p $statedir +chown -R www-data:www-data $statedir + + +mkdir -p $final_logpath +chown -R www-data:www-data $final_logpath + + +#================================================= +# MODIFY A CONFIG FILE +#================================================= # Configuration -sed -i "s^define('TIMEZONE', .*^define('TIMEZONE', '$(cat /etc/timezone)');^" ../conf/config.php -sed -i "s@LOGTOCHANGE@$final_logpath@g" ../conf/config.php -sed -i "s@LOGTOCHANGE@$final_logpath@g" ../conf/logrotate +ynh_replace_string __TIMEZONE__ $(cat /etc/timezone) ../conf/config.php +ynh_replace_string __FINAL_LOGPATH__ $final_logpath ../conf/config.php # Storage of state_dir in /home/yunohost.app # This contains the sync status in between device and z-push -sed -i "s@STATEDIRTOCHANGE@$statedir@g" ../conf/config.php -sudo mkdir -p $statedir -sudo chown -R www-data:www-data $statedir +ynh_replace_string __STATEDIR__ $statedir ../conf/config.php + # Enable caldav carddav support -if sudo yunohost app list --installed -f baikal | grep -q id ; then +if yunohost app list --installed -f baikal | grep -q id ; then echo "Detected Baikal" caldavdomain=$(ynh_app_setting_get baikal domain) caldavpath=$(ynh_app_setting_get baikal path) caldavpath=${caldavpath%/} # Configuration of backend - sed -i "s@BACKENDTOCHANGE@BackendCombined@g" ../conf/config.php + ynh_replace_string __BACKEND__ BackendCombined ../conf/config.php # Configuration baikal - sed -i "s@BAIKALDOMAIN@$caldavdomain@g" ../conf/backend/config*.php - sed -i "s@BAIKALPATH@$caldavpath@g" ../conf/backend/config*.php - sed -i "s@DOMAINTOCHANGE@$domain@g" ../conf/backend/config-imap.php - sed -i "s@FLAGTOCHANGE@true@g" ../conf/backend/config-imap.php + ynh_replace_string __BAIKALDOMAIN__ $caldavdomain ../conf/backend/config*.php + ynh_replace_string __BAIKALPATH__ $caldavpath ../conf/backend/config*.php + ynh_replace_string __DOMAINTOCHANGE__ $domain ../conf/backend/config-imap.php + ynh_replace_string __FLAGTOCHANGE__ true ../conf/backend/config-imap.php # Copy config - sudo cp ../conf/config.php $final_path/config.php - sudo cp ../conf/backend/config-imap.php $final_path/backend/imap/config.php - sudo cp ../conf/backend/config-carddav.php $final_path/backend/carddav/config.php - sudo cp ../conf/backend/config-caldav.php $final_path/backend/caldav/config.php - sudo cp ../conf/backend/config-combined.php $final_path/backend/combined/config.php + cp ../conf/config.php $final_path/config.php + cp ../conf/backend/config-imap.php $final_path/backend/imap/config.php + cp ../conf/backend/config-carddav.php $final_path/backend/carddav/config.php + cp ../conf/backend/config-caldav.php $final_path/backend/caldav/config.php + cp ../conf/backend/config-combined.php $final_path/backend/combined/config.php else # Configuration of backend - sed -i "s@BACKENDTOCHANGE@BackendIMAP@g" ../conf/config.php + ynh_replace_string __BACKEND__ BackendIMAP ../conf/config.php # Copy config - sudo cp ../conf/config.php $final_path/config.php - sed -i "s@DOMAINTOCHANGE@$domain@g" ../conf/backend/config-imap.php - sed -i "s@FLAGTOCHANGE@false@g" ../conf/backend/config-imap.php - sudo cp ../conf/backend/config-imap.php $final_path/backend/imap/config.php - + cp ../conf/config.php $final_path/config.php + ynh_replace_string __DOMAINTOCHANGE__ $domain ../conf/backend/config-imap.php + ynh_replace_string __FLAGTOCHANGE__ false ../conf/backend/config-imap.php + cp ../conf/backend/config-imap.php $final_path/backend/imap/config.php fi -# Set permissions to z-push directory -sudo chown -R www-data: $final_path - -# Create log directory -sudo mkdir -p $final_logpath -sudo chmod 750 $final_logpath -sudo chown www-data:www-data $final_logpath - -# Activate logrotate -sudo cp ../conf/logrotate /etc/logrotate.d/$app -sudo chmod 644 /etc/logrotate.d/$app -sudo chown root:root /etc/logrotate.d/$app - #Copy XMLElement.php -sudo ln -s /usr/share/awl/inc/XML* /var/www/$app/include/ +ln -s /usr/share/awl/inc/XML* /var/www/$app/include/ -# Modify Nginx configuration file and copy it to Nginx conf directory -sudo sed -i "s@ALIASTOCHANGE@$final_path/@g" ../conf/nginx.conf -sudo sed -i "s@NAMETOCHANGE@$app@g" ../conf/nginx.conf -sudo cp ../conf/nginx.conf $final_nginxconf +#================================================= +# GENERIC FINALIZATION +#================================================= +# SECURE FILES AND DIRECTORIES +#================================================= -# Dedicated php-fpm processes -sudo sed -i "s@NAMETOCHANGE@$app@g" ../conf/php-fpm.conf -sudo cp ../conf/php-fpm.conf $final_phpconf -sudo chown root: $final_phpconf -sudo chmod 644 $final_phpconf +# Set permissions to app files +chown -R www-data: $final_path -# Enable api for client and make app public +#================================================= +# SETUP LOGROTATE +#================================================= +ynh_print_info "Configuring log rotation..." + + +# Use logrotate to manage application logfile(s) +ynh_use_logrotate + +#================================================= +# SETUP SSOWAT +#================================================= +ynh_print_info "Configuring SSOwat..." + +# Make app public ynh_app_setting_set $app skipped_uris "/" -# Reload Nginx and regenerate SSOwat conf -sudo service php5-fpm reload -sudo service nginx reload -sudo yunohost app ssowatconf +#================================================= +# RELOAD NGINX +#================================================= +ynh_print_info "Reloading nginx web server..." + +systemctl reload nginx + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Installation of $app completed" diff --git a/scripts/remove b/scripts/remove index 67bdb6a..8af8d4e 100755 --- a/scripts/remove +++ b/scripts/remove @@ -1,77 +1,78 @@ #!/bin/bash -set -u -# Source app helpers +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source _common.sh source /usr/share/yunohost/helpers -SECURE_REMOVE () { # Suppression de dossier avec vérification des variables - chaine="$1" # L'argument doit être donné entre quotes simple '', pour éviter d'interpréter les variables. - no_var=0 - while (echo "$chaine" | grep -q '\$') # Boucle tant qu'il y a des $ dans la chaine - do - no_var=1 - global_var=$(echo "$chaine" | cut -d '$' -f 2) # Isole la première variable trouvée. - only_var=\$$(expr "$global_var" : '\([A-Za-z0-9_]*\)') # Isole complètement la variable en ajoutant le $ au début et en gardant uniquement le nom de la variable. Se débarrasse$ - real_var=$(eval "echo ${only_var}") # `eval "echo ${var}` permet d'interpréter une variable contenue dans une variable. - if test -z "$real_var" || [ "$real_var" = "/" ]; then - echo "Variable $only_var is empty, suppression of $chaine cancelled." >&2 - return 1 - fi - chaine=$(echo "$chaine" | sed "s@$only_var@$real_var@") # remplace la variable par sa valeur dans la chaine. - done - if [ "$no_var" -eq 1 ] - then - if [ -e "$chaine" ]; then - echo "Delete directory $chaine" - sudo rm -r "$chaine" - fi - return 0 - else - echo "No detected variable." >&2 - return 1 - fi -} +#================================================= +# LOAD SETTINGS +#================================================= +ynh_print_info "Loading installation settings..." -REMOVE_NGINX_CONF () { # Suppression de la configuration nginx - if [ -e "/etc/nginx/conf.d/$domain.d/$app.conf" ]; then # Delete nginx config - echo "Delete nginx config" - sudo rm "/etc/nginx/conf.d/$domain.d/$app.conf" - fi -} - -REMOVE_FPM_CONF () { # Suppression de la configuration du pool php-fpm - if [ -e "/etc/php5/fpm/pool.d/$app.conf" ]; then # Delete fpm config - echo "Delete fpm config" - sudo rm "/etc/php5/fpm/pool.d/$app.conf" - fi -} - -REMOVE_LOGROTATE_CONF () { # Suppression de la configuration de logrotate - if [ -e "/etc/logrotate.d/$app" ]; then - echo "Delete logrotate config" - sudo rm "/etc/logrotate.d/$app" - fi -} - -# We retrieve app parameters app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get "$app" domain) -# Cleaning -SECURE_REMOVE '/var/www/$app' -SECURE_REMOVE '/home/yunohost.app/$app' -SECURE_REMOVE '/var/log/$app' +domain=$(ynh_app_setting_get $app domain) -REMOVE_NGINX_CONF -REMOVE_FPM_CONF -REMOVE_LOGROTATE_CONF +final_path=$(ynh_app_setting_get $app final_path) +statedir=$(ynh_app_setting_get $app statedir) +final_logpath=$(ynh_app_setting_get $app final_logpath) -# Remove app dependencies -if ynh_package_is_installed "z-push-deps"; then - ynh_package_autoremove "z-push-deps" -fi +#================================================= +# REMOVE DEPENDENCIES +#================================================= +ynh_print_info "Removing dependencies" -# Restart of services -sudo service php5-fpm reload -sudo service nginx reload -sudo yunohost app ssowatconf +# Remove metapackage and its dependencies +ynh_remove_app_dependencies + +#================================================= +# REMOVE APP MAIN DIR +#================================================= +ynh_print_info "Removing app main directory" + +# Remove the app directory securely +ynh_secure_remove "$final_path" + +#================================================= +# REMOVE NGINX CONFIGURATION +#================================================= +ynh_print_info "Removing nginx web server configuration" + +# Remove the dedicated nginx config +ynh_remove_nginx_config + +#================================================= +# REMOVE PHP-FPM CONFIGURATION +#================================================= +ynh_print_info "Removing php-fpm configuration" + +# Remove the dedicated php-fpm config +ynh_remove_fpm_config + +#================================================= +# REMOVE LOGROTATE CONFIGURATION +#================================================= +ynh_print_info "Removing logrotate configuration" + +# Remove the app-specific logrotate config +ynh_remove_logrotate + +#================================================= +# SPECIFIC REMOVE +#================================================= +# REMOVE STATEDIR AND FINAL_LOGPATH +#================================================= + +ynh_secure_remove "$statedir" +ynh_secure_remove "$final_logpath" + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index 2dd9d68..8ed1da2 100755 --- a/scripts/restore +++ b/scripts/restore @@ -14,65 +14,90 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { - #### Remove this function if there's nothing to clean before calling the remove script. - true -} # Exit if an error occurs during the execution of the script ynh_abort_if_errors + +#================================================= +# LOAD SETTINGS +#================================================= +ynh_print_info "Loading settings..." + app=$YNH_APP_INSTANCE_NAME -# Retrieve old app settings -path=$(ynh_app_setting_get $app path) domain=$(ynh_app_setting_get $app domain) +path=$(ynh_app_setting_get $app path) final_path=$(ynh_app_setting_get $app final_path) statedir=$(ynh_app_setting_get $app statedir) final_logpath=$(ynh_app_setting_get $app final_logpath) -final_nginxconf=$(ynh_app_setting_get $app final_nginxconf) -final_phpconf=$(ynh_app_setting_get $app final_phpconf) -# Prereqs -sudo apt-get update -y -sudo apt-get install php-soap php5-imap libawl-php php5-xsl -y +#================================================= +# CHECK IF THE APP CAN BE RESTORED +#================================================= +ynh_print_info "Validating restoration parameters..." -# Install dependencies using Helpers -#ynh_package_install_from_equivs ../conf/z-push-deps.control \ -#|| ynh_die "Unable to install dependencies" +ynh_webpath_available $domain $path \ + || ynh_die "Path not available: ${domain}${path}" +test ! -d $final_path \ + || ynh_die "There is already a directory: $final_path " -# Restore sources, data and permissions -sudo mkdir -p $final_path -sudo cp -a ./sources/. $final_path/ -sudo chown -R www-data: $final_path +#================================================= +# STANDARD RESTORATION STEPS +#================================================= +# RESTORE THE NGINX CONFIGURATION +#================================================= + +ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" + +#================================================= +# RESTORE THE APP MAIN DIR +#================================================= +ynh_print_info "Restoring the app main directory..." + +ynh_restore_file "$final_path" +chown -R www-data: $final_path # Restore statedir -sudo mkdir -p $statedir -sudo cp -a ./statedir/. $statedir/ -sudo chown -R www-data:www-data $statedir +ynh_restore_file "$statedir" +chown -R www-data:www-data $statedir # Restore logs, data & permissions -sudo mkdir -p $final_logpath -sudo cp -a ./logs/. $final_logpath/ -sudo chown -R www-data:www-data $final_logpath +ynh_restore_file "$final_logpath" +chown -R www-data:www-data $final_logpath -# Restore logrotate -sudo cp -a ./logrotate /etc/logrotate.d/$app -sudo chmod 644 /etc/logrotate.d/$app -sudo chown root:root /etc/logrotate.d/$app +#================================================= +# RESTORE THE PHP-FPM CONFIGURATION +#================================================= -# Restore NGINX configuration -sudo cp -a ./nginx.conf $final_nginxconf +ynh_restore_file "/etc/php/7.0/fpm/pool.d/$app.conf" -# Restore PHP-FPM configuration -sudo cp -a ./php-fpm.conf $final_phpconf -sudo chown root: $final_phpconf -sudo chmod 644 $final_phpconf +#================================================= +# SPECIFIC RESTORATION +#================================================= +# REINSTALL DEPENDENCIES +#================================================= +ynh_print_info "Reinstalling dependencies..." -# Make app public -ynh_app_setting_set $app skipped_uris "/" +# Define and install dependencies +ynh_install_app_dependencies $pkg_dependencies +#================================================= +# RESTORE THE LOGROTATE CONFIGURATION +#================================================= -# Restart webserver -sudo service nginx reload -sudo service php5-fpm reload -sudo yunohost app ssowatconf +ynh_restore_file "/etc/logrotate.d/$app" +#================================================= +# GENERIC FINALIZATION +#================================================= +# RELOAD NGINX AND PHP-FPM +#================================================= +ynh_print_info "Reloading nginx web server and php-fpm..." + +systemctl reload php7.0-fpm +systemctl reload nginx + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Restoration completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index cca630d..995cdc5 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -9,23 +9,37 @@ source _common.sh source /usr/share/yunohost/helpers -# Retrieve arguments +#================================================= +# LOAD SETTINGS +#================================================= +ynh_print_info "Loading installation settings..." + app=$YNH_APP_INSTANCE_NAME + domain=$(ynh_app_setting_get $app domain) path=$(ynh_app_setting_get $app path) final_path=$(ynh_app_setting_get $app final_path) statedir=$(ynh_app_setting_get $app statedir) final_logpath=$(ynh_app_setting_get $app final_logpath) -final_nginxconf=$(ynh_app_setting_get $app final_nginxconf) -final_phpconf=$(ynh_app_setting_get $app final_phpconf) -# We make the app retro-compatible with previous versions -if [ -z "$final_path" ]; -then - final_path="/var/www/$app" - ynh_app_setting_set "$app" final_path "$final_path" -else - echo "${final_path} exists, we don't create it." +#================================================= +# ENSURE DOWNWARD COMPATIBILITY +#================================================= +ynh_print_info "Ensuring downward compatibility..." + +# Fix is_public as a boolean value +if [ "$is_public" = "Yes" ]; then + ynh_app_setting_set $app is_public 1 + is_public=1 +elif [ "$is_public" = "No" ]; then + ynh_app_setting_set $app is_public 0 + is_public=0 +fi + +# If final_path doesn't exist, create it +if [ -z $final_path ]; then + final_path=/var/www/$app + ynh_app_setting_set $app final_path $final_path fi #================================================= @@ -58,127 +72,144 @@ else echo "${final_logpath} exists, we don't create it." fi -if [ -z "$final_nginxconf" ]; -then - final_nginxconf="/etc/nginx/conf.d/${domain}.d/${app}.conf" - ynh_app_setting_set "$app" final_nginxconf "$final_nginxconf" -else - echo "${final_nginxconf} exists, we don't create it." -fi +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= +ynh_print_info "Backing up the app before upgrading (may take a while)..." -if [ -z "$final_phpconf" ]; -then - final_phpconf=/etc/php5/fpm/pool.d/$app.conf - ynh_app_setting_set "$app" final_phpconf "$final_phpconf" -else - echo "${final_phpconf} exists, we don't create it." -fi +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + # restore it if the upgrade fails + ynh_restore_upgradebackup +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors -# Prereqs -#sudo apt-get install php-soap php5-imap libawl-php php5-xsl -# Install dependencies using Helpers -ynh_package_install_from_equivs ../conf/z-push-deps.control \ -|| ynh_die "Unable to install dependencies" +#================================================= +# STANDARD UPGRADE STEPS +#================================================= +# DOWNLOAD, CHECK AND UNPACK SOURCE +#================================================= +ynh_print_info "Upgrading source files..." +# Download, check integrity, uncompress and patch the source from app.src +ynh_setup_source "$final_path" -# Cleaning -ynh_secure_remove "$final_path" -ynh_secure_remove "$final_logpath" -sudo rm -f $final_nginxconf -sudo rm -f $final_phpconf -sudo rm -f /etc/logrotate.d/$app +#================================================= +# NGINX CONFIGURATION +#================================================= +ynh_print_info "Upgrading nginx web server configuration..." -# Copy files to the right place -sudo mkdir -p $final_path +# Create a dedicated nginx config +ynh_add_nginx_config -# We download the sources and check the md5sum -SFILE=`sudo cat ../sources/source_file`; -sudo wget -nv -i ../sources/source_url -O ${SFILE}.tar.gz -sudo md5sum -c ../sources/source_md5 --status || (echo "Corrupt source" >&2 && false) -sudo tar xvf ${SFILE}.tar.gz -C ../sources/ -sudo cp -a ../sources/$SFILE/. $final_path/ +#================================================= +# UPGRADE DEPENDENCIES +#================================================= +ynh_print_info "Upgrading dependencies..." + +ynh_install_app_dependencies $pkg_dependencies + +#================================================= +# PHP-FPM CONFIGURATION +#================================================= +ynh_print_info "Upgrading php-fpm configuration..." + +# Create a dedicated php-fpm config +ynh_add_fpm_config + +#================================================= +# SPECIFIC UPGRADE +#================================================= +# MODIFY A CONFIG FILE +#================================================= # Configuration -sed -i "s^define('TIMEZONE', .*^define('TIMEZONE', '$(cat /etc/timezone)');^" ../conf/config.php -sed -i "s@LOGTOCHANGE@$final_logpath@g" ../conf/config.php -sed -i "s@LOGTOCHANGE@$final_logpath@g" ../conf/logrotate +ynh_replace_string __TIMEZONE__ $(cat /etc/timezone) ../conf/config.php +ynh_replace_string __FINAL_LOGPATH__ $final_logpath ../conf/config.php # Storage of state_dir in /home/yunohost.app # This contains the sync status in between device and z-push -sed -i "s@STATEDIRTOCHANGE@$statedir@g" ../conf/config.php -sudo mkdir -p $statedir -sudo chown -R www-data:www-data $statedir -# Note : there is a "fixstates actions done after the sources have been installed and configured +ynh_replace_string __STATEDIR__ $statedir ../conf/config.php # Enable caldav carddav support -if sudo yunohost app list --installed -f baikal | grep -q id ; then - echo "Detected Baikal" - caldavdomain=$(ynh_app_setting_get baikal domain) - caldavpath=$(ynh_app_setting_get baikal path) - caldavpath=${caldavpath%/} +if yunohost app list --installed -f baikal | grep -q id ; then + echo "Detected Baikal" + caldavdomain=$(ynh_app_setting_get baikal domain) + caldavpath=$(ynh_app_setting_get baikal path) + caldavpath=${caldavpath%/} - # Configuration of backend - sed -i "s@BACKENDTOCHANGE@BackendCombined@g" ../conf/config.php + # Configuration of backend + ynh_replace_string __BACKEND__ BackendCombined ../conf/config.php - # Configuration baikal - sed -i "s@BAIKALDOMAIN@$caldavdomain@g" ../conf/backend/config*.php - sed -i "s@BAIKALPATH@$caldavpath@g" ../conf/backend/config*.php - sed -i "s@DOMAINTOCHANGE@$domain@g" ../conf/backend/config-imap.php - sed -i "s@FLAGTOCHANGE@true@g" ../conf/backend/config-imap.php + # Configuration baikal + ynh_replace_string __BAIKALDOMAIN__ $caldavdomain ../conf/backend/config*.php + ynh_replace_string __BAIKALPATH__ $caldavpath ../conf/backend/config*.php + ynh_replace_string __DOMAINTOCHANGE__ $domain ../conf/backend/config-imap.php + ynh_replace_string __FLAGTOCHANGE__ true ../conf/backend/config-imap.php - # Copy config - sudo cp ../conf/config.php $final_path/config.php - sudo cp ../conf/backend/config-imap.php $final_path/backend/imap/config.php - sudo cp ../conf/backend/config-carddav.php $final_path/backend/carddav/config.php - sudo cp ../conf/backend/config-caldav.php $final_path/backend/caldav/config.php - sudo cp ../conf/backend/config-combined.php $final_path/backend/combined/config.php + # Copy config + cp ../conf/config.php $final_path/config.php + cp ../conf/backend/config-imap.php $final_path/backend/imap/config.php + cp ../conf/backend/config-carddav.php $final_path/backend/carddav/config.php + cp ../conf/backend/config-caldav.php $final_path/backend/caldav/config.php + cp ../conf/backend/config-combined.php $final_path/backend/combined/config.php else - # Configuration of backend - sed -i "s@BACKENDTOCHANGE@BackendIMAP@g" ../conf/config.php - - # Copy config - sudo cp ../conf/config.php $final_path/config.php - sed -i "s@DOMAINTOCHANGE@$domain@g" ../conf/backend/config-imap.php - sed -i "s@FLAGTOCHANGE@false@g" ../conf/backend/config-imap.php - sudo cp ../conf/backend/config-imap.php $final_path/backend/imap/config.php + # Configuration of backend + ynh_replace_string __BACKEND__ BackendIMAP ../conf/config.php + # Copy config + cp ../conf/config.php $final_path/config.php + ynh_replace_string __DOMAINTOCHANGE__ $domain ../conf/backend/config-imap.php + ynh_replace_string __FLAGTOCHANGE__ false ../conf/backend/config-imap.php + cp ../conf/backend/config-imap.php $final_path/backend/imap/config.php fi -# Set permissions to z-push directory -sudo chown -R www-data: $final_path - -# Create log directory -sudo mkdir -p $final_logpath -sudo chmod 750 $final_logpath -sudo chown www-data:www-data $final_logpath - -# Activate logrotate -sudo cp ../conf/logrotate /etc/logrotate.d/$app -sudo chmod 644 /etc/logrotate.d/$app -sudo chown root:root /etc/logrotate.d/$app - -#Copy XMLElement.php -sudo ln -s /usr/share/awl/inc/XML* /var/www/z-push/include/ - -# Modify Nginx configuration file and copy it to Nginx conf directory -sudo sed -i "s@ALIASTOCHANGE@$final_path/@g" ../conf/nginx.conf -sudo sed -i "s@NAMETOCHANGE@$app@g" ../conf/nginx.conf -sudo cp ../conf/nginx.conf $final_nginxconf - -# Dedicated php-fpm processes -sudo sed -i "s@NAMETOCHANGE@$app@g" ../conf/php-fpm.conf -sudo cp ../conf/php-fpm.conf $final_phpconf -sudo chown root: $final_phpconf -sudo chmod 644 $final_phpconf - # Fixstates to avoid full resync of devices after version upgrades -sudo $final_path/z-push-admin.php -a fixstates +$final_path/z-push-admin.php -a fixstates + +#================================================= +# SETUP LOGROTATE +#================================================= +ynh_print_info "Upgrading logrotate configuration..." + +# Use logrotate to manage app-specific logfile(s) +ynh_use_logrotate --non-append + +#================================================= +# GENERIC FINALIZATION +#================================================= +# SECURE FILES AND DIRECTORIES +#================================================= + +# Set permissions on app files +chown -R www-data: $final_path + + + + + + + + +#================================================= +# SETUP SSOWAT +#================================================= +ynh_print_info "Upgrading SSOwat configuration..." -# Enable api for client and make the app public ynh_app_setting_set $app skipped_uris "/" -# Restart of services -sudo service php5-fpm reload -sudo service nginx reload -sudo yunohost app ssowatconf +#================================================= +# RELOAD NGINX +#================================================= +ynh_print_info "Reloading nginx web server..." + +systemctl reload nginx + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Upgrade of $app completed" diff --git a/sources/source_file b/sources/source_file deleted file mode 100644 index fd8699c..0000000 --- a/sources/source_file +++ /dev/null @@ -1 +0,0 @@ -z-push-2.3.6 diff --git a/sources/source_md5 b/sources/source_md5 deleted file mode 100644 index 3e223bb..0000000 --- a/sources/source_md5 +++ /dev/null @@ -1 +0,0 @@ -36673351affcc83d1e98de8f8d606feb z-push-2.3.6.tar.gz diff --git a/sources/source_url b/sources/source_url deleted file mode 100644 index 9ff56e2..0000000 --- a/sources/source_url +++ /dev/null @@ -1 +0,0 @@ -http://download.z-push.org/final/2.3/z-push-2.3.6.tar.gz From 5590e28efb66bb4b952e8a01bfd6523d6c75bede Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 3 Apr 2019 22:31:26 +0200 Subject: [PATCH 03/16] Upgrade to 2.4.5 (#3) * Switch source to github.tar.gz * Fix $final_path creation * upgrade to 2.4.5 --- README.md | 4 ++-- conf/app.src | 4 ++-- manifest.json | 2 +- scripts/install | 6 +++++- scripts/upgrade | 5 ++++- 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index c0d4598..8c4bcd4 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to ## Overview Z-Push is an Exchange ActiveSync fronted written in php which lets you synchronize emails (imap/smtp backend) and calendar/contacts (carddav and caldav backend) -**Shipped version:** 2.3.6 +**Shipped version:** 2.4.5 * * * ### Known bug : @@ -24,7 +24,7 @@ Z-Push is an Exchange ActiveSync fronted written in php which lets you synchroni - [x] z-push is now configured to use smtp to send emails instead of php_mail() function. This let us have emails signed by dkim for example. - [x] The current imap backend configuration seems able to handle email addresses different from login (for example login : john and email john.doe@domain.tld instead of john@domain.tld) - Further testing required ! - [x] The sources are based on http://download.z-push.org/final/ -- [x] Use of version 2.3.6 final +- [x] Use of version 2.4.5 final ## Documentation diff --git a/conf/app.src b/conf/app.src index 506e928..6265cd3 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=http://download.z-push.org/final/2.3/z-push-2.3.6.tar.gz -SOURCE_SUM=9f86e4f6d822558bffdf05bebce4f1157ed7d8784b52d488935ef6d02efc27d7 +SOURCE_URL=https://github.com/Z-Hub/Z-Push/archive/3b937fb5c79068553198347ffad1f39f2e9d1b51.tar.gz +SOURCE_SUM=d4d341946a6a2d24c4f9ceebeef8d0c3724c09ed5ad8c905fd1b4c44b25fe6fa SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/manifest.json b/manifest.json index fc797b2..e388fed 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Z-Push is an Exchange ActiveSync fronted written in php which lets you synchronize emails (imap/smtp backend) and calendar/contacts (carddav and caldav backend)", "fr": "Z-Push est un fronted Exchange ActiveSync écrit en php qui permet de synchroniser vos email (backend imap/smtp) et vos contacts/calendrier (backend carddav et caldav)" }, - "version": "2.3.6~ynh2", + "version": "2.4.5~ynh1", "url": "https://z-push.org", "license": "AGPL-3.0-or-later", "maintainer": { diff --git a/scripts/install b/scripts/install index d1b0937..00e822c 100755 --- a/scripts/install +++ b/scripts/install @@ -66,7 +66,11 @@ ynh_print_info "Setting up source files..." ynh_app_setting_set $app final_path $final_path # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source "$final_path" +mkdir "$final_path" +mkdir "$final_path/tmp" +ynh_setup_source "$final_path/tmp" +cp -a "$final_path/tmp/src/." "$final_path/." +rm -r "$final_path/tmp" #================================================= # NGINX CONFIGURATION diff --git a/scripts/upgrade b/scripts/upgrade index 995cdc5..f7abaca 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -95,7 +95,10 @@ ynh_abort_if_errors ynh_print_info "Upgrading source files..." # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source "$final_path" +mkdir "$final_path/tmp" +ynh_setup_source "$final_path/tmp" +cp -a "$final_path/tmp/src/." "$final_path/." +rm -r "$final_path/tmp" #================================================= # NGINX CONFIGURATION From 5cf542959060e4fd5f8d9dba94ab84835b0e861a Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 6 Apr 2019 01:18:13 +0200 Subject: [PATCH 04/16] Implement Autodiscover (#4) * Implement autodiscover --- conf/backend/config-autodiscover.php | 110 +++++++++++++++++++++++++++ conf/backend/config-carddav.php | 2 +- conf/backend/config-combined.php | 30 +++++--- conf/config.php | 2 +- conf/nginx.conf | 24 ++++++ scripts/_common.sh | 2 +- scripts/install | 19 +++-- scripts/upgrade | 24 +++--- 8 files changed, 183 insertions(+), 30 deletions(-) create mode 100644 conf/backend/config-autodiscover.php diff --git a/conf/backend/config-autodiscover.php b/conf/backend/config-autodiscover.php new file mode 100644 index 0000000..f77939f --- /dev/null +++ b/conf/backend/config-autodiscover.php @@ -0,0 +1,110 @@ +. +* +* Consult LICENSE file for details +************************************************/ + +/********************************************************************************** + * Default settings + */ + + // Replace zpush.example.com with your z-push's host name and uncomment the line below. + // define('ZPUSH_HOST', 'zpush.example.com'); + + // Defines the default time zone, change e.g. to "Europe/London" if necessary + define('TIMEZONE', '__TIMEZONE__'); + + // Defines the base path on the server + define('BASE_PATH', dirname($_SERVER['SCRIPT_FILENAME']). '/'); + + /* + * Whether to use the complete email address as a login name + * (e.g. user@company.com) or the username only (user). + * Possible values: + * false - use the username only (default). + * true - use the complete email address. + */ + define('USE_FULLEMAIL_FOR_LOGIN', false); + + /* + * AutoDiscover requires the username to match either the email address + * or the local part of the email address. + * This is not always possible as the username might have a different + * schema than email address. Configure this parameter to match your + * username settings. + * @see https://wiki.z-hub.io/display/ZP/Configuring+Z-Push+Autodiscover#ConfiguringZ-PushAutodiscover-Configuration + * @see https://jira.z-hub.io/browse/ZP-1209 + * + * Possible values: + * AUTODISCOVER_LOGIN_EMAIL - uses the email address as provided when setting up the account + * AUTODISCOVER_LOGIN_NO_DOT - removes the '.' from email address: + * email: first.last@domain.com -> resulting username: firstlast + * AUTODISCOVER_LOGIN_F_NO_DOT_LAST - cuts the first part before '.' after the first letter and + * removes the '.' from email address: + * email: first.last@domain.com -> resulting username: flast + * AUTODISCOVER_LOGIN_F_DOT_LAST - cuts the part before '.' after the first letter and + * leaves the part after '.' as is: + * email: first.last@domain.com -> resulting username: f.last + */ + define('AUTODISCOVER_LOGIN_TYPE', AUTODISCOVER_LOGIN_EMAIL); + +/********************************************************************************** + * Logging settings + * Possible LOGLEVEL and LOGUSERLEVEL values are: + * LOGLEVEL_OFF - no logging + * LOGLEVEL_FATAL - log only critical errors + * LOGLEVEL_ERROR - logs events which might require corrective actions + * LOGLEVEL_WARN - might lead to an error or require corrective actions in the future + * LOGLEVEL_INFO - usually completed actions + * LOGLEVEL_DEBUG - debugging information, typically only meaningful to developers + * LOGLEVEL_WBXML - also prints the WBXML sent to/from the device + * LOGLEVEL_DEVICEID - also prints the device id for every log entry + * LOGLEVEL_WBXMLSTACK - also prints the contents of WBXML stack + * + * The verbosity increases from top to bottom. More verbose levels include less verbose + * ones, e.g. setting to LOGLEVEL_DEBUG will also output LOGLEVEL_FATAL, LOGLEVEL_ERROR, + * LOGLEVEL_WARN and LOGLEVEL_INFO level entries. + */ + + define('LOGBACKEND', 'filelog'); + + define('LOGFILEDIR', '__FINAL_LOGPATH__/'); + define('LOGFILE', LOGFILEDIR . 'autodiscover.log'); + define('LOGERRORFILE', LOGFILEDIR . 'autodiscover-error.log'); + define('LOGLEVEL', LOGLEVEL_INFO); + define('LOGUSERLEVEL', LOGLEVEL); + $specialLogUsers = array(); + + // Syslog settings + // false will log to local syslog, otherwise put the remote syslog IP here + define('LOG_SYSLOG_HOST', false); + // Syslog port + define('LOG_SYSLOG_PORT', 514); + // Program showed in the syslog. Useful if you have more than one instance login to the same syslog + define('LOG_SYSLOG_PROGRAM', 'z-push-autodiscover'); + // Syslog facility - use LOG_USER when running on Windows + define('LOG_SYSLOG_FACILITY', LOG_LOCAL0); +/********************************************************************************** + * Backend settings + */ + // the backend data provider + define('BACKEND_PROVIDER', '__BACKEND__'); diff --git a/conf/backend/config-carddav.php b/conf/backend/config-carddav.php index 95d1103..b291d2c 100644 --- a/conf/backend/config-carddav.php +++ b/conf/backend/config-carddav.php @@ -53,7 +53,7 @@ define('CARDDAV_PATH', '__BAIKALPATH__/card.php/addressbooks/%u/'); // %u: replaced with the username // %d: replaced with the domain // Add the trailing / -define('CARDDAV_DEFAULT_PATH', 'BAIKALPATH/card.php/addressbooks/%u/default'); +define('CARDDAV_DEFAULT_PATH', '__BAIKALPATH__/card.php/addressbooks/%u/default'); // Server path to the GAL addressbook. This addressbook is readonly and searchable by the user, but it will NOT be synced. // If you don't want GAL, comment it diff --git a/conf/backend/config-combined.php b/conf/backend/config-combined.php index 0efb4c0..24a3de7 100644 --- a/conf/backend/config-combined.php +++ b/conf/backend/config-combined.php @@ -47,10 +47,22 @@ class BackendCombinedConfig { 'i' => array( 'name' => 'BackendIMAP', ), + 'z' => array( + 'name' => 'BackendKopano', + ), + 'm' => array( + 'name' => 'BackendMaildir', + ), + 'v' => array( + 'name' => 'BackendVCardDir', + ), + 'l' => array( + 'name' => 'BackendLDAP', + ), 'd' => array( 'name' => 'BackendCardDAV', ), - 'l' => array( + 'c' => array( 'name' => 'BackendCalDAV', ), ), @@ -63,18 +75,18 @@ class BackendCombinedConfig { SYNC_FOLDER_TYPE_WASTEBASKET => 'i', SYNC_FOLDER_TYPE_SENTMAIL => 'i', SYNC_FOLDER_TYPE_OUTBOX => 'i', - SYNC_FOLDER_TYPE_TASK => 'l', - SYNC_FOLDER_TYPE_APPOINTMENT => 'l', + SYNC_FOLDER_TYPE_TASK => 'c', + SYNC_FOLDER_TYPE_APPOINTMENT => 'c', SYNC_FOLDER_TYPE_CONTACT => 'd', - SYNC_FOLDER_TYPE_NOTE => 'l', - SYNC_FOLDER_TYPE_JOURNAL => 'l', + SYNC_FOLDER_TYPE_NOTE => 'c', + SYNC_FOLDER_TYPE_JOURNAL => 'c', SYNC_FOLDER_TYPE_OTHER => 'i', SYNC_FOLDER_TYPE_USER_MAIL => 'i', - SYNC_FOLDER_TYPE_USER_APPOINTMENT => 'l', + SYNC_FOLDER_TYPE_USER_APPOINTMENT => 'c', SYNC_FOLDER_TYPE_USER_CONTACT => 'd', - SYNC_FOLDER_TYPE_USER_TASK => 'l', - SYNC_FOLDER_TYPE_USER_JOURNAL => 'l', - SYNC_FOLDER_TYPE_USER_NOTE => 'l', + SYNC_FOLDER_TYPE_USER_TASK => 'c', + SYNC_FOLDER_TYPE_USER_JOURNAL => 'c', + SYNC_FOLDER_TYPE_USER_NOTE => 'c', SYNC_FOLDER_TYPE_UNKNOWN => 'i', ), //creating a new folder in the root folder should create a folder in one backend diff --git a/conf/config.php b/conf/config.php index c0877a0..76a5e6f 100644 --- a/conf/config.php +++ b/conf/config.php @@ -50,7 +50,7 @@ * false - use the username only. * true - string the mobile sends as username, e.g. full email address (default). */ - define('USE_FULLEMAIL_FOR_LOGIN', true); + define('USE_FULLEMAIL_FOR_LOGIN', false); /********************************************************************************** * StateMachine setting diff --git a/conf/nginx.conf b/conf/nginx.conf index 35df35c..d7d078b 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -21,3 +21,27 @@ location /Microsoft-Server-ActiveSync { # Include SSOWAT user panel. include conf.d/yunohost_panel.conf.inc; } + +location /AutoDiscover/AutoDiscover.xml { + alias __FINALPATH__/autodiscover/autodiscover.php; + fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock; + include fastcgi_params; + fastcgi_param HTTPS on; + fastcgi_param SCRIPT_FILENAME $request_filename; +} + +location /Autodiscover/Autodiscover.xml { + alias __FINALPATH__/autodiscover/autodiscover.php; + fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock; + include fastcgi_params; + fastcgi_param HTTPS on; + fastcgi_param SCRIPT_FILENAME $request_filename; +} + +location /autodiscover/autodiscover.xml { + alias __FINALPATH__/autodiscover/autodiscover.php; + fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock; + include fastcgi_params; + fastcgi_param HTTPS on; + fastcgi_param SCRIPT_FILENAME $request_filename; +} \ No newline at end of file diff --git a/scripts/_common.sh b/scripts/_common.sh index b4c32ea..1228e40 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,7 +5,7 @@ #================================================= # dependencies used by the app -pkg_dependencies="php-soap php5-imap libawl-php php5-xsl" +pkg_dependencies="php-soap php-imap libawl-php php-xsl php-curl libawl-php php-xml php-ldap php-cli php-mbstring php-memcached" #================================================= # PERSONAL HELPERS diff --git a/scripts/install b/scripts/install index 00e822c..ee244ab 100755 --- a/scripts/install +++ b/scripts/install @@ -100,24 +100,23 @@ ynh_print_info "Creating statedir and final_logpath..." mkdir -p $statedir chown -R www-data:www-data $statedir - mkdir -p $final_logpath chown -R www-data:www-data $final_logpath - #================================================= # MODIFY A CONFIG FILE #================================================= # Configuration ynh_replace_string __TIMEZONE__ $(cat /etc/timezone) ../conf/config.php +ynh_replace_string __TIMEZONE__ $(cat /etc/timezone) ../conf/backend/config-autodiscover.php ynh_replace_string __FINAL_LOGPATH__ $final_logpath ../conf/config.php +ynh_replace_string __FINAL_LOGPATH__ $final_logpath ../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 __STATEDIR__ $statedir ../conf/config.php - # Enable caldav carddav support if yunohost app list --installed -f baikal | grep -q id ; then echo "Detected Baikal" @@ -127,10 +126,13 @@ if yunohost app list --installed -f baikal | grep -q id ; then # Configuration of backend ynh_replace_string __BACKEND__ BackendCombined ../conf/config.php + ynh_replace_string __BACKEND__ BackendCombined ../conf/backend/config-autodiscover.php # Configuration baikal - ynh_replace_string __BAIKALDOMAIN__ $caldavdomain ../conf/backend/config*.php - ynh_replace_string __BAIKALPATH__ $caldavpath ../conf/backend/config*.php + ynh_replace_string __BAIKALDOMAIN__ $caldavdomain ../conf/backend/config-caldav.php + ynh_replace_string __BAIKALDOMAIN__ $caldavdomain ../conf/backend/config-carddav.php + ynh_replace_string __BAIKALPATH__ $caldavpath ../conf/backend/config-caldav.php + ynh_replace_string __BAIKALPATH__ $caldavpath ../conf/backend/config-carddav.php ynh_replace_string __DOMAINTOCHANGE__ $domain ../conf/backend/config-imap.php ynh_replace_string __FLAGTOCHANGE__ true ../conf/backend/config-imap.php @@ -140,15 +142,18 @@ if yunohost app list --installed -f baikal | grep -q id ; then cp ../conf/backend/config-carddav.php $final_path/backend/carddav/config.php cp ../conf/backend/config-caldav.php $final_path/backend/caldav/config.php cp ../conf/backend/config-combined.php $final_path/backend/combined/config.php + cp ../conf/backend/config-autodiscover.php $final_path/autodiscover/config.php else # Configuration of backend ynh_replace_string __BACKEND__ BackendIMAP ../conf/config.php + ynh_replace_string __BACKEND__ BackendIMAP ../conf/backend/config-autodiscover.php # Copy config cp ../conf/config.php $final_path/config.php ynh_replace_string __DOMAINTOCHANGE__ $domain ../conf/backend/config-imap.php ynh_replace_string __FLAGTOCHANGE__ false ../conf/backend/config-imap.php cp ../conf/backend/config-imap.php $final_path/backend/imap/config.php + cp ../conf/backend/config-autodiscover.php $final_path/autodiscover/config.php fi #Copy XMLElement.php @@ -168,7 +173,6 @@ chown -R www-data: $final_path #================================================= ynh_print_info "Configuring log rotation..." - # Use logrotate to manage application logfile(s) ynh_use_logrotate @@ -178,7 +182,8 @@ ynh_use_logrotate ynh_print_info "Configuring SSOwat..." # Make app public -ynh_app_setting_set $app skipped_uris "/" +ynh_app_setting_set $app unprotected_uris "/" +ynh_app_setting_set $app skipped_regex "^[^/]*/[Aa]uto[Dd]iscover.*" #================================================= # RELOAD NGINX diff --git a/scripts/upgrade b/scripts/upgrade index f7abaca..83555d7 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -86,7 +86,6 @@ ynh_clean_setup () { # Exit if an error occurs during the execution of the script ynh_abort_if_errors - #================================================= # STANDARD UPGRADE STEPS #================================================= @@ -131,7 +130,9 @@ ynh_add_fpm_config # Configuration ynh_replace_string __TIMEZONE__ $(cat /etc/timezone) ../conf/config.php +ynh_replace_string __TIMEZONE__ $(cat /etc/timezone) ../conf/backend/config-autodiscover.php ynh_replace_string __FINAL_LOGPATH__ $final_logpath ../conf/config.php +ynh_replace_string __FINAL_LOGPATH__ $final_logpath ../conf/backend/config-autodiscover.php # Storage of state_dir in /home/yunohost.app # This contains the sync status in between device and z-push @@ -146,10 +147,13 @@ if yunohost app list --installed -f baikal | grep -q id ; then # Configuration of backend ynh_replace_string __BACKEND__ BackendCombined ../conf/config.php + ynh_replace_string __BACKEND__ BackendCombined ../conf/backend/config-autodiscover.php # Configuration baikal - ynh_replace_string __BAIKALDOMAIN__ $caldavdomain ../conf/backend/config*.php - ynh_replace_string __BAIKALPATH__ $caldavpath ../conf/backend/config*.php + ynh_replace_string __BAIKALDOMAIN__ $caldavdomain ../conf/backend/config-caldav.php + ynh_replace_string __BAIKALDOMAIN__ $caldavdomain ../conf/backend/config-carddav.php + ynh_replace_string __BAIKALPATH__ $caldavpath ../conf/backend/config-caldav.php + ynh_replace_string __BAIKALPATH__ $caldavpath ../conf/backend/config-carddav.php ynh_replace_string __DOMAINTOCHANGE__ $domain ../conf/backend/config-imap.php ynh_replace_string __FLAGTOCHANGE__ true ../conf/backend/config-imap.php @@ -159,15 +163,18 @@ if yunohost app list --installed -f baikal | grep -q id ; then cp ../conf/backend/config-carddav.php $final_path/backend/carddav/config.php cp ../conf/backend/config-caldav.php $final_path/backend/caldav/config.php cp ../conf/backend/config-combined.php $final_path/backend/combined/config.php + cp ../conf/backend/config-autodiscover.php $final_path/autodiscover/config.php else # Configuration of backend ynh_replace_string __BACKEND__ BackendIMAP ../conf/config.php + ynh_replace_string __BACKEND__ BackendIMAP ../conf/backend/config-autodiscover.php # Copy config cp ../conf/config.php $final_path/config.php ynh_replace_string __DOMAINTOCHANGE__ $domain ../conf/backend/config-imap.php ynh_replace_string __FLAGTOCHANGE__ false ../conf/backend/config-imap.php cp ../conf/backend/config-imap.php $final_path/backend/imap/config.php + cp ../conf/backend/config-autodiscover.php $final_path/autodiscover/config.php fi # Fixstates to avoid full resync of devices after version upgrades @@ -190,19 +197,14 @@ ynh_use_logrotate --non-append # Set permissions on app files chown -R www-data: $final_path - - - - - - - #================================================= # SETUP SSOWAT #================================================= ynh_print_info "Upgrading SSOwat configuration..." -ynh_app_setting_set $app skipped_uris "/" +# Make app public +ynh_app_setting_set $app unprotected_uris "/" +ynh_app_setting_set $app skipped_regex "^[^/]*/[Aa]uto[Dd]iscover.*" #================================================= # RELOAD NGINX From 98549674bfea5296a48aff0ee192d267a928860d Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 8 Apr 2019 21:45:53 +0200 Subject: [PATCH 05/16] Implement Nextcloud configuration (#5) * Add nextcloud * Reorder config file * switch variable names * fix variables * Fix nextcloud config --- conf/backend/config-caldav.php | 6 +-- conf/backend/config-carddav.php | 6 +-- conf/backend/config-imap.php | 2 +- scripts/install | 68 ++++++++++++++++++++++++--------- 4 files changed, 58 insertions(+), 24 deletions(-) diff --git a/conf/backend/config-caldav.php b/conf/backend/config-caldav.php index d90ddb5..6499eaf 100644 --- a/conf/backend/config-caldav.php +++ b/conf/backend/config-caldav.php @@ -33,16 +33,16 @@ define('CALDAV_PROTOCOL', 'https'); // Server name -define('CALDAV_SERVER', '__BAIKALDOMAIN__'); +define('CALDAV_SERVER', '__CALDAV_SERVER__'); // Server port define('CALDAV_PORT', '443'); // Path -define('CALDAV_PATH', '__BAIKALPATH__/cal.php/calendars/%u/'); +define('CALDAV_PATH', '__CALDAV_PATH__'); // Default CalDAV folder (calendar folder/principal). This will be marked as the default calendar in the mobile -define('CALDAV_PERSONAL', 'default'); +define('CALDAV_PERSONAL', '__CALDAV_PERSONAL__'); // If the CalDAV server supports the sync-collection operation // DAViCal, SOGo and SabreDav support it diff --git a/conf/backend/config-carddav.php b/conf/backend/config-carddav.php index b291d2c..3020359 100644 --- a/conf/backend/config-carddav.php +++ b/conf/backend/config-carddav.php @@ -31,7 +31,7 @@ define('CARDDAV_PROTOCOL', 'https'); // Server name -define('CARDDAV_SERVER', '__BAIKALDOMAIN__'); +define('CARDDAV_SERVER', '__CARDDAV_SERVER__'); // Server port define('CARDDAV_PORT', '443'); @@ -45,7 +45,7 @@ define('CARDDAV_PORT', '443'); // %u: replaced with the username // %d: replaced with the domain // Add the trailing / -define('CARDDAV_PATH', '__BAIKALPATH__/card.php/addressbooks/%u/'); +define('CARDDAV_PATH', '__CARDDAV_PATH__'); // Server path to the default addressbook @@ -53,7 +53,7 @@ define('CARDDAV_PATH', '__BAIKALPATH__/card.php/addressbooks/%u/'); // %u: replaced with the username // %d: replaced with the domain // Add the trailing / -define('CARDDAV_DEFAULT_PATH', '__BAIKALPATH__/card.php/addressbooks/%u/default'); +define('CARDDAV_DEFAULT_PATH', '__CARDDAV_DEFAULT_PATH__'); // Server path to the GAL addressbook. This addressbook is readonly and searchable by the user, but it will NOT be synced. // If you don't want GAL, comment it diff --git a/conf/backend/config-imap.php b/conf/backend/config-imap.php index 664a172..57a724e 100644 --- a/conf/backend/config-imap.php +++ b/conf/backend/config-imap.php @@ -203,7 +203,7 @@ global $imap_smtp_params; // IMPORTANT: To use SSL you must use PHP 5.1 or later, install openssl libs and use ssl:// within the host variable // IMPORTANT: To use SSL with PHP 5.6 you should set verify_peer, verify_peer_name and allow_self_signed //$imap_smtp_params = array('host' => 'ssl://localhost', 'port' => 465, 'auth' => true, 'username' => 'imap_username', 'password' => 'imap_password'); -$imap_smtp_params = array('host' => 'tcp://__DOMAINTOCHANGE__', 'port' => 587, 'auth' => true, 'username' => 'imap_username', 'password' => 'imap_password', 'localhost' => '__DOMAINTOCHANGE__', 'verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true); +$imap_smtp_params = array('host' => 'tcp://__IMAP_SERVER__', 'port' => 587, 'auth' => true, 'username' => 'imap_username', 'password' => 'imap_password', 'localhost' => '__IMAP_SERVER__', 'verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true); diff --git a/scripts/install b/scripts/install index ee244ab..14f44ce 100755 --- a/scripts/install +++ b/scripts/install @@ -120,42 +120,76 @@ ynh_replace_string __STATEDIR__ $statedir ../conf/config.php # Enable caldav carddav support if yunohost app list --installed -f baikal | grep -q id ; then echo "Detected Baikal" - caldavdomain=$(ynh_app_setting_get baikal domain) - caldavpath=$(ynh_app_setting_get baikal path) - caldavpath=${caldavpath%/} + bailkaldomain=$(ynh_app_setting_get baikal domain) + bailkalpath=$(ynh_app_setting_get baikal path) + bailkalpath=${bailkalpath%/} # Configuration of backend ynh_replace_string __BACKEND__ BackendCombined ../conf/config.php ynh_replace_string __BACKEND__ BackendCombined ../conf/backend/config-autodiscover.php # Configuration baikal - ynh_replace_string __BAIKALDOMAIN__ $caldavdomain ../conf/backend/config-caldav.php - ynh_replace_string __BAIKALDOMAIN__ $caldavdomain ../conf/backend/config-carddav.php - ynh_replace_string __BAIKALPATH__ $caldavpath ../conf/backend/config-caldav.php - ynh_replace_string __BAIKALPATH__ $caldavpath ../conf/backend/config-carddav.php - ynh_replace_string __DOMAINTOCHANGE__ $domain ../conf/backend/config-imap.php + ynh_replace_string __CALDAV_SERVER__ "${bailkaldomain}" ../conf/backend/config-caldav.php + ynh_replace_string __CALDAV_PATH__ "${bailkalpath}/cal.php/calendars/%u/" ../conf/backend/config-caldav.php + ynh_replace_string __CALDAV_PERSONAL__ "default" ../conf/backend/config-caldav.php + + ynh_replace_string __CARDDAV_SERVER__ "${bailkaldomain}" ../conf/backend/config-carddav.php + ynh_replace_string __CARDDAV_PATH__ "${bailkalpath}/card.php/addressbooks/%u/" ../conf/backend/config-carddav.php + ynh_replace_string __CARDDAV_DEFAULT_PATH__ "${bailkalpath}/card.php/addressbooks/%u/default" ../conf/backend/config-carddav.php + + ynh_replace_string __IMAP_SERVER__ "${domain}" ../conf/backend/config-imap.php ynh_replace_string __FLAGTOCHANGE__ true ../conf/backend/config-imap.php # Copy config - cp ../conf/config.php $final_path/config.php - cp ../conf/backend/config-imap.php $final_path/backend/imap/config.php - cp ../conf/backend/config-carddav.php $final_path/backend/carddav/config.php cp ../conf/backend/config-caldav.php $final_path/backend/caldav/config.php + cp ../conf/backend/config-carddav.php $final_path/backend/carddav/config.php + cp ../conf/backend/config-imap.php $final_path/backend/imap/config.php + cp ../conf/backend/config-combined.php $final_path/backend/combined/config.php + +elif yunohost app list --installed -f nextcloud | grep -q id ; then + echo "Detected NextCloud" + nextclouddomain=$(ynh_app_setting_get nextcloud domain) + nextcloudpath=$(ynh_app_setting_get nextcloud path) + nextcloudpath=${nextcloudpath%/} + + # Configuration of backend + ynh_replace_string __BACKEND__ BackendCombined ../conf/config.php + ynh_replace_string __BACKEND__ BackendCombined ../conf/backend/config-autodiscover.php + + # Configuration nextcloud + ynh_replace_string __CALDAV_SERVER__ "${nextclouddomain}" ../conf/backend/config-caldav.php + ynh_replace_string __CALDAV_PATH__ "${nextcloudpath}/remote.php/dav/calendars/%u/" ../conf/backend/config-caldav.php + ynh_replace_string __CALDAV_PERSONAL__ "personal" ../conf/backend/config-caldav.php + + ynh_replace_string __CARDDAV_SERVER__ "${nextclouddomain}" ../conf/backend/config-carddav.php + ynh_replace_string __CARDDAV_PATH__ "${nextcloudpath}/remote.php/dav/addressbooks/users/%u/contacts/" ../conf/backend/config-carddav.php + ynh_replace_string __CARDDAV_DEFAULT_PATH__ "${nextcloudpath}/remote.php/dav/addressbooks/users/%u/contacts/" ../conf/backend/config-carddav.php + + ynh_replace_string __IMAP_SERVER__ "${domain}" ../conf/backend/config-imap.php + ynh_replace_string __FLAGTOCHANGE__ true ../conf/backend/config-imap.php + + # Copy config + cp ../conf/backend/config-caldav.php $final_path/backend/caldav/config.php + cp ../conf/backend/config-carddav.php $final_path/backend/carddav/config.php + cp ../conf/backend/config-imap.php $final_path/backend/imap/config.php cp ../conf/backend/config-combined.php $final_path/backend/combined/config.php - cp ../conf/backend/config-autodiscover.php $final_path/autodiscover/config.php else # Configuration of backend ynh_replace_string __BACKEND__ BackendIMAP ../conf/config.php ynh_replace_string __BACKEND__ BackendIMAP ../conf/backend/config-autodiscover.php - # Copy config - cp ../conf/config.php $final_path/config.php - ynh_replace_string __DOMAINTOCHANGE__ $domain ../conf/backend/config-imap.php + # Configuration imap + ynh_replace_string __IMAP_SERVER__ "${domain}" ../conf/backend/config-imap.php ynh_replace_string __FLAGTOCHANGE__ false ../conf/backend/config-imap.php - cp ../conf/backend/config-imap.php $final_path/backend/imap/config.php - cp ../conf/backend/config-autodiscover.php $final_path/autodiscover/config.php + + # Copy config + cp ../conf/backend/config-imap.php $final_path/backend/imap/config.php fi +# Copy config +cp ../conf/config.php $final_path/config.php +cp ../conf/backend/config-autodiscover.php $final_path/autodiscover/config.php + #Copy XMLElement.php ln -s /usr/share/awl/inc/XML* /var/www/$app/include/ From 1d2c80b1fddb87c2bd58d655533b38338a9466b0 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 8 Apr 2019 21:52:19 +0200 Subject: [PATCH 06/16] implement nextcloud upgrade --- scripts/upgrade | 68 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 51 insertions(+), 17 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 83555d7..c283622 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -141,42 +141,76 @@ ynh_replace_string __STATEDIR__ $statedir ../conf/config.php # Enable caldav carddav support if yunohost app list --installed -f baikal | grep -q id ; then echo "Detected Baikal" - caldavdomain=$(ynh_app_setting_get baikal domain) - caldavpath=$(ynh_app_setting_get baikal path) - caldavpath=${caldavpath%/} + bailkaldomain=$(ynh_app_setting_get baikal domain) + bailkalpath=$(ynh_app_setting_get baikal path) + bailkalpath=${bailkalpath%/} # Configuration of backend ynh_replace_string __BACKEND__ BackendCombined ../conf/config.php ynh_replace_string __BACKEND__ BackendCombined ../conf/backend/config-autodiscover.php # Configuration baikal - ynh_replace_string __BAIKALDOMAIN__ $caldavdomain ../conf/backend/config-caldav.php - ynh_replace_string __BAIKALDOMAIN__ $caldavdomain ../conf/backend/config-carddav.php - ynh_replace_string __BAIKALPATH__ $caldavpath ../conf/backend/config-caldav.php - ynh_replace_string __BAIKALPATH__ $caldavpath ../conf/backend/config-carddav.php - ynh_replace_string __DOMAINTOCHANGE__ $domain ../conf/backend/config-imap.php + ynh_replace_string __CALDAV_SERVER__ "${bailkaldomain}" ../conf/backend/config-caldav.php + ynh_replace_string __CALDAV_PATH__ "${bailkalpath}/cal.php/calendars/%u/" ../conf/backend/config-caldav.php + ynh_replace_string __CALDAV_PERSONAL__ "default" ../conf/backend/config-caldav.php + + ynh_replace_string __CARDDAV_SERVER__ "${bailkaldomain}" ../conf/backend/config-carddav.php + ynh_replace_string __CARDDAV_PATH__ "${bailkalpath}/card.php/addressbooks/%u/" ../conf/backend/config-carddav.php + ynh_replace_string __CARDDAV_DEFAULT_PATH__ "${bailkalpath}/card.php/addressbooks/%u/default" ../conf/backend/config-carddav.php + + ynh_replace_string __IMAP_SERVER__ "${domain}" ../conf/backend/config-imap.php ynh_replace_string __FLAGTOCHANGE__ true ../conf/backend/config-imap.php # Copy config - cp ../conf/config.php $final_path/config.php - cp ../conf/backend/config-imap.php $final_path/backend/imap/config.php - cp ../conf/backend/config-carddav.php $final_path/backend/carddav/config.php cp ../conf/backend/config-caldav.php $final_path/backend/caldav/config.php + cp ../conf/backend/config-carddav.php $final_path/backend/carddav/config.php + cp ../conf/backend/config-imap.php $final_path/backend/imap/config.php + cp ../conf/backend/config-combined.php $final_path/backend/combined/config.php + +elif yunohost app list --installed -f nextcloud | grep -q id ; then + echo "Detected NextCloud" + nextclouddomain=$(ynh_app_setting_get nextcloud domain) + nextcloudpath=$(ynh_app_setting_get nextcloud path) + nextcloudpath=${nextcloudpath%/} + + # Configuration of backend + ynh_replace_string __BACKEND__ BackendCombined ../conf/config.php + ynh_replace_string __BACKEND__ BackendCombined ../conf/backend/config-autodiscover.php + + # Configuration nextcloud + ynh_replace_string __CALDAV_SERVER__ "${nextclouddomain}" ../conf/backend/config-caldav.php + ynh_replace_string __CALDAV_PATH__ "${nextcloudpath}/remote.php/dav/calendars/%u/" ../conf/backend/config-caldav.php + ynh_replace_string __CALDAV_PERSONAL__ "personal" ../conf/backend/config-caldav.php + + ynh_replace_string __CARDDAV_SERVER__ "${nextclouddomain}" ../conf/backend/config-carddav.php + ynh_replace_string __CARDDAV_PATH__ "${nextcloudpath}/remote.php/dav/addressbooks/users/%u/contacts/" ../conf/backend/config-carddav.php + ynh_replace_string __CARDDAV_DEFAULT_PATH__ "${nextcloudpath}/remote.php/dav/addressbooks/users/%u/contacts/" ../conf/backend/config-carddav.php + + ynh_replace_string __IMAP_SERVER__ "${domain}" ../conf/backend/config-imap.php + ynh_replace_string __FLAGTOCHANGE__ true ../conf/backend/config-imap.php + + # Copy config + cp ../conf/backend/config-caldav.php $final_path/backend/caldav/config.php + cp ../conf/backend/config-carddav.php $final_path/backend/carddav/config.php + cp ../conf/backend/config-imap.php $final_path/backend/imap/config.php cp ../conf/backend/config-combined.php $final_path/backend/combined/config.php - cp ../conf/backend/config-autodiscover.php $final_path/autodiscover/config.php else # Configuration of backend ynh_replace_string __BACKEND__ BackendIMAP ../conf/config.php ynh_replace_string __BACKEND__ BackendIMAP ../conf/backend/config-autodiscover.php - # Copy config - cp ../conf/config.php $final_path/config.php - ynh_replace_string __DOMAINTOCHANGE__ $domain ../conf/backend/config-imap.php + # Configuration imap + ynh_replace_string __IMAP_SERVER__ "${domain}" ../conf/backend/config-imap.php ynh_replace_string __FLAGTOCHANGE__ false ../conf/backend/config-imap.php - cp ../conf/backend/config-imap.php $final_path/backend/imap/config.php - cp ../conf/backend/config-autodiscover.php $final_path/autodiscover/config.php + + # Copy config + cp ../conf/backend/config-imap.php $final_path/backend/imap/config.php fi +# Copy config +cp ../conf/config.php $final_path/config.php +cp ../conf/backend/config-autodiscover.php $final_path/autodiscover/config.php + # Fixstates to avoid full resync of devices after version upgrades $final_path/z-push-admin.php -a fixstates From 8e484e582c2e9138c069c922e97c04fd401423ca Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 8 Apr 2019 23:29:39 +0200 Subject: [PATCH 07/16] Implement ldap search --- conf/backend/config-searchldap.php | 56 ++++++++++++++++++++++++++++++ conf/config.php | 2 +- scripts/install | 1 + 3 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 conf/backend/config-searchldap.php diff --git a/conf/backend/config-searchldap.php b/conf/backend/config-searchldap.php new file mode 100644 index 0000000..a0d36b6 --- /dev/null +++ b/conf/backend/config-searchldap.php @@ -0,0 +1,56 @@ +. +* +* Consult LICENSE file for details +************************************************/ + +// LDAP host and port +define("LDAP_HOST", "ldap://127.0.0.1/"); +define("LDAP_PORT", "389"); + +// Set USER and PASSWORD if not using anonymous bind +define("ANONYMOUS_BIND", true); +define("LDAP_BIND_USER", "cn=searchuser,dc=test,dc=net"); +define("LDAP_BIND_PASSWORD", ""); + +// Search base & filter +// the SEARCHVALUE string is substituded by the value inserted into the search field +define("LDAP_SEARCH_BASE", "ou=users,dc=yunohost,dc=org"); +define("LDAP_SEARCH_FILTER", "(|(cn=*SEARCHVALUE*)(mail=*SEARCHVALUE*))"); + +// LDAP field mapping. +// values correspond to an inetOrgPerson class +global $ldap_field_map; +$ldap_field_map = array( + SYNC_GAL_DISPLAYNAME => 'cn', + SYNC_GAL_PHONE => 'telephonenumber', + SYNC_GAL_OFFICE => '', + SYNC_GAL_TITLE => 'title', + SYNC_GAL_COMPANY => 'ou', + SYNC_GAL_ALIAS => 'uid', + SYNC_GAL_FIRSTNAME => 'givenname', + SYNC_GAL_LASTNAME => 'sn', + SYNC_GAL_HOMEPHONE => 'homephone', + SYNC_GAL_MOBILEPHONE => 'mobile', + SYNC_GAL_EMAILADDRESS => 'mail', + ); diff --git a/conf/config.php b/conf/config.php index 76a5e6f..47bb77e 100644 --- a/conf/config.php +++ b/conf/config.php @@ -276,7 +276,7 @@ * If set, the Search Provider will always be preferred. * Use 'BackendSearchLDAP' to search in a LDAP directory (see backend/searchldap/config.php) */ - define('SEARCH_PROVIDER', ''); + define('SEARCH_PROVIDER', 'BackendSearchLDAP'); // Time in seconds for the server search. Setting it too high might result in timeout. // Setting it too low might not return all results. Default is 10. define('SEARCH_WAIT', 10); diff --git a/scripts/install b/scripts/install index 14f44ce..00af287 100755 --- a/scripts/install +++ b/scripts/install @@ -189,6 +189,7 @@ fi # Copy config cp ../conf/config.php $final_path/config.php cp ../conf/backend/config-autodiscover.php $final_path/autodiscover/config.php +cp ../conf/backend/config-searchldap.php $final_path/backend/searchldap/config.php #Copy XMLElement.php ln -s /usr/share/awl/inc/XML* /var/www/$app/include/ From 52a12d6c94eafbcc20fd06431c607d8ba1e39364 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 9 Apr 2019 00:19:02 +0200 Subject: [PATCH 08/16] update upgrade fo searchldap --- scripts/upgrade | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/upgrade b/scripts/upgrade index c283622..2e547fb 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -210,6 +210,7 @@ fi # Copy config cp ../conf/config.php $final_path/config.php cp ../conf/backend/config-autodiscover.php $final_path/autodiscover/config.php +cp ../conf/backend/config-searchldap.php $final_path/backend/searchldap/config.php # Fixstates to avoid full resync of devices after version upgrades $final_path/z-push-admin.php -a fixstates From da7fa9dea5d43b8c4508b734d114ac54d06f4a26 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 9 Apr 2019 23:50:09 +0200 Subject: [PATCH 09/16] Activate multi-instance test --- check_process | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check_process b/check_process index 6b19827..c43b9c3 100644 --- a/check_process +++ b/check_process @@ -13,7 +13,7 @@ upgrade=1 upgrade=1 from_commit=bdac42b709cd2bc663a68422f69ac6bfd43a1ce5 backup_restore=1 - multi_instance=0 + multi_instance=1 incorrect_path=0 port_already_use=0 change_url=0 From ee7e88a82733377b231155468b7530a90d02c44b Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 10 Apr 2019 00:00:02 +0200 Subject: [PATCH 10/16] switch release --- conf/app.src | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conf/app.src b/conf/app.src index 6265cd3..5986e31 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/Z-Hub/Z-Push/archive/3b937fb5c79068553198347ffad1f39f2e9d1b51.tar.gz -SOURCE_SUM=d4d341946a6a2d24c4f9ceebeef8d0c3724c09ed5ad8c905fd1b4c44b25fe6fa +SOURCE_URL=https://github.com/Z-Hub/Z-Push/archive/2.4.5.tar.gz +SOURCE_SUM=ed588da3d4a213bcef3688f928fc250a34684b919aa1a08979e4114a16788b24 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true From 97df0dcdbe801b636191c45f7a58cfbfa854772d Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 10 Apr 2019 00:11:17 +0200 Subject: [PATCH 11/16] solve small typo --- scripts/backup | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/backup b/scripts/backup index 717ccbd..c6f0692 100755 --- a/scripts/backup +++ b/scripts/backup @@ -57,6 +57,8 @@ ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" ynh_print_info "Backing up php-fpm configuration..." ynh_backup "/etc/php/7.0/fpm/pool.d/$app.conf" + +#================================================= # BACKUP LOGROTATE #================================================= ynh_print_info "Backing up logrotate configuration..." From 99d06c6815f8e417e596bf52961e116400fc0f41 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 10 Apr 2019 00:15:31 +0200 Subject: [PATCH 12/16] Switch to ynh_secure_remove --- scripts/install | 2 +- scripts/upgrade | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 00af287..7475218 100755 --- a/scripts/install +++ b/scripts/install @@ -70,7 +70,7 @@ mkdir "$final_path" mkdir "$final_path/tmp" ynh_setup_source "$final_path/tmp" cp -a "$final_path/tmp/src/." "$final_path/." -rm -r "$final_path/tmp" +ynh_secure_remove "$final_path/tmp" #================================================= # NGINX CONFIGURATION diff --git a/scripts/upgrade b/scripts/upgrade index 2e547fb..2605977 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -97,7 +97,7 @@ ynh_print_info "Upgrading source files..." mkdir "$final_path/tmp" ynh_setup_source "$final_path/tmp" cp -a "$final_path/tmp/src/." "$final_path/." -rm -r "$final_path/tmp" +ynh_secure_remove "$final_path/tmp" #================================================= # NGINX CONFIGURATION From 0c172d881d860f940d21723affe12e687eb34155 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 10 Apr 2019 00:19:31 +0200 Subject: [PATCH 13/16] remove duplicate backup during upgrade --- scripts/upgrade | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 2605977..3934b2e 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -42,20 +42,6 @@ if [ -z $final_path ]; then ynh_app_setting_set $app final_path $final_path fi -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -ynh_print_info "Backing up the app before upgrading (may take a while)..." - -# Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { - # restore it if the upgrade fails - ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - if [ -z "$statedir" ]; then statedir="/home/yunohost.app/$app" From c02f0de04d77d34dde89506e7bafd880c26b1982 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 10 Apr 2019 00:34:37 +0200 Subject: [PATCH 14/16] swith to path_url --- scripts/install | 6 +++--- scripts/restore | 6 +++--- scripts/upgrade | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/install b/scripts/install index 7475218..4800ac3 100755 --- a/scripts/install +++ b/scripts/install @@ -22,7 +22,7 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN -path="/Microsoft-Server-ActiveSync" +path_url="/Microsoft-Server-ActiveSync" app=$YNH_APP_INSTANCE_NAME #================================================= @@ -39,7 +39,7 @@ test ! -e "$statedir" || ynh_die "This path already contains a folder" final_logpath="/var/log/$app" # Register (book) web path -ynh_webpath_register $app $domain $path +ynh_webpath_register $app $domain $path_url #================================================= # STORE SETTINGS FROM MANIFEST @@ -47,7 +47,7 @@ ynh_webpath_register $app $domain $path ynh_print_info "Storing installation settings..." ynh_app_setting_set $app domain $domain -ynh_app_setting_set $app path $path +ynh_app_setting_set $app path $path_url ynh_app_setting_set $app statedir "$statedir" ynh_app_setting_set $app final_logpath "$final_logpath" diff --git a/scripts/restore b/scripts/restore index 8ed1da2..995817f 100755 --- a/scripts/restore +++ b/scripts/restore @@ -25,7 +25,7 @@ ynh_print_info "Loading settings..." app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get $app domain) -path=$(ynh_app_setting_get $app path) +path_url=$(ynh_app_setting_get $app path) final_path=$(ynh_app_setting_get $app final_path) statedir=$(ynh_app_setting_get $app statedir) final_logpath=$(ynh_app_setting_get $app final_logpath) @@ -35,8 +35,8 @@ final_logpath=$(ynh_app_setting_get $app final_logpath) #================================================= ynh_print_info "Validating restoration parameters..." -ynh_webpath_available $domain $path \ - || ynh_die "Path not available: ${domain}${path}" +ynh_webpath_available $domain $path_url \ + || ynh_die "Path not available: ${domain}${path_url}" test ! -d $final_path \ || ynh_die "There is already a directory: $final_path " diff --git a/scripts/upgrade b/scripts/upgrade index 3934b2e..f3c0a44 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -17,7 +17,7 @@ ynh_print_info "Loading installation settings..." app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get $app domain) -path=$(ynh_app_setting_get $app path) +path_url=$(ynh_app_setting_get $app path) final_path=$(ynh_app_setting_get $app final_path) statedir=$(ynh_app_setting_get $app statedir) final_logpath=$(ynh_app_setting_get $app final_logpath) From 97c7ea9e140b7d1ac0784fe97590cdff30e48959 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 10 Apr 2019 01:04:02 +0200 Subject: [PATCH 15/16] Switch to dedicated user --- conf/php-fpm.conf | 4 ++-- scripts/install | 14 +++++++++++--- scripts/restore | 20 +++++++++++++++++--- scripts/upgrade | 19 ++++++++++++++++--- 4 files changed, 46 insertions(+), 11 deletions(-) diff --git a/conf/php-fpm.conf b/conf/php-fpm.conf index 6de65f1..50354f3 100644 --- a/conf/php-fpm.conf +++ b/conf/php-fpm.conf @@ -20,8 +20,8 @@ ; Unix user/group of processes ; Note: The user is mandatory. If the group is not set, the default user's group ; will be used. -user = www-data -group = www-data +user = __USER__ +group = __USER__ ; The address on which to accept FastCGI requests. ; Valid syntaxes are: diff --git a/scripts/install b/scripts/install index 7475218..63c844a 100755 --- a/scripts/install +++ b/scripts/install @@ -82,6 +82,14 @@ ynh_print_info "Configuring nginx web server..." # Create a dedicated nginx config ynh_add_nginx_config +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_print_info "Configuring system user..." + +# Create a system user +ynh_system_user_create $app + #================================================= # PHP-FPM CONFIGURATION #================================================= @@ -98,10 +106,10 @@ ynh_add_fpm_config ynh_print_info "Creating statedir and final_logpath..." mkdir -p $statedir -chown -R www-data:www-data $statedir +chown -R $app: $statedir mkdir -p $final_logpath -chown -R www-data:www-data $final_logpath +chown -R $app: $final_logpath #================================================= # MODIFY A CONFIG FILE @@ -201,7 +209,7 @@ ln -s /usr/share/awl/inc/XML* /var/www/$app/include/ #================================================= # Set permissions to app files -chown -R www-data: $final_path +chown -R $app: $final_path #================================================= # SETUP LOGROTATE diff --git a/scripts/restore b/scripts/restore index 8ed1da2..9c11822 100755 --- a/scripts/restore +++ b/scripts/restore @@ -54,15 +54,29 @@ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" ynh_print_info "Restoring the app main directory..." ynh_restore_file "$final_path" -chown -R www-data: $final_path # Restore statedir ynh_restore_file "$statedir" -chown -R www-data:www-data $statedir # Restore logs, data & permissions ynh_restore_file "$final_logpath" -chown -R www-data:www-data $final_logpath + +#================================================= +# RECREATE THE DEDICATED USER +#================================================= +ynh_print_info "Recreating the dedicated system user..." + +# Create the dedicated user (if not existing) +ynh_system_user_create $app + +#================================================= +# RESTORE USER RIGHTS +#================================================= + +# Restore permissions on app files +chown -R $app: $final_path +chown -R $app: $statedir +chown -R $app: $final_logpath #================================================= # RESTORE THE PHP-FPM CONFIGURATION diff --git a/scripts/upgrade b/scripts/upgrade index 3934b2e..8389613 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -46,16 +46,18 @@ if [ -z "$statedir" ]; then statedir="/home/yunohost.app/$app" ynh_app_setting_set "$app" statedir "$statedir" + mkdir -p $statedir else - echo "${statedir} exists, we don't create it." + ynh_print_info "${statedir} exists, we don't create it." fi if [ -z "$final_logpath" ]; then final_logpath="/var/log/$app" ynh_app_setting_set "$app" final_logpath "$final_logpath" + mkdir -p $final_logpath else - echo "${final_logpath} exists, we don't create it." + ynh_print_info "${final_logpath} exists, we don't create it." fi #================================================= @@ -100,6 +102,14 @@ ynh_print_info "Upgrading dependencies..." ynh_install_app_dependencies $pkg_dependencies +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_print_info "Making sure dedicated system user exists..." + +# Create a dedicated user (if not existing) +ynh_system_user_create $app + #================================================= # PHP-FPM CONFIGURATION #================================================= @@ -216,7 +226,10 @@ ynh_use_logrotate --non-append #================================================= # Set permissions on app files -chown -R www-data: $final_path +chown -R $app: $final_path + +chown -R $app: $statedir +chown -R $app: $final_logpath #================================================= # SETUP SSOWAT From bd35b7238edd162452f0e7f34ef4c63680a42ddd Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 10 Apr 2019 03:32:58 +0200 Subject: [PATCH 16/16] add domain in skipped_regex --- scripts/install | 3 ++- scripts/upgrade | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 7475218..5eba948 100755 --- a/scripts/install +++ b/scripts/install @@ -218,7 +218,8 @@ ynh_print_info "Configuring SSOwat..." # Make app public ynh_app_setting_set $app unprotected_uris "/" -ynh_app_setting_set $app skipped_regex "^[^/]*/[Aa]uto[Dd]iscover.*" +domain_regex=$(echo "$domain" | sed 's@-@.@g') +ynh_app_setting_set $app skipped_regex "$domain_regex/[Aa]uto[Dd]iscover/.*" #================================================= # RELOAD NGINX diff --git a/scripts/upgrade b/scripts/upgrade index 3934b2e..a260972 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -225,7 +225,8 @@ ynh_print_info "Upgrading SSOwat configuration..." # Make app public ynh_app_setting_set $app unprotected_uris "/" -ynh_app_setting_set $app skipped_regex "^[^/]*/[Aa]uto[Dd]iscover.*" +domain_regex=$(echo "$domain" | sed 's@-@.@g') +ynh_app_setting_set $app skipped_regex "$domain_regex/[Aa]uto[Dd]iscover/.*" #================================================= # RELOAD NGINX