1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/z-push_ynh.git synced 2024-09-03 18:05:58 +02:00

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
This commit is contained in:
yalh76 2019-03-31 04:34:31 +02:00 committed by GitHub
parent 96fda9562e
commit 71cbe948ee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 780 additions and 511 deletions

View file

@ -1,4 +1,15 @@
# Z-Push For Yunohost # 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 : ### 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. - [ ] [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] The sources are based on http://download.z-push.org/final/
- [x] Use of version 2.3.6 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
```

View file

@ -9,25 +9,23 @@
setup_root=0 setup_root=0
setup_nourl=0 setup_nourl=0
setup_private=0 setup_private=0
setup_public=0 setup_public=1
upgrade=1 upgrade=1
upgrade=1 from_commit=bdac42b709cd2bc663a68422f69ac6bfd43a1ce5
backup_restore=1 backup_restore=1
multi_instance=0 multi_instance=0
wrong_user=0
wrong_path=1
incorrect_path=0 incorrect_path=0
corrupt_source=0
fail_download_source=0
port_already_use=0 port_already_use=0
final_path_already_use=0 change_url=0
;;; Levels ;;; Levels
Level 1=auto Level 1=auto
Level 2=auto Level 2=auto
Level 3=auto Level 3=auto
# ? Level 4=0
Level 4=1 Level 5=auto
# ? Level 6=auto
Level 5=1 Level 7=auto
Level 6=auto Level 8=0
Level 7=auto Level 9=0
Level 10=0

6
conf/app.src Normal file
View file

@ -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=

View file

@ -33,13 +33,13 @@
define('CALDAV_PROTOCOL', 'https'); define('CALDAV_PROTOCOL', 'https');
// Server name // Server name
define('CALDAV_SERVER', 'BAIKALDOMAIN'); define('CALDAV_SERVER', '__BAIKALDOMAIN__');
// Server port // Server port
define('CALDAV_PORT', '443'); define('CALDAV_PORT', '443');
// Path // 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 // Default CalDAV folder (calendar folder/principal). This will be marked as the default calendar in the mobile
define('CALDAV_PERSONAL', 'default'); define('CALDAV_PERSONAL', 'default');

View file

@ -31,7 +31,7 @@
define('CARDDAV_PROTOCOL', 'https'); define('CARDDAV_PROTOCOL', 'https');
// Server name // Server name
define('CARDDAV_SERVER', 'BAIKALDOMAIN'); define('CARDDAV_SERVER', '__BAIKALDOMAIN__');
// Server port // Server port
define('CARDDAV_PORT', '443'); define('CARDDAV_PORT', '443');
@ -45,7 +45,7 @@ define('CARDDAV_PORT', '443');
// %u: replaced with the username // %u: replaced with the username
// %d: replaced with the domain // %d: replaced with the domain
// Add the trailing / // 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 // Server path to the default addressbook

View file

@ -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 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 // 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' => '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. // 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__);

View file

@ -27,7 +27,7 @@
* Default settings * Default settings
*/ */
// Defines the default time zone, change e.g. to "Europe/London" if necessary // 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 // Defines the base path on the server
define('BASE_PATH', dirname($_SERVER['SCRIPT_FILENAME']). '/'); 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 * State migration script is available, more informations: https://wiki.z-hub.io/x/xIAa
*/ */
define('STATE_MACHINE', 'FILE'); define('STATE_MACHINE', 'FILE');
define('STATE_DIR', 'STATEDIRTOCHANGE/'); define('STATE_DIR', '__STATEDIR__/');
/********************************************************************************** /**********************************************************************************
* IPC - InterProcessCommunication * IPC - InterProcessCommunication
@ -110,7 +110,7 @@
$specialLogUsers = array(); $specialLogUsers = array();
// Filelog settings // Filelog settings
define('LOGFILEDIR', 'LOGTOCHANGE/'); define('LOGFILEDIR', '__FINAL_LOGPATH__/');
define('LOGFILE', LOGFILEDIR . 'z-push.log'); define('LOGFILE', LOGFILEDIR . 'z-push.log');
define('LOGERRORFILE', LOGFILEDIR . 'z-push-error.log'); define('LOGERRORFILE', LOGFILEDIR . 'z-push-error.log');
@ -266,7 +266,7 @@
* Backend settings * Backend settings
*/ */
// the backend data provider // the backend data provider
define('BACKEND_PROVIDER', 'BACKENDTOCHANGE'); define('BACKEND_PROVIDER', '__BACKEND__');
/********************************************************************************** /**********************************************************************************
* Search provider settings * Search provider settings

View file

@ -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
}

View file

@ -1,5 +1,5 @@
location /Microsoft-Server-ActiveSync { location /Microsoft-Server-ActiveSync {
alias ALIASTOCHANGE; alias __FINALPATH__/ ;
if ($scheme = http) { if ($scheme = http) {
rewrite ^ https://$server_name$request_uri? permanent; rewrite ^ https://$server_name$request_uri? permanent;
} }
@ -9,7 +9,8 @@ location /Microsoft-Server-ActiveSync {
rewrite ^(.*)$ /Microsoft-Server-ActiveSync/index.php last; rewrite ^(.*)$ /Microsoft-Server-ActiveSync/index.php last;
location ~ [^/]\.php(/|$) { location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.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; fastcgi_index index.php;
include fastcgi_params; include fastcgi_params;
fastcgi_param HTTPS on; fastcgi_param HTTPS on;
@ -20,4 +21,3 @@ location /Microsoft-Server-ActiveSync {
# Include SSOWAT user panel. # Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc; include conf.d/yunohost_panel.conf.inc;
} }

View file

@ -1,10 +1,11 @@
; Start a new pool named 'www'. ; 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) ; pool name ('www' here)
[NAMETOCHANGE] [__NAMETOCHANGE__]
; Per pool prefix ; Per pool prefix
; It only applies on the following directives: ; It only applies on the following directives:
; - 'access.log'
; - 'slowlog' ; - 'slowlog'
; - 'listen' (unixsocket) ; - 'listen' (unixsocket)
; - 'chroot' ; - 'chroot'
@ -16,21 +17,43 @@
; Default Value: none ; Default Value: none
;prefix = /path/to/pools/$pool ;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. ; The address on which to accept FastCGI requests.
; Valid syntaxes are: ; 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; ; a specific port;
; 'port' - to listen on a TCP socket to all addresses on a ; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
; specific port; ; 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. ; '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory. ; 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. ; Set listen(2) backlog.
; Default Value: 128 (-1 on FreeBSD and OpenBSD) ; Default Value: 511 (-1 on FreeBSD and OpenBSD)
;listen.backlog = -1 ;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 ; 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 ; 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 ; 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 ; Default Value: any
;listen.allowed_clients = 127.0.0.1 ;listen.allowed_clients = 127.0.0.1
; Set permissions for unix socket, if one is used. In Linux, read/write ; Specify the nice(2) priority to apply to the pool processes (only if set)
; permissions must be set in order to allow connections from a web server. Many ; The value can vary from -19 (highest priority) to 20 (lower priority)
; BSD-derived systems allow connections regardless of permissions. ; Note: - It will only work if the FPM master process is launched as root
; Default Values: user and group are set as the running user ; - The pool processes will inherit the master process priority
; mode is set to 0666 ; unless it specified otherwise
listen.owner = www-data ; Default Value: no set
listen.group = www-data ; process.priority = -19
listen.mode = 0600
; Unix user/group of processes ; Set the process dumpable flag (PR_SET_DUMPABLE prctl) even if the process user
; Note: The user is mandatory. If the group is not set, the default user's group ; or group is differrent than the master process user. It allows to create process
; will be used. ; core dump and ptrace the process for the pool user.
user = www-data ; Default Value: no
group = www-data ; process.dumpable = yes
; Choose how the process manager will control the number of child processes. ; Choose how the process manager will control the number of child processes.
; Possible Values: ; Possible Values:
; static - a fixed number (pm.max_children) of child processes; ; static - a fixed number (pm.max_children) of child processes;
; dynamic - the number of child processes are set dynamically based on the ; 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 ; pm.max_children - the maximum number of children that can
; be alive at the same time. ; be alive at the same time.
; pm.start_servers - the number of children created on startup. ; pm.start_servers - the number of children created on startup.
@ -69,16 +92,23 @@ group = www-data
; state (waiting to process). If the number ; state (waiting to process). If the number
; of 'idle' processes is greater than this ; of 'idle' processes is greater than this
; number then some children will be killed. ; 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. ; Note: This value is mandatory.
pm = dynamic pm = dynamic
; The number of child processes to be created when pm is set to 'static' and the ; 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 ; This value sets the limit on the number of simultaneous requests that will be
; served. Equivalent to the ApacheMaxClients directive with mpm_prefork. ; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP ; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
; CGI. ; CGI. The below defaults are based on a server without much resources. Don't
; Note: Used when pm is set to either 'static' or 'dynamic' ; forget to tweak pm.* to fit your needs.
; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand'
; Note: This value is mandatory. ; Note: This value is mandatory.
pm.max_children = 10 pm.max_children = 10
@ -97,6 +127,11 @@ pm.min_spare_servers = 3
; Note: Mandatory when pm is set to 'dynamic' ; Note: Mandatory when pm is set to 'dynamic'
pm.max_spare_servers = 5 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. ; 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 ; 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. ; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
@ -104,33 +139,98 @@ pm.max_spare_servers = 5
pm.max_requests = 0 pm.max_requests = 0
; The URI to view the FPM status page. If this value is not set, no URI will be ; 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 ; recognized as a status page. It shows the following informations:
; information:
; accepted conn - the number of request accepted by the pool;
; pool - the name of the pool; ; 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; ; idle processes - the number of idle processes;
; active processes - the number of active 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, ; max children reached - number of times, the process limit has been reached,
; when pm tries to start more children (works only for ; when pm tries to start more children (works only for
; pm 'dynamic') ; pm 'dynamic' and 'ondemand');
; The values of 'idle processes', 'active processes' and 'total processes' are ; Value are updated in real time.
; updated each second. The value of 'accepted conn' is updated in real time.
; Example output: ; Example output:
; accepted conn: 12073
; pool: www ; pool: www
; process manager: static ; process manager: static
; idle processes: 35 ; start time: 01/Jul/2011:17:53:49 +0200
; active processes: 65 ; start since: 62636
; total processes: 100 ; accepted conn: 190460
; max children reached: 1 ; 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 ; 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 ; 'html', 'xml' or 'json' in the query string will return the corresponding
; syntax. Example: ; output syntax. Example:
; http://www.foo.bar/status ; http://www.foo.bar/status
; http://www.foo.bar/status?json ; http://www.foo.bar/status?json
; http://www.foo.bar/status?html ; 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 ; 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 ; anything, but it may not be a good idea to use the .php extension or it
; may conflict with a real PHP file. ; may conflict with a real PHP file.
@ -154,12 +254,73 @@ ping.path = /ping
; Default Value: pong ; Default Value: pong
;ping.response = pong ;ping.response = pong
; The timeout for serving a single request after which the worker process will ; The access log file
; be killed. This option should be used when the 'max_execution_time' ini option ; Default: not set
; does not stop script execution for some reason. A value of '0' means 'off'. ;access.log = log/$pool.access.log
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
; Default Value: 0 ; The access log format.
request_terminate_timeout = 700s ; 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 %{<strftime_format>}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 %{<strftime_format>}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 ; 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'. ; dumped to the 'slowlog' file. A value of '0s' means 'off'.
@ -167,10 +328,12 @@ request_terminate_timeout = 700s
; Default Value: 0 ; Default Value: 0
request_slowlog_timeout = 5s request_slowlog_timeout = 5s
; The log file for slow requests ; The timeout for serving a single request after which the worker process will
; Default Value: not set ; be killed. This option should be used when the 'max_execution_time' ini option
; Note: slowlog is mandatory if request_slowlog_timeout is set ; does not stop script execution for some reason. A value of '0' means 'off'.
slowlog = /var/log/nginx/NAMETOCHANGE.slow.log ; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
; Default Value: 0
request_terminate_timeout = 700s
; Set open file descriptor rlimit. ; Set open file descriptor rlimit.
; Default Value: system defined value ; Default Value: system defined value
@ -195,7 +358,7 @@ rlimit_core = 0
; Chdir to this directory at the start. ; Chdir to this directory at the start.
; Note: relative path can be used. ; Note: relative path can be used.
; Default Value: current directory or / when chroot ; 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 ; 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. ; stderr will be redirected to /dev/null according to FastCGI specs.
@ -204,6 +367,23 @@ chdir = /var/www/NAMETOCHANGE
; Default Value: no ; Default Value: no
catch_workers_output = yes 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 ; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from
; the current environment. ; the current environment.
; Default Value: clean env ; Default Value: clean env
@ -238,11 +418,13 @@ catch_workers_output = yes
;php_admin_flag[log_errors] = on ;php_admin_flag[log_errors] = on
;php_admin_value[memory_limit] = 32M ;php_admin_value[memory_limit] = 32M
php_value[upload_max_filesize] = 50M ; Common values to change to increase file upload limit
php_value[post_max_size] = 50M php_admin_value[upload_max_filesize] = 50M
php_value[mail.add_x_header] = Off php_admin_value[post_max_size] = 50M
php_value[max_execution_time] = 600 php_admin_flag[mail.add_x_header] = Off
php_value[max_input_time] = 300
php_value[memory_limit] = 256M
php_value[short_open_tag] = On
; 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

View file

@ -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.

View file

@ -13,11 +13,11 @@
"name": "beudbeud, polytan02" "name": "beudbeud, polytan02"
}, },
"requirements": { "requirements": {
"yunohost": ">=2.4.0" "yunohost": ">= 3.4"
}, },
"services": [ "services": [
"nginx", "nginx",
"php5-fpm" "php7.0-fpm"
], ],
"multi_instance": true, "multi_instance": true,
"arguments": { "arguments": {
@ -30,16 +30,6 @@
"fr": "Choisissez un domaine pour Z-push" "fr": "Choisissez un domaine pour Z-push"
}, },
"example": "domain.org" "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"
} }
] ]
} }

View file

@ -5,7 +5,7 @@
#================================================= #=================================================
# dependencies used by the app # dependencies used by the app
pkg_dependencies="deb1 deb2" pkg_dependencies="php-soap php5-imap libawl-php php5-xsl"
#================================================= #=================================================
# PERSONAL HELPERS # PERSONAL HELPERS

View file

@ -1,30 +1,70 @@
#!/bin/bash #!/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 app=$YNH_APP_INSTANCE_NAME
# Source YunoHost helpers
source /usr/share/yunohost/helpers
final_path=$(ynh_app_setting_get $app final_path) final_path=$(ynh_app_setting_get $app final_path)
domain=$(ynh_app_setting_get $app domain)
statedir=$(ynh_app_setting_get $app statedir) statedir=$(ynh_app_setting_get $app statedir)
final_logpath=$(ynh_app_setting_get $app final_logpath) 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. # STANDARD BACKUP STEPS
ynh_backup "$final_path" "sources" #=================================================
# BACKUP THE APP MAIN DIR
#=================================================
ynh_print_info "Backing up the main app directory..."
ynh_backup "$final_path"
# Backup statedir # Backup statedir
ynh_backup "$statedir" "statedir" ynh_backup "$statedir"
# Backup logs # Backup logs
ynh_backup "$final_logpath" "logs" ynh_backup "$final_logpath"
ynh_backup "/etc/logrotate.d/$app" "logrotate"
# 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 "/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_backup "$final_phpconf" "php-fpm.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)."

View file

@ -16,172 +16,175 @@ source /usr/share/yunohost/helpers
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors ynh_abort_if_errors
# Retrieve arguments #=================================================
app=$YNH_APP_INSTANCE_NAME # RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
domain=$YNH_APP_ARG_DOMAIN domain=$YNH_APP_ARG_DOMAIN
path=$YNH_APP_ARG_PATH
# We check variables are not empty path="/Microsoft-Server-ActiveSync"
CHECK_VAR () { # Vérifie que la variable n'est pas vide. app=$YNH_APP_INSTANCE_NAME
# $1 = Variable à vérifier
# $2 = Texte à afficher en cas d'erreur
test -n "$1" || (echo "$2" >&2 && false)
}
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) final_path=/var/www/$app
CHECK_PATH () { # Vérifie la présence du / en début de path. Et son absence à la fin. test ! -e "$final_path" || ynh_die "This path already contains a folder"
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
statedir="/home/yunohost.app/$app" statedir="/home/yunohost.app/$app"
test ! -e "$statedir" || ynh_die "This path already contains a folder"
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"
final_logpath="/var/log/$app" final_logpath="/var/log/$app"
ynh_app_setting_set "$app" final_logpath "$final_logpath"
final_nginxconf="/etc/nginx/conf.d/${domain}.d/${app}.conf" # Register (book) web path
ynh_app_setting_set "$app" final_nginxconf "$final_nginxconf" 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 ynh_app_setting_set $app domain $domain
sudo mkdir -p $final_path ynh_app_setting_set $app path $path
# We download the sources and check the md5sum ynh_app_setting_set $app statedir "$statedir"
SFILE=`sudo cat ../sources/source_file`; ynh_app_setting_set $app final_logpath "$final_logpath"
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/ # INSTALL DEPENDENCIES
sudo cp -a ../sources/$SFILE/. $final_path/ #=================================================
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 # Configuration
sed -i "s^define('TIMEZONE', .*^define('TIMEZONE', '$(cat /etc/timezone)');^" ../conf/config.php ynh_replace_string __TIMEZONE__ $(cat /etc/timezone) ../conf/config.php
sed -i "s@LOGTOCHANGE@$final_logpath@g" ../conf/config.php ynh_replace_string __FINAL_LOGPATH__ $final_logpath ../conf/config.php
sed -i "s@LOGTOCHANGE@$final_logpath@g" ../conf/logrotate
# Storage of state_dir in /home/yunohost.app # Storage of state_dir in /home/yunohost.app
# This contains the sync status in between device and z-push # This contains the sync status in between device and z-push
sed -i "s@STATEDIRTOCHANGE@$statedir@g" ../conf/config.php ynh_replace_string __STATEDIR__ $statedir ../conf/config.php
sudo mkdir -p $statedir
sudo chown -R www-data:www-data $statedir
# Enable caldav carddav support # 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" echo "Detected Baikal"
caldavdomain=$(ynh_app_setting_get baikal domain) caldavdomain=$(ynh_app_setting_get baikal domain)
caldavpath=$(ynh_app_setting_get baikal path) caldavpath=$(ynh_app_setting_get baikal path)
caldavpath=${caldavpath%/} caldavpath=${caldavpath%/}
# Configuration of backend # Configuration of backend
sed -i "s@BACKENDTOCHANGE@BackendCombined@g" ../conf/config.php ynh_replace_string __BACKEND__ BackendCombined ../conf/config.php
# Configuration baikal # Configuration baikal
sed -i "s@BAIKALDOMAIN@$caldavdomain@g" ../conf/backend/config*.php ynh_replace_string __BAIKALDOMAIN__ $caldavdomain ../conf/backend/config*.php
sed -i "s@BAIKALPATH@$caldavpath@g" ../conf/backend/config*.php ynh_replace_string __BAIKALPATH__ $caldavpath ../conf/backend/config*.php
sed -i "s@DOMAINTOCHANGE@$domain@g" ../conf/backend/config-imap.php ynh_replace_string __DOMAINTOCHANGE__ $domain ../conf/backend/config-imap.php
sed -i "s@FLAGTOCHANGE@true@g" ../conf/backend/config-imap.php ynh_replace_string __FLAGTOCHANGE__ true ../conf/backend/config-imap.php
# Copy config # Copy config
sudo cp ../conf/config.php $final_path/config.php cp ../conf/config.php $final_path/config.php
sudo cp ../conf/backend/config-imap.php $final_path/backend/imap/config.php 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 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 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/backend/config-combined.php $final_path/backend/combined/config.php
else else
# Configuration of backend # Configuration of backend
sed -i "s@BACKENDTOCHANGE@BackendIMAP@g" ../conf/config.php ynh_replace_string __BACKEND__ BackendIMAP ../conf/config.php
# Copy config # Copy config
sudo cp ../conf/config.php $final_path/config.php cp ../conf/config.php $final_path/config.php
sed -i "s@DOMAINTOCHANGE@$domain@g" ../conf/backend/config-imap.php ynh_replace_string __DOMAINTOCHANGE__ $domain ../conf/backend/config-imap.php
sed -i "s@FLAGTOCHANGE@false@g" ../conf/backend/config-imap.php ynh_replace_string __FLAGTOCHANGE__ false ../conf/backend/config-imap.php
sudo cp ../conf/backend/config-imap.php $final_path/backend/imap/config.php cp ../conf/backend/config-imap.php $final_path/backend/imap/config.php
fi 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 #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 # GENERIC FINALIZATION
sudo sed -i "s@NAMETOCHANGE@$app@g" ../conf/nginx.conf #=================================================
sudo cp ../conf/nginx.conf $final_nginxconf # SECURE FILES AND DIRECTORIES
#=================================================
# Dedicated php-fpm processes # Set permissions to app files
sudo sed -i "s@NAMETOCHANGE@$app@g" ../conf/php-fpm.conf chown -R www-data: $final_path
sudo cp ../conf/php-fpm.conf $final_phpconf
sudo chown root: $final_phpconf
sudo chmod 644 $final_phpconf
# 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 "/" ynh_app_setting_set $app skipped_uris "/"
# Reload Nginx and regenerate SSOwat conf #=================================================
sudo service php5-fpm reload # RELOAD NGINX
sudo service nginx reload #=================================================
sudo yunohost app ssowatconf ynh_print_info "Reloading nginx web server..."
systemctl reload nginx
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Installation of $app completed"

View file

@ -1,77 +1,78 @@
#!/bin/bash #!/bin/bash
set -u
# Source app helpers #=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers 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. # LOAD SETTINGS
no_var=0 #=================================================
while (echo "$chaine" | grep -q '\$') # Boucle tant qu'il y a des $ dans la chaine ynh_print_info "Loading installation settings..."
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
}
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 app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get "$app" domain)
# Cleaning domain=$(ynh_app_setting_get $app domain)
SECURE_REMOVE '/var/www/$app'
SECURE_REMOVE '/home/yunohost.app/$app'
SECURE_REMOVE '/var/log/$app'
REMOVE_NGINX_CONF final_path=$(ynh_app_setting_get $app final_path)
REMOVE_FPM_CONF statedir=$(ynh_app_setting_get $app statedir)
REMOVE_LOGROTATE_CONF final_logpath=$(ynh_app_setting_get $app final_logpath)
# Remove app dependencies #=================================================
if ynh_package_is_installed "z-push-deps"; then # REMOVE DEPENDENCIES
ynh_package_autoremove "z-push-deps" #=================================================
fi ynh_print_info "Removing dependencies"
# Restart of services # Remove metapackage and its dependencies
sudo service php5-fpm reload ynh_remove_app_dependencies
sudo service nginx reload
sudo yunohost app ssowatconf #=================================================
# 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"

View file

@ -14,65 +14,90 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE # 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 # Exit if an error occurs during the execution of the script
ynh_abort_if_errors ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info "Loading settings..."
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
# Retrieve old app settings
path=$(ynh_app_setting_get $app path)
domain=$(ynh_app_setting_get $app domain) domain=$(ynh_app_setting_get $app domain)
path=$(ynh_app_setting_get $app path)
final_path=$(ynh_app_setting_get $app final_path) final_path=$(ynh_app_setting_get $app final_path)
statedir=$(ynh_app_setting_get $app statedir) statedir=$(ynh_app_setting_get $app statedir)
final_logpath=$(ynh_app_setting_get $app final_logpath) 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 # CHECK IF THE APP CAN BE RESTORED
sudo apt-get install php-soap php5-imap libawl-php php5-xsl -y #=================================================
ynh_print_info "Validating restoration parameters..."
# Install dependencies using Helpers ynh_webpath_available $domain $path \
#ynh_package_install_from_equivs ../conf/z-push-deps.control \ || ynh_die "Path not available: ${domain}${path}"
#|| ynh_die "Unable to install dependencies" test ! -d $final_path \
|| ynh_die "There is already a directory: $final_path "
# Restore sources, data and permissions #=================================================
sudo mkdir -p $final_path # STANDARD RESTORATION STEPS
sudo cp -a ./sources/. $final_path/ #=================================================
sudo chown -R www-data: $final_path # 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 # Restore statedir
sudo mkdir -p $statedir ynh_restore_file "$statedir"
sudo cp -a ./statedir/. $statedir/ chown -R www-data:www-data $statedir
sudo chown -R www-data:www-data $statedir
# Restore logs, data & permissions # Restore logs, data & permissions
sudo mkdir -p $final_logpath ynh_restore_file "$final_logpath"
sudo cp -a ./logs/. $final_logpath/ chown -R www-data:www-data $final_logpath
sudo chown -R www-data:www-data $final_logpath
# Restore logrotate #=================================================
sudo cp -a ./logrotate /etc/logrotate.d/$app # RESTORE THE PHP-FPM CONFIGURATION
sudo chmod 644 /etc/logrotate.d/$app #=================================================
sudo chown root:root /etc/logrotate.d/$app
# Restore NGINX configuration ynh_restore_file "/etc/php/7.0/fpm/pool.d/$app.conf"
sudo cp -a ./nginx.conf $final_nginxconf
# Restore PHP-FPM configuration #=================================================
sudo cp -a ./php-fpm.conf $final_phpconf # SPECIFIC RESTORATION
sudo chown root: $final_phpconf #=================================================
sudo chmod 644 $final_phpconf # REINSTALL DEPENDENCIES
#=================================================
ynh_print_info "Reinstalling dependencies..."
# Make app public # Define and install dependencies
ynh_app_setting_set $app skipped_uris "/" ynh_install_app_dependencies $pkg_dependencies
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================
# Restart webserver ynh_restore_file "/etc/logrotate.d/$app"
sudo service nginx reload
sudo service php5-fpm reload
sudo yunohost app ssowatconf
#=================================================
# 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"

View file

@ -9,23 +9,37 @@
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
# Retrieve arguments #=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info "Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain) domain=$(ynh_app_setting_get $app domain)
path=$(ynh_app_setting_get $app path) path=$(ynh_app_setting_get $app path)
final_path=$(ynh_app_setting_get $app final_path) final_path=$(ynh_app_setting_get $app final_path)
statedir=$(ynh_app_setting_get $app statedir) statedir=$(ynh_app_setting_get $app statedir)
final_logpath=$(ynh_app_setting_get $app final_logpath) 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" ]; # ENSURE DOWNWARD COMPATIBILITY
then #=================================================
final_path="/var/www/$app" ynh_print_info "Ensuring downward compatibility..."
ynh_app_setting_set "$app" final_path "$final_path"
else # Fix is_public as a boolean value
echo "${final_path} exists, we don't create it." 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 fi
#================================================= #=================================================
@ -58,127 +72,144 @@ else
echo "${final_logpath} exists, we don't create it." echo "${final_logpath} exists, we don't create it."
fi fi
if [ -z "$final_nginxconf" ]; #=================================================
then # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
final_nginxconf="/etc/nginx/conf.d/${domain}.d/${app}.conf" #=================================================
ynh_app_setting_set "$app" final_nginxconf "$final_nginxconf" ynh_print_info "Backing up the app before upgrading (may take a while)..."
else
echo "${final_nginxconf} exists, we don't create it."
fi
if [ -z "$final_phpconf" ]; # Backup the current version of the app
then ynh_backup_before_upgrade
final_phpconf=/etc/php5/fpm/pool.d/$app.conf ynh_clean_setup () {
ynh_app_setting_set "$app" final_phpconf "$final_phpconf" # restore it if the upgrade fails
else ynh_restore_upgradebackup
echo "${final_phpconf} exists, we don't create it." }
fi # 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 # STANDARD UPGRADE STEPS
# Install dependencies using Helpers #=================================================
ynh_package_install_from_equivs ../conf/z-push-deps.control \ # DOWNLOAD, CHECK AND UNPACK SOURCE
|| ynh_die "Unable to install dependencies" #=================================================
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" # NGINX CONFIGURATION
ynh_secure_remove "$final_logpath" #=================================================
sudo rm -f $final_nginxconf ynh_print_info "Upgrading nginx web server configuration..."
sudo rm -f $final_phpconf
sudo rm -f /etc/logrotate.d/$app
# Copy files to the right place # Create a dedicated nginx config
sudo mkdir -p $final_path ynh_add_nginx_config
# We download the sources and check the md5sum #=================================================
SFILE=`sudo cat ../sources/source_file`; # UPGRADE DEPENDENCIES
sudo wget -nv -i ../sources/source_url -O ${SFILE}.tar.gz #=================================================
sudo md5sum -c ../sources/source_md5 --status || (echo "Corrupt source" >&2 && false) ynh_print_info "Upgrading dependencies..."
sudo tar xvf ${SFILE}.tar.gz -C ../sources/
sudo cp -a ../sources/$SFILE/. $final_path/ 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 # Configuration
sed -i "s^define('TIMEZONE', .*^define('TIMEZONE', '$(cat /etc/timezone)');^" ../conf/config.php ynh_replace_string __TIMEZONE__ $(cat /etc/timezone) ../conf/config.php
sed -i "s@LOGTOCHANGE@$final_logpath@g" ../conf/config.php ynh_replace_string __FINAL_LOGPATH__ $final_logpath ../conf/config.php
sed -i "s@LOGTOCHANGE@$final_logpath@g" ../conf/logrotate
# Storage of state_dir in /home/yunohost.app # Storage of state_dir in /home/yunohost.app
# This contains the sync status in between device and z-push # This contains the sync status in between device and z-push
sed -i "s@STATEDIRTOCHANGE@$statedir@g" ../conf/config.php ynh_replace_string __STATEDIR__ $statedir ../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
# Enable caldav carddav support # 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" echo "Detected Baikal"
caldavdomain=$(ynh_app_setting_get baikal domain) caldavdomain=$(ynh_app_setting_get baikal domain)
caldavpath=$(ynh_app_setting_get baikal path) caldavpath=$(ynh_app_setting_get baikal path)
caldavpath=${caldavpath%/} caldavpath=${caldavpath%/}
# Configuration of backend # Configuration of backend
sed -i "s@BACKENDTOCHANGE@BackendCombined@g" ../conf/config.php ynh_replace_string __BACKEND__ BackendCombined ../conf/config.php
# Configuration baikal # Configuration baikal
sed -i "s@BAIKALDOMAIN@$caldavdomain@g" ../conf/backend/config*.php ynh_replace_string __BAIKALDOMAIN__ $caldavdomain ../conf/backend/config*.php
sed -i "s@BAIKALPATH@$caldavpath@g" ../conf/backend/config*.php ynh_replace_string __BAIKALPATH__ $caldavpath ../conf/backend/config*.php
sed -i "s@DOMAINTOCHANGE@$domain@g" ../conf/backend/config-imap.php ynh_replace_string __DOMAINTOCHANGE__ $domain ../conf/backend/config-imap.php
sed -i "s@FLAGTOCHANGE@true@g" ../conf/backend/config-imap.php ynh_replace_string __FLAGTOCHANGE__ true ../conf/backend/config-imap.php
# Copy config # Copy config
sudo cp ../conf/config.php $final_path/config.php cp ../conf/config.php $final_path/config.php
sudo cp ../conf/backend/config-imap.php $final_path/backend/imap/config.php 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 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 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/backend/config-combined.php $final_path/backend/combined/config.php
else else
# Configuration of backend # 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
# 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 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 # 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 "/" ynh_app_setting_set $app skipped_uris "/"
# Restart of services #=================================================
sudo service php5-fpm reload # RELOAD NGINX
sudo service nginx reload #=================================================
sudo yunohost app ssowatconf ynh_print_info "Reloading nginx web server..."
systemctl reload nginx
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Upgrade of $app completed"

View file

@ -1 +0,0 @@
z-push-2.3.6

View file

@ -1 +0,0 @@
36673351affcc83d1e98de8f8d606feb z-push-2.3.6.tar.gz

View file

@ -1 +0,0 @@
http://download.z-push.org/final/2.3/z-push-2.3.6.tar.gz