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

Merge pull request #34 from yalh76/testing

Full upgrade
This commit is contained in:
Maniack Crudelis 2019-04-20 08:02:30 +02:00 committed by GitHub
commit 5a95fa1d33
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 1182 additions and 561 deletions

View file

@ -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.4.5
* * *
### 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.
@ -13,5 +24,37 @@
- [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
* 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_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=1
corrupt_source=0
fail_download_source=0
multi_instance=1
incorrect_path=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

6
conf/app.src Normal file
View file

@ -0,0 +1,6 @@
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
SOURCE_FILENAME=

View file

@ -0,0 +1,110 @@
<?php
/***********************************************
* File : config.php
* Project : Z-Push
* Descr : Autodiscover configuration file
*
* Created : 30.07.2014
*
* Copyright 2007 - 2016 Zarafa Deutschland GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* 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__');

View file

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

View file

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

View file

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

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 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);
@ -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__);

View file

@ -0,0 +1,56 @@
<?php
/***********************************************
* File : searchldap/config.php
* Project : Z-Push
* Descr : configuration file for the
* BackendSearchLDAP backend.
*
* Created : 03.08.2010
*
* Copyright 2007 - 2016 Zarafa Deutschland GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* 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',
);

View file

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

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 {
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;
@ -21,3 +22,26 @@ location /Microsoft-Server-ActiveSync {
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;
}

View file

@ -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 = __USER__
group = __USER__
; 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 %{<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
; 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

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

@ -6,17 +6,18 @@
"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.4.5~ynh1",
"url": "https://z-push.org",
"license": "free",
"license": "AGPL-3.0-or-later",
"maintainer": {
"name": "beudbeud, polytan02"
},
"requirements": {
"yunohost": ">=2.4.0"
"yunohost": ">= 3.4"
},
"services": [
"nginx",
"php5-fpm"
"php7.0-fpm"
],
"multi_instance": true,
"arguments": {
@ -29,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"
}
]
}

20
scripts/_common.sh Normal file
View file

@ -0,0 +1,20 @@
#!/bin/bash
#=================================================
# COMMON VARIABLES
#=================================================
# dependencies used by the app
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
#=================================================
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
#=================================================
# FUTURE OFFICIAL HELPERS
#=================================================

View file

@ -1,30 +1,72 @@
#!/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)."

View file

@ -1,202 +1,243 @@
#!/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
# Retrieve arguments
app=$YNH_APP_INSTANCE_NAME
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# 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_url="/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_url
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_url
# 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
mkdir "$final_path"
mkdir "$final_path/tmp"
ynh_setup_source "$final_path/tmp"
cp -a "$final_path/tmp/src/." "$final_path/."
ynh_secure_remove "$final_path/tmp"
#=================================================
# 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
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_print_info "Configuring system user..."
# Create a system user
ynh_system_user_create $app
#=================================================
# 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 $app: $statedir
mkdir -p $final_logpath
chown -R $app: $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 __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
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%/}
bailkaldomain=$(ynh_app_setting_get baikal domain)
bailkalpath=$(ynh_app_setting_get baikal path)
bailkalpath=${bailkalpath%/}
# Configuration of backend
sed -i "s@BACKENDTOCHANGE@BackendCombined@g" ../conf/config.php
ynh_replace_string __BACKEND__ BackendCombined ../conf/config.php
ynh_replace_string __BACKEND__ BackendCombined ../conf/backend/config-autodiscover.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 __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
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/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
else
# Configuration of backend
sed -i "s@BACKENDTOCHANGE@BackendIMAP@g" ../conf/config.php
ynh_replace_string __BACKEND__ BackendIMAP ../conf/config.php
ynh_replace_string __BACKEND__ BackendIMAP ../conf/backend/config-autodiscover.php
# Configuration imap
ynh_replace_string __IMAP_SERVER__ "${domain}" ../conf/backend/config-imap.php
ynh_replace_string __FLAGTOCHANGE__ false ../conf/backend/config-imap.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/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 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
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 $app: $final_path
# Enable api for client and make app public
ynh_app_setting_set $app skipped_uris "/"
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_print_info "Configuring log rotation..."
# Reload Nginx and regenerate SSOwat conf
sudo service php5-fpm reload
sudo service nginx reload
sudo yunohost app ssowatconf
# 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 unprotected_uris "/"
domain_regex=$(echo "$domain" | sed 's@-@.@g')
ynh_app_setting_set $app skipped_regex "$domain_regex/[Aa]uto[Dd]iscover/.*"
#=================================================
# RELOAD NGINX
#=================================================
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
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"

View file

@ -1,62 +1,117 @@
#!/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 settings..."
app=$YNH_APP_INSTANCE_NAME
# Source YunoHost helpers
source /usr/share/yunohost/helpers
# Retrieve old app settings
path=$(ynh_app_setting_get $app path)
domain=$(ynh_app_setting_get $app domain)
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)
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_url \
|| ynh_die "Path not available: ${domain}${path_url}"
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"
# Restore statedir
sudo mkdir -p $statedir
sudo cp -a ./statedir/. $statedir/
sudo chown -R www-data:www-data $statedir
ynh_restore_file "$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"
# 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
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_print_info "Recreating the dedicated system user..."
# Restore NGINX configuration
sudo cp -a ./nginx.conf $final_nginxconf
# Create the dedicated user (if not existing)
ynh_system_user_create $app
# Restore PHP-FPM configuration
sudo cp -a ./php-fpm.conf $final_phpconf
sudo chown root: $final_phpconf
sudo chmod 644 $final_phpconf
#=================================================
# RESTORE USER RIGHTS
#=================================================
# Make app public
ynh_app_setting_set $app skipped_uris "/"
# Restore permissions on app files
chown -R $app: $final_path
chown -R $app: $statedir
chown -R $app: $final_logpath
#=================================================
# RESTORE THE PHP-FPM CONFIGURATION
#=================================================
# Restart webserver
sudo service nginx reload
sudo service php5-fpm reload
sudo yunohost app ssowatconf
ynh_restore_file "/etc/php/7.0/fpm/pool.d/$app.conf"
#=================================================
# SPECIFIC RESTORATION
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_print_info "Reinstalling dependencies..."
# Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================
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"

View file

@ -1,165 +1,255 @@
#!/bin/bash
set -eu
# Source app helpers
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
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)
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)
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
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
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
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_print_info "Upgrading source files..."
# 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"
# Download, check integrity, uncompress and patch the source from app.src
mkdir "$final_path/tmp"
ynh_setup_source "$final_path/tmp"
cp -a "$final_path/tmp/src/." "$final_path/."
ynh_secure_remove "$final_path/tmp"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_print_info "Upgrading nginx web server configuration..."
# Cleaning
sudo rm -rf $final_path
sudo rm -rf $final_logpath
sudo rm -f $final_nginxconf
sudo rm -f $final_phpconf
sudo rm -f /etc/logrotate.d/$app
# Create a dedicated nginx config
ynh_add_nginx_config
# Copy files to the right place
sudo mkdir -p $final_path
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_print_info "Upgrading dependencies..."
# 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_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
#=================================================
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 __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
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"
bailkaldomain=$(ynh_app_setting_get baikal domain)
bailkalpath=$(ynh_app_setting_get baikal path)
bailkalpath=${bailkalpath%/}
# Configuration of backend
sed -i "s@BACKENDTOCHANGE@BackendCombined@g" ../conf/config.php
# Configuration of backend
ynh_replace_string __BACKEND__ BackendCombined ../conf/config.php
ynh_replace_string __BACKEND__ BackendCombined ../conf/backend/config-autodiscover.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 __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
# 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
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/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
else
# Configuration of backend
sed -i "s@BACKENDTOCHANGE@BackendIMAP@g" ../conf/config.php
# Configuration of backend
ynh_replace_string __BACKEND__ BackendIMAP ../conf/config.php
ynh_replace_string __BACKEND__ BackendIMAP ../conf/backend/config-autodiscover.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 imap
ynh_replace_string __IMAP_SERVER__ "${domain}" ../conf/backend/config-imap.php
ynh_replace_string __FLAGTOCHANGE__ false ../conf/backend/config-imap.php
# Copy config
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
# 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
sudo $final_path/z-push-admin.php -a fixstates
$final_path/z-push-admin.php -a fixstates
# Enable api for client and make the app public
ynh_app_setting_set $app skipped_uris "/"
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_print_info "Upgrading logrotate configuration..."
# Restart of services
sudo service php5-fpm reload
sudo service nginx reload
sudo yunohost app ssowatconf
# 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 $app: $final_path
chown -R $app: $statedir
chown -R $app: $final_logpath
#=================================================
# SETUP SSOWAT
#=================================================
ynh_print_info "Upgrading SSOwat configuration..."
# Make app public
ynh_app_setting_set $app unprotected_uris "/"
domain_regex=$(echo "$domain" | sed 's@-@.@g')
ynh_app_setting_set $app skipped_regex "$domain_regex/[Aa]uto[Dd]iscover/.*"
#=================================================
# RELOAD NGINX
#=================================================
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