mirror of
https://github.com/YunoHost-Apps/roundcube_ynh.git
synced 2024-09-03 20:16:28 +02:00
[fix] Update new version & script
This commit is contained in:
parent
bbfe887818
commit
2d3edbe943
10 changed files with 687 additions and 219 deletions
|
@ -1,5 +1,5 @@
|
|||
location #PATH# {
|
||||
alias #DESTDIR#;
|
||||
location __PATH__ {
|
||||
alias __FINALPATH__/;
|
||||
|
||||
if ($scheme = http) {
|
||||
rewrite ^ https://$server_name$request_uri? permanent;
|
||||
|
@ -13,7 +13,7 @@ location #PATH# {
|
|||
location ~ [^/]\.php(/|$) {
|
||||
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
|
||||
|
||||
fastcgi_pass unix:/var/run/php5-fpm-roundcube.sock;
|
||||
fastcgi_pass unix:/var/run/php5-fpm-__NAME__.sock;
|
||||
fastcgi_index index.php;
|
||||
fastcgi_param REMOTE_USER $remote_user;
|
||||
fastcgi_param PATH_INFO $fastcgi_path_info;
|
||||
|
@ -26,15 +26,15 @@ location #PATH# {
|
|||
}
|
||||
|
||||
# prevent useless logs
|
||||
location #PATH#/favicon.ico {
|
||||
location __PATH__/favicon.ico {
|
||||
access_log off;
|
||||
log_not_found off;
|
||||
}
|
||||
|
||||
# deny access to sensitive files
|
||||
location ~ ^#PATH#/(config|temp|logs)/ {
|
||||
location ~ ^__PATH__/(config|temp|logs)/ {
|
||||
deny all;
|
||||
}
|
||||
location ~ ^#PATH#/(.+/|)\. {
|
||||
location ~ ^__PATH__/(.+/|)\. {
|
||||
deny all;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
; Start a new pool named 'www'.
|
||||
; the variable $pool can we used in any directive and will be replaced by the
|
||||
; pool name ('www' here)
|
||||
[#POOLNAME#]
|
||||
[__NAMETOCHANGE__]
|
||||
|
||||
; Per pool prefix
|
||||
; It only applies on the following directives:
|
||||
|
@ -16,6 +16,12 @@
|
|||
; 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
|
||||
|
@ -24,12 +30,21 @@
|
|||
; specific port;
|
||||
; '/path/to/unix/socket' - to listen on a unix socket.
|
||||
; Note: This value is mandatory.
|
||||
listen = /var/run/php5-fpm-#POOLNAME#.sock
|
||||
listen = /var/run/php5-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)
|
||||
;listen.backlog = -1
|
||||
;listen.backlog = 128
|
||||
|
||||
; 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 = 0660
|
||||
|
||||
; List of ipv4 addresses 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
|
||||
|
@ -38,26 +53,20 @@ listen = /var/run/php5-fpm-#POOLNAME#.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
|
||||
|
||||
; 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
|
||||
; 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
|
||||
; priority = -19
|
||||
|
||||
; 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,34 +78,46 @@ 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 = 6
|
||||
pm.max_children = 10
|
||||
|
||||
; The number of child processes created on startup.
|
||||
; Note: Used only when pm is set to 'dynamic'
|
||||
; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2
|
||||
pm.start_servers = 3
|
||||
pm.start_servers = 2
|
||||
|
||||
; The desired minimum number of idle server processes.
|
||||
; Note: Used only when pm is set to 'dynamic'
|
||||
; Note: Mandatory when pm is set to 'dynamic'
|
||||
pm.min_spare_servers = 3
|
||||
pm.min_spare_servers = 1
|
||||
|
||||
; The desired maximum number of idle server processes.
|
||||
; Note: Used only when pm is set to 'dynamic'
|
||||
; Note: Mandatory when pm is set to 'dynamic'
|
||||
pm.max_spare_servers = 5
|
||||
pm.max_spare_servers = 3
|
||||
|
||||
; 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,39 +125,104 @@ pm.max_spare_servers = 5
|
|||
pm.max_requests = 500
|
||||
|
||||
; 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: ${prefix}/share/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.
|
||||
; Default Value: not set
|
||||
pm.status_path = /fpm-status
|
||||
|
||||
; Default Value: not set
|
||||
;pm.status_path = /status
|
||||
|
||||
; The ping URI to call the monitoring page of FPM. If this value is not set, no
|
||||
; URI will be recognized as a ping page. This could be used to test from outside
|
||||
; that FPM is alive and responding, or to
|
||||
|
@ -147,56 +233,115 @@ pm.status_path = /fpm-status
|
|||
; anything, but it may not be a good idea to use the .php extension or it
|
||||
; may conflict with a real PHP file.
|
||||
; Default Value: not set
|
||||
ping.path = /ping
|
||||
;ping.path = /ping
|
||||
|
||||
; This directive may be used to customize the response of a ping request. The
|
||||
; response is formatted as text/plain with a 200 response code.
|
||||
; 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 = 120s
|
||||
; 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: ouput 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)
|
||||
; %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)
|
||||
; %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'.
|
||||
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
|
||||
; 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/#POOLNAME#.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 = 1d
|
||||
|
||||
; Set open file descriptor rlimit.
|
||||
; Default Value: system defined value
|
||||
rlimit_files = 4096
|
||||
|
||||
;rlimit_files = 1024
|
||||
|
||||
; Set max core size rlimit.
|
||||
; Possible Values: 'unlimited' or an integer greater or equal to 0
|
||||
; Default Value: system defined value
|
||||
rlimit_core = 0
|
||||
|
||||
;rlimit_core = 0
|
||||
|
||||
; Chroot to this directory at the start. This value must be defined as an
|
||||
; absolute path. When this value is not set, chroot is not used.
|
||||
; Note: you can prefix with '$prefix' to chroot to the pool prefix or one
|
||||
; of its subdirectories. If the pool prefix is not set, the global prefix
|
||||
; will be used instead.
|
||||
; Note: chrooting is a great security feature and should be used whenever
|
||||
; Note: chrooting is a great security feature and should be used whenever
|
||||
; possible. However, all PHP paths will be relative to the chroot
|
||||
; (error_log, sessions.save_path, ...).
|
||||
; Default Value: not set
|
||||
;chroot =
|
||||
|
||||
;chroot =
|
||||
|
||||
; Chdir to this directory at the start.
|
||||
; Note: relative path can be used.
|
||||
; Default Value: current directory or / when chroot
|
||||
chdir = #DESTDIR#
|
||||
|
||||
chdir = __FINALPATH__
|
||||
|
||||
; 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.
|
||||
; Note: on highloaded environement, this can cause some delay in the page
|
||||
|
@ -204,6 +349,14 @@ chdir = #DESTDIR#
|
|||
; Default Value: no
|
||||
catch_workers_output = yes
|
||||
|
||||
; 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
|
||||
; exectute php code.
|
||||
; Note: set an empty value to allow all extensions.
|
||||
; Default Value: .php
|
||||
;security.limit_extensions = .php .php3 .php4 .php5
|
||||
|
||||
; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from
|
||||
; the current environment.
|
||||
; Default Value: clean env
|
||||
|
@ -217,7 +370,7 @@ catch_workers_output = yes
|
|||
; overwrite the values previously defined in the php.ini. The directives are the
|
||||
; same as the PHP SAPI:
|
||||
; php_value/php_flag - you can set classic ini defines which can
|
||||
; be overwritten from PHP call 'ini_set'.
|
||||
; be overwritten from PHP call 'ini_set'.
|
||||
; php_admin_value/php_admin_flag - these directives won't be overwritten by
|
||||
; PHP call 'ini_set'
|
||||
; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no.
|
||||
|
@ -236,8 +389,4 @@ catch_workers_output = yes
|
|||
;php_flag[display_errors] = off
|
||||
;php_admin_value[error_log] = /var/log/fpm-php.www.log
|
||||
;php_admin_flag[log_errors] = on
|
||||
;php_admin_value[memory_limit] = 32M
|
||||
|
||||
php_value[upload_max_filesize] = 10G
|
||||
php_value[post_max_size] = 10G
|
||||
php_value[mail.add_x_header] = Off
|
||||
;php_admin_value[memory_limit] = 32M
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"package_format": 1,
|
||||
"id": "roundcube",
|
||||
"name": "Roundcube",
|
||||
"packaging_format": 1,
|
||||
"description": {
|
||||
"en": "Open Source Webmail software",
|
||||
"fr": "Webmail Open Source"
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
#
|
||||
|
||||
# Roundcube version
|
||||
VERSION="1.2.3"
|
||||
VERSION="1.2.5"
|
||||
|
||||
# Package name for Roundcube dependencies
|
||||
DEPS_PKG_NAME="roundcube-deps"
|
||||
|
||||
# Roundcube complete tarball checksum
|
||||
ROUNDCUBE_SOURCE_SHA256="2df820d2ccc7bb320f854a821a1dc9983792f42a3353a1d38fe0822d94980d4d"
|
||||
ROUNDCUBE_SOURCE_SHA256="9c4d65951cc636d0e2e2296bfdf55fb53e23a4611fa96f17fb5d354db91bec38"
|
||||
|
||||
# Remote URL to fetch Roundcube source tarball
|
||||
ROUNDCUBE_SOURCE_URL="https://github.com/roundcube/roundcubemail/releases/download/${VERSION}/roundcubemail-${VERSION}.tar.gz"
|
||||
|
@ -37,9 +37,9 @@ extract_roundcube() {
|
|||
rm "$rc_tarball"
|
||||
|
||||
# apply patches
|
||||
(cd "$DESTDIR" \
|
||||
&& for p in ${PKGDIR}/patches/*.patch; do patch -p1 < $p; done) \
|
||||
|| ynh_die "Unable to apply patches to Roundcube"
|
||||
# (cd "$DESTDIR" \
|
||||
# && for p in ${PKGDIR}/patches/*.patch; do patch -p1 < $p; done) \
|
||||
# || ynh_die "Unable to apply patches to Roundcube"
|
||||
|
||||
# copy composer.json-dist for Roundcube with complete dependencies
|
||||
cp "${PKGDIR}/sources/composer.json-dist" "${DESTDIR}/composer.json-dist"
|
||||
|
@ -55,7 +55,7 @@ exec_as() {
|
|||
eval $@
|
||||
else
|
||||
# use sudo twice to be root and be allowed to use another user
|
||||
sudo sudo -u "$USER" $@
|
||||
sudo -u "$USER" $@
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ exec_composer() {
|
|||
shift 2
|
||||
|
||||
exec_as "$AS_USER" COMPOSER_HOME="${WORKDIR}/.composer" \
|
||||
php "${WORKDIR}/composer.phar" $@ \
|
||||
sudo php "${WORKDIR}/composer.phar" $@ \
|
||||
-d "${WORKDIR}" --quiet --no-interaction
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,7 @@ init_composer() {
|
|||
local AS_USER=${2:-admin}
|
||||
|
||||
# install composer
|
||||
curl -sS https://getcomposer.org/installer \
|
||||
sudo curl -sS https://getcomposer.org/installer \
|
||||
| exec_as "$AS_USER" COMPOSER_HOME="${DESTDIR}/.composer" \
|
||||
php -- --quiet --install-dir="$DESTDIR" \
|
||||
|| ynh_die "Unable to install Composer"
|
||||
|
@ -88,7 +88,7 @@ init_composer() {
|
|||
cp "${DESTDIR}/composer.json-dist" "${DESTDIR}/composer.json"
|
||||
|
||||
# update dependencies to create composer.lock
|
||||
exec_composer "$AS_USER" "$DESTDIR" install --no-dev --prefer-dist \
|
||||
exec_composer "$AS_USER" "$DESTDIR" install --no-dev \
|
||||
|| ynh_die "Unable to update Roundcube core dependencies"
|
||||
}
|
||||
|
||||
|
@ -124,3 +124,221 @@ install_carddav() {
|
|||
sudo cp "$carddav_tmp_config" "$carddav_config"
|
||||
sudo chown "${AS_USER}:" "$carddav_config"
|
||||
}
|
||||
|
||||
# Create a system user
|
||||
#
|
||||
# usage: ynh_system_user_create user_name [home_dir]
|
||||
# | arg: user_name - Name of the system user that will be create
|
||||
# | arg: home_dir - Path of the home dir for the user. Usually the final path of the app. If this argument is omitted, the user will be created without home
|
||||
ynh_system_user_create () {
|
||||
if ! ynh_system_user_exists "$1" # Check if the user exists on the system
|
||||
then # If the user doesn't exist
|
||||
if [ $# -ge 2 ]; then # If a home dir is mentioned
|
||||
user_home_dir="-d $2"
|
||||
else
|
||||
user_home_dir="--no-create-home"
|
||||
fi
|
||||
sudo useradd $user_home_dir --system --user-group $1 --shell /usr/sbin/nologin || ynh_die "Unable to create $1 system account"
|
||||
fi
|
||||
}
|
||||
|
||||
# Delete a system user
|
||||
#
|
||||
# usage: ynh_system_user_delete user_name
|
||||
# | arg: user_name - Name of the system user that will be create
|
||||
ynh_system_user_delete () {
|
||||
if ynh_system_user_exists "$1" # Check if the user exists on the system
|
||||
then
|
||||
echo "Remove the user $1" >&2
|
||||
sudo userdel $1
|
||||
else
|
||||
echo "The user $1 was not found" >&2
|
||||
fi
|
||||
}
|
||||
|
||||
# Normalize the url path syntax
|
||||
# Handle the slash at the beginning of path and its absence at ending
|
||||
# Return a normalized url path
|
||||
#
|
||||
# example: url_path=$(ynh_normalize_url_path $url_path)
|
||||
# ynh_normalize_url_path example -> /example
|
||||
# ynh_normalize_url_path /example -> /example
|
||||
# ynh_normalize_url_path /example/ -> /example
|
||||
# ynh_normalize_url_path / -> /
|
||||
#
|
||||
# usage: ynh_normalize_url_path path_to_normalize
|
||||
# | arg: url_path_to_normalize - URL path to normalize before using it
|
||||
ynh_normalize_url_path () {
|
||||
path_url=$1
|
||||
test -n "$path_url" || ynh_die "ynh_normalize_url_path expect a URL path as first argument and received nothing."
|
||||
if [ "${path_url:0:1}" != "/" ]; then # If the first character is not a /
|
||||
path_url="/$path_url" # Add / at begin of path variable
|
||||
fi
|
||||
if [ "${path_url:${#path_url}-1}" == "/" ] && [ ${#path_url} -gt 1 ]; then # If the last character is a / and that not the only character.
|
||||
path_url="${path_url:0:${#path_url}-1}" # Delete the last character
|
||||
fi
|
||||
echo $path_url
|
||||
}
|
||||
|
||||
|
||||
# Add config nginx
|
||||
ynh_nginx_config () {
|
||||
finalnginxconf="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
ynh_compare_checksum_config "$finalnginxconf" 1
|
||||
sudo cp ../conf/nginx.conf "$finalnginxconf"
|
||||
|
||||
# To avoid a break by set -u, use a void substitution ${var:-}. If the variable is not set, it's simply set with an empty variable.
|
||||
# Substitute in a nginx config file only if the variable is not empty
|
||||
if test -n "${path:-}"; then
|
||||
ynh_substitute_char "__PATH__" "$path" "$finalnginxconf"
|
||||
fi
|
||||
if test -n "${domain:-}"; then
|
||||
ynh_substitute_char "__DOMAIN__" "$domain" "$finalnginxconf"
|
||||
fi
|
||||
if test -n "${port:-}"; then
|
||||
ynh_substitute_char "__PORT__" "$port" "$finalnginxconf"
|
||||
fi
|
||||
if test -n "${app:-}"; then
|
||||
ynh_substitute_char "__NAME__" "$app" "$finalnginxconf"
|
||||
fi
|
||||
if test -n "${final_path:-}"; then
|
||||
ynh_substitute_char "__FINALPATH__" "$final_path" "$finalnginxconf"
|
||||
fi
|
||||
ynh_store_checksum_config "$finalnginxconf"
|
||||
|
||||
sudo systemctl reload nginx
|
||||
}
|
||||
|
||||
# Remove config nginx
|
||||
ynh_remove_nginx_config () {
|
||||
ynh_secure_remove "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
sudo systemctl reload nginx
|
||||
}
|
||||
|
||||
ynh_fpm_config () {
|
||||
finalphpconf="/etc/php5/fpm/pool.d/$app.conf"
|
||||
ynh_compare_checksum_config "$finalphpconf" 1
|
||||
sudo cp ../conf/php-fpm.conf "$finalphpconf"
|
||||
ynh_substitute_char "__NAMETOCHANGE__" "$app" "$finalphpconf"
|
||||
ynh_substitute_char "__FINALPATH__" "$final_path" "$finalphpconf"
|
||||
ynh_substitute_char "__USER__" "$app" "$finalphpconf"
|
||||
sudo chown root: "$finalphpconf"
|
||||
ynh_store_checksum_config "$finalphpconf"
|
||||
|
||||
if [ -e "../conf/php-fpm.ini" ]
|
||||
then
|
||||
finalphpini="/etc/php5/fpm/conf.d/20-$app.ini"
|
||||
ynh_compare_checksum_config "$finalphpini" 1
|
||||
sudo cp ../conf/php-fpm.ini "$finalphpini"
|
||||
sudo chown root: "$finalphpini"
|
||||
ynh_store_checksum_config "$finalphpini"
|
||||
fi
|
||||
|
||||
sudo systemctl reload php5-fpm
|
||||
}
|
||||
|
||||
ynh_remove_fpm_config () {
|
||||
ynh_secure_remove "/etc/php5/fpm/pool.d/$app.conf"
|
||||
ynh_secure_remove "/etc/php5/fpm/conf.d/20-$app.ini"
|
||||
sudo systemctl reload php5-fpm
|
||||
}
|
||||
|
||||
# Remove a file or a directory securely
|
||||
#
|
||||
# usage: ynh_secure_remove path_to_remove
|
||||
# | arg: path_to_remove - File or directory to remove
|
||||
ynh_secure_remove () {
|
||||
path_to_remove=$1
|
||||
forbidden_path=" \
|
||||
/var/www \
|
||||
/home/yunohost.app"
|
||||
|
||||
if [[ "$forbidden_path" =~ "$path_to_remove" \
|
||||
# Match all path or subpath in $forbidden_path
|
||||
|| "$path_to_remove" =~ ^/[[:alnum:]]+$ \
|
||||
# Match all first level path from / (Like /var, /root, etc...)
|
||||
|| "${path_to_remove:${#path_to_remove}-1}" = "/" ]]
|
||||
# Match if the path finish by /. Because it's seems there is an empty variable
|
||||
then
|
||||
echo "Avoid deleting of $path_to_remove." >&2
|
||||
else
|
||||
if [ -e "$path_to_remove" ]
|
||||
then
|
||||
sudo rm -R "$path_to_remove"
|
||||
else
|
||||
echo "$path_to_remove doesn't deleted because it's not exist." >&2
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
ynh_compare_checksum_config () {
|
||||
current_config_file=$1
|
||||
compress_backup=${2:-0} # If $2 is empty, compress_backup will set at 0
|
||||
config_file_checksum=checksum_${current_config_file//[\/ ]/_} # Replace all '/' and ' ' by '_'
|
||||
checksum_value=$(ynh_app_setting_get $app $config_file_checksum)
|
||||
if [ -n "$checksum_value" ]
|
||||
then # Proceed only if a value was stocked into the app config
|
||||
if ! echo "$checksum_value $current_config_file" | md5sum -c --status
|
||||
then # If the checksum is now different
|
||||
backup_config_file="$current_config_file.backup.$(date '+%d.%m.%y_%Hh%M,%Ss')"
|
||||
if [ compress_backup -eq 1 ]
|
||||
then
|
||||
sudo tar --create --gzip --file "$backup_config_file.tar.gz" "$current_config_file" # Backup the current config file and compress
|
||||
backup_config_file="$backup_config_file.tar.gz"
|
||||
else
|
||||
sudo cp -a "$current_config_file" "$backup_config_file" # Backup the current config file
|
||||
fi
|
||||
echo "Config file $current_config_file has been manually modified since the installation or last upgrade. So it has been duplicated in $backup_config_file" >&2
|
||||
echo "$backup_config_file" # Return the name of the backup file
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Substitute a string by another in a file
|
||||
#
|
||||
# usage: ynh_substitute_char string_to_find replace_string file_to_analyse
|
||||
# | arg: string_to_find - String to replace in the file
|
||||
# | arg: replace_string - New string that will replace
|
||||
# | arg: file_to_analyse - File where the string will be replaced.
|
||||
ynh_substitute_char () {
|
||||
delimit=@
|
||||
match_char=${1//${delimit}/"\\${delimit}"} # Escape the delimiter if it's in the string.
|
||||
replace_char=${2//${delimit}/"\\${delimit}"}
|
||||
workfile=$3
|
||||
|
||||
sudo sed --in-place "s${delimit}${match_char}${delimit}${replace_char}${delimit}g" "$workfile"
|
||||
}
|
||||
|
||||
ynh_store_checksum_config () {
|
||||
config_file_checksum=checksum_${1//[\/ ]/_} # Replace all '/' and ' ' by '_'
|
||||
ynh_app_setting_set $app $config_file_checksum $(sudo md5sum "$1" | cut -d' ' -f1)
|
||||
}
|
||||
|
||||
ynh_backup_fail_upgrade () {
|
||||
WARNING echo "Upgrade failed."
|
||||
app_bck=${app//_/-} # Replace all '_' by '-'
|
||||
if sudo yunohost backup list | grep -q $app_bck-pre-upgrade$backup_number; then # Vérifie l'existence de l'archive avant de supprimer l'application et de restaurer
|
||||
sudo yunohost app remove $app # Supprime l'application avant de la restaurer.
|
||||
sudo yunohost backup restore --ignore-hooks $app_bck-pre-upgrade$backup_number --apps $app --force # Restore the backup if upgrade failed
|
||||
ynh_die "The app was restored to the way it was before the failed upgrade."
|
||||
fi
|
||||
}
|
||||
|
||||
ynh_backup_before_upgrade () { # Backup the current version of the app, restore it if the upgrade fails
|
||||
backup_number=1
|
||||
old_backup_number=2
|
||||
app_bck=${app//_/-} # Replace all '_' by '-'
|
||||
if sudo yunohost backup list | grep -q $app_bck-pre-upgrade1; then # Vérifie l'existence d'une archive déjà numéroté à 1.
|
||||
backup_number=2 # Et passe le numéro de l'archive à 2
|
||||
old_backup_number=1
|
||||
fi
|
||||
|
||||
sudo yunohost backup create --ignore-hooks --apps $app --name $app_bck-pre-upgrade$backup_number # Créer un backup différent de celui existant.
|
||||
if [ "$?" -eq 0 ]; then # Si le backup est un succès, supprime l'archive précédente.
|
||||
if sudo yunohost backup list | grep -q $app_bck-pre-upgrade$old_backup_number; then # Vérifie l'existence de l'ancienne archive avant de la supprimer, pour éviter une erreur.
|
||||
QUIET sudo yunohost backup delete $app_bck-pre-upgrade$old_backup_number
|
||||
fi
|
||||
else # Si le backup a échoué
|
||||
ynh_die "Backup failed, the upgrade process was aborted."
|
||||
fi
|
||||
}
|
|
@ -6,21 +6,20 @@ set -eu
|
|||
# Get multi-instances specific variables
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
# Set app specific variables
|
||||
dbname=$app
|
||||
dbuser=$app
|
||||
|
||||
# Source app helpers
|
||||
. /usr/share/yunohost/helpers
|
||||
|
||||
# Retrieve app settings
|
||||
domain=$(ynh_app_setting_get "$app" domain)
|
||||
path=$(ynh_app_setting_get "$app" path)
|
||||
with_carddav=$(ynh_app_setting_get "$app" with_carddav)
|
||||
dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
|
||||
dbname=$app
|
||||
dbuser=$app
|
||||
|
||||
# Copy the app files
|
||||
DESTDIR="/var/www/$app"
|
||||
ynh_backup "$DESTDIR" "sources"
|
||||
finalpath="/var/www/$app"
|
||||
ynh_backup "$finalpath" "sources"
|
||||
|
||||
# Copy the conf files
|
||||
ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" "nginx.conf"
|
||||
|
|
|
@ -3,33 +3,37 @@
|
|||
# Exit on command errors and treat unset variables as an error
|
||||
set -eu
|
||||
|
||||
# Get multi-instances specific variables
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
# Source app helpers
|
||||
source ./_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
# Retrieve arguments
|
||||
domain=$1
|
||||
path=${2%/}
|
||||
with_carddav=$3
|
||||
domain=$YNH_APP_ARG_DOMAIN
|
||||
path=$(ynh_normalize_url_path $YNH_APP_ARG_PATH)
|
||||
with_carddav=$YNH_APP_ARG_WITH_CARDDAV
|
||||
|
||||
# Load common variables
|
||||
. ./_common.sh
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
# Check domain/path availability
|
||||
sudo yunohost app checkurl "${domain}${path}" -a "$app"
|
||||
|
||||
# Set app specific variables
|
||||
dbname=$app
|
||||
dbuser=$app
|
||||
|
||||
# Source app helpers
|
||||
. /usr/share/yunohost/helpers
|
||||
# Generate random DES key & password
|
||||
deskey=$(ynh_string_random 24)
|
||||
dbpass=$(ynh_string_random)
|
||||
|
||||
# Check domain/path availability
|
||||
sudo yunohost app checkurl "${domain}${path}" -a "$app" \
|
||||
|| exit 1
|
||||
sudo yunohost app checkurl "${domain}${path}" -a "$app"
|
||||
|
||||
# Save app settings
|
||||
ynh_app_setting_set $app domain $domain
|
||||
ynh_app_setting_set $app path $path
|
||||
ynh_app_setting_set $app with_carddav $with_carddav
|
||||
|
||||
# Check destination directory
|
||||
DESTDIR="/var/www/$app"
|
||||
[[ -d $DESTDIR ]] && ynh_die \
|
||||
"The destination directory '$DESTDIR' already exists.\
|
||||
You should safely delete it before installing this app."
|
||||
final_path=/var/www/$app
|
||||
|
||||
# FIXME: jessie-backports is needed for php-net-ldap3
|
||||
grep -q -R 'jessie-backports' /etc/apt/sources.list{,.d} || {
|
||||
|
@ -41,73 +45,65 @@ grep -q -R 'jessie-backports' /etc/apt/sources.list{,.d} || {
|
|||
ynh_package_install_from_equivs ../conf/${DEPS_PKG_NAME}.control \
|
||||
|| ynh_die "Unable to install dependencies"
|
||||
|
||||
# Create tmp directory and install app inside
|
||||
TMPDIR=$(ynh_mkdir_tmp)
|
||||
extract_roundcube "$TMPDIR"
|
||||
init_composer "$TMPDIR"
|
||||
# Create system user dedicace for this app
|
||||
ynh_system_user_create $app
|
||||
|
||||
# Generate random DES key & password
|
||||
deskey=$(ynh_string_random 24)
|
||||
dbpass=$(ynh_string_random)
|
||||
# Create final_path directory and install app inside
|
||||
sudo mkdir -p $final_path
|
||||
extract_roundcube "${final_path}"
|
||||
# Change owner by admin for execute composer
|
||||
sudo chown -R admin: "${final_path}"
|
||||
init_composer "${final_path}"
|
||||
|
||||
# Initialize database
|
||||
ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass"
|
||||
ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" \
|
||||
< "${TMPDIR}/SQL/mysql.initial.sql"
|
||||
< "${final_path}/SQL/mysql.initial.sql"
|
||||
|
||||
# Copy and set Roundcube configuration
|
||||
rc_conf="${TMPDIR}/config/config.inc.php"
|
||||
rc_conf="${final_path}/config/config.inc.php"
|
||||
cp ../conf/config.inc.php "$rc_conf"
|
||||
sed -i "s/#DESKEY#/${deskey}/g" "$rc_conf"
|
||||
sed -i "s/#DBUSER#/${dbuser}/g" "$rc_conf"
|
||||
sed -i "s/#DBPASS#/${dbpass}/g" "$rc_conf"
|
||||
sed -i "s/#DBNAME#/${dbname}/g" "$rc_conf"
|
||||
ynh_substitute_char "#DESKEY#" "$deskey" "$rc_conf"
|
||||
ynh_substitute_char "#DBUSER#" "$dbuser" "$rc_conf"
|
||||
ynh_substitute_char "#DBPASS#" "$dbpass" "$rc_conf"
|
||||
ynh_substitute_char "#DBNAME#" "$dbname" "$rc_conf"
|
||||
|
||||
# Install files and set permissions
|
||||
sudo mv "$TMPDIR" "$DESTDIR"
|
||||
sudo mkdir -p "${DESTDIR}/logs" "${DESTDIR}/temp"
|
||||
sudo chown -R www-data: "$DESTDIR"
|
||||
sudo mkdir -p "${final_path}/logs" "${final_path}/temp"
|
||||
sudo chown -R $app: "${final_path}"
|
||||
|
||||
# Install some plugins manually
|
||||
sudo cp -r ../sources/plugins/ldapAliasSync "${DESTDIR}/plugins"
|
||||
sudo chown -R www-data: "${DESTDIR}/plugins/ldapAliasSync"
|
||||
sudo cp -r ../sources/plugins/ldapAliasSync "${final_path}/plugins"
|
||||
sudo chown -R $app: "${final_path}/plugins/ldapAliasSync"
|
||||
installed_plugins=" 'ldapAliasSync',"
|
||||
|
||||
# Install additional plugins
|
||||
exec_composer www-data "$DESTDIR" require \
|
||||
exec_composer admin "$final_path" require \
|
||||
"johndoh/contextmenu dev-release-2.1" \
|
||||
"sblaisot/automatic_addressbook"
|
||||
installed_plugins+=" 'contextmenu', 'automatic_addressbook',"
|
||||
|
||||
# Instal CardDAV plugin
|
||||
if [[ $with_carddav -eq 1 ]]; then
|
||||
install_carddav "$DESTDIR" \
|
||||
install_carddav "$final_path" \
|
||||
&& installed_plugins+=" 'carddav'," \
|
||||
|| echo "Unable to install CardDAV plugin" >&2
|
||||
fi
|
||||
|
||||
# Update Roundcube configuration
|
||||
sudo sed -i "s#^\s*// installed plugins#&\n ${installed_plugins}#" \
|
||||
"${DESTDIR}/config/config.inc.php"
|
||||
"${final_path}/config/config.inc.php"
|
||||
|
||||
# Copy and set nginx configuration
|
||||
nginx_conf="/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
||||
sed -i "s@#PATH#@${path:-/}@g" ../conf/nginx.conf
|
||||
sed -i "s@#DESTDIR#@${DESTDIR}/@g" ../conf/nginx.conf
|
||||
sudo cp ../conf/nginx.conf "$nginx_conf"
|
||||
# Modify Nginx configuration file and copy it to Nginx conf directory
|
||||
ynh_nginx_config
|
||||
|
||||
# Copy and set php-fpm configuration
|
||||
phpfpm_conf="/etc/php5/fpm/pool.d/${app}.conf"
|
||||
sed -i "s@#POOLNAME#@${app}@g" ../conf/php-fpm.conf
|
||||
sed -i "s@#DESTDIR#@${DESTDIR}/@g" ../conf/php-fpm.conf
|
||||
sudo cp ../conf/php-fpm.conf "$phpfpm_conf"
|
||||
sudo chown root: $phpfpm_conf
|
||||
sudo chmod 644 $phpfpm_conf
|
||||
# Create the php-fpm pool config
|
||||
ynh_fpm_config
|
||||
|
||||
# Save app settings
|
||||
ynh_app_setting_set "$app" with_carddav "$with_carddav"
|
||||
ynh_app_setting_set "$app" mysqlpwd "$dbpass"
|
||||
|
||||
# Reload services
|
||||
sudo service php5-fpm restart || true
|
||||
sudo service nginx reload || true
|
||||
sudo systemctl restart php5-fpm
|
||||
sudo systemctl reload nginx
|
||||
|
|
|
@ -1,31 +1,36 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Load common variables and helpers
|
||||
. ./_common.sh
|
||||
|
||||
# Set app specific variables
|
||||
app=$1
|
||||
dbname=$app
|
||||
dbuser=$app
|
||||
# Exit on command errors and treat unset variables as an error
|
||||
set -u
|
||||
|
||||
if [ ! -e _common.sh ]; then
|
||||
# Get file fonction if not been to the current directory
|
||||
sudo cp ../settings/scripts/_common.sh ./_common.sh
|
||||
sudo chmod a+rx _common.sh
|
||||
fi
|
||||
# Source app helpers
|
||||
. /usr/share/yunohost/helpers
|
||||
source ./_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
# Get multi-instances specific variables
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
# Retrieve arguments
|
||||
domain=$(ynh_app_setting_get "$app" domain)
|
||||
|
||||
# Drop MySQL database and user
|
||||
dbname=$app
|
||||
dbuser=$app
|
||||
ynh_mysql_drop_db "$dbname" 2>&1 || true
|
||||
ynh_mysql_drop_user "$dbuser" 2>&1 || true
|
||||
|
||||
# Retrieve domain from app settings
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
ynh_secure_remove /var/www/$app
|
||||
ynh_secure_remove /etc/nginx/conf.d/$domain.d/$app.conf
|
||||
ynh_remove_fpm_config
|
||||
|
||||
# Delete app directory and configurations
|
||||
sudo rm -rf "/var/www/${app}"
|
||||
sudo rm -f "/etc/php5/fpm/pool.d/${app}.conf"
|
||||
[[ -n $domain ]] && sudo rm -f "/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
||||
ynh_system_user_delete $app
|
||||
|
||||
# Reload services
|
||||
sudo service php5-fpm restart || true
|
||||
sudo service nginx reload || true
|
||||
sudo systemctl reload nginx
|
||||
|
||||
# Remove app dependencies
|
||||
if ynh_package_is_installed "$DEPS_PKG_NAME"; then
|
||||
|
|
|
@ -1,3 +1,84 @@
|
|||
#!/bin/bash
|
||||
|
||||
# causes the shell to exit if any subcommand or pipeline returns a non-zero status
|
||||
set -eu
|
||||
|
||||
if [ ! -e _common.sh ]; then
|
||||
# Get file fonction if not been to the current directory
|
||||
sudo cp ../settings/scripts/_common.sh ./_common.sh
|
||||
sudo chmod a+rx _common
|
||||
fi
|
||||
# Loads the generic functions usually used in the script
|
||||
source _common.sh
|
||||
# Source app helpers
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
# Retrieve arguments
|
||||
domain=$(ynh_app_setting_get "$app" domain)
|
||||
path=$(ynh_app_setting_get "$app" path)
|
||||
with_carddav=$(ynh_app_setting_get "$app" with_carddav)
|
||||
dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
|
||||
dbname=$app
|
||||
dbuser=$app
|
||||
|
||||
# Check domain/path availability
|
||||
sudo yunohost app checkurl "${domain}${path}" -a "$app" \
|
||||
|| ynh_die "Path not available: ${domain}${path}"
|
||||
|
||||
# Check $final_path
|
||||
final_path="/var/www/${app}"
|
||||
if [ -d $final_path ]; then
|
||||
ynh_die "There is already a directory: $final_path"
|
||||
fi
|
||||
|
||||
# Check configuration files
|
||||
nginx_conf="/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
||||
if [ -f $nginx_conf ]; then
|
||||
ynh_die "The NGINX configuration already exists at '${nginx_conf}'.
|
||||
You should safely delete it before restoring this app."
|
||||
fi
|
||||
# Check configuration files php-fpm
|
||||
phpfpm_conf="/etc/php5/fpm/pool.d/${app}.conf"
|
||||
if [ -f $phpfpm_conf ]; then
|
||||
ynh_die "The PHP FPM configuration already exists at '${phpfpm_conf}'.
|
||||
You should safely delete it before restoring this app."
|
||||
fi
|
||||
|
||||
phpfpm_ini="/etc/php5/fpm/conf.d/20-${app}.ini"
|
||||
if [ -f $phpfpm_ini ]; then
|
||||
ynh_die "The PHP FPM INI configuration already exists at '${phpfpm_ini}'.
|
||||
You should safely delete it before restoring this app."
|
||||
fi
|
||||
|
||||
# Create system user dedicace for this app
|
||||
ynh_system_user_create $app
|
||||
|
||||
# Restore sources & data
|
||||
sudo cp -a "./sources" $final_path
|
||||
|
||||
# Set permissions
|
||||
sudo chown -R $app: $final_path
|
||||
|
||||
# Create and restore the database
|
||||
ynh_mysql_create_db $dbname $dbuser $dbpass
|
||||
ynh_mysql_connect_as $dbuser $dbpass $dbname < ./dump.sql
|
||||
|
||||
# Restore configuration files
|
||||
sudo cp -a ./conf/nginx.conf "${nginx_conf}"
|
||||
|
||||
# Restore php-fpm configuration files
|
||||
sudo cp -a ./conf/php-fpm.conf "${phpfpm_conf}"
|
||||
sudo cp -a ./conf/php-fpm.ini "${phpfpm_ini}"
|
||||
|
||||
# Reload service
|
||||
sudo systemctl reload php5-fpm
|
||||
sudo systemctl reload nginx
|
||||
sudo yunohost app ssowatconf
|
||||
|
||||
|
||||
|
||||
#!/bin/bash
|
||||
|
||||
# Exit on command errors and treat unset variables as an error
|
||||
|
@ -47,7 +128,7 @@ ynh_mysql_connect_as $dbuser $dbpass $dbname < ./dump.sql
|
|||
|
||||
# Fix installation directories and permissions
|
||||
sudo mkdir -p "${DESTDIR}/logs" "${DESTDIR}/temp"
|
||||
sudo chown -R www-data: "$DESTDIR"
|
||||
sudo chown -R $app: "$DESTDIR"
|
||||
|
||||
# Restore configuration files
|
||||
sudo cp -a ./nginx.conf "$nginx_conf"
|
||||
|
|
101
scripts/upgrade
101
scripts/upgrade
|
@ -1,18 +1,20 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Exit on command errors and treat unset variables as an error
|
||||
# causes the shell to exit if any subcommand or pipeline returns a non-zero status
|
||||
set -eu
|
||||
|
||||
# Get multi-instances specific variables
|
||||
if [ ! -e _common.sh ]; then
|
||||
# Get file fonction if not been to the current directory
|
||||
sudo cp ../settings/scripts/_common.sh ./_common.sh
|
||||
sudo chmod a+rx _common
|
||||
fi
|
||||
# Loads the generic functions usually used in the script
|
||||
source _common.sh
|
||||
# Source app helpers
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
# Load common variables and helpers
|
||||
. ./_common.sh
|
||||
|
||||
# Set app specific variables
|
||||
dbname=$app
|
||||
dbuser=$app
|
||||
|
||||
# Source app helpers
|
||||
. /usr/share/yunohost/helpers
|
||||
|
||||
|
@ -22,12 +24,17 @@ path=$(ynh_app_setting_get "$app" path)
|
|||
path=${path%/}
|
||||
dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
|
||||
with_carddav=$(ynh_app_setting_get "$app" with_carddav)
|
||||
dbname=$app
|
||||
dbuser=$app
|
||||
|
||||
# Check destination directory
|
||||
DESTDIR="/var/www/$app"
|
||||
[[ ! -d $DESTDIR ]] && ynh_die \
|
||||
"The destination directory '$DESTDIR' does not exist.\
|
||||
The app is not correctly installed, you should remove it first."
|
||||
ynh_backup_before_upgrade # Backup the current version of the app
|
||||
ynh_clean_setup () {
|
||||
ynh_backup_fail_upgrade # restore it if the upgrade fails
|
||||
}
|
||||
ynh_abort_if_errors # Active trap pour arrêter le script si une erreur est détectée.
|
||||
|
||||
# Init final_path, if ever it got deleted somehow
|
||||
final_path=/var/www/$app
|
||||
|
||||
# FIXME: jessie-backports is needed for php-net-ldap3
|
||||
grep -q -R 'jessie-backports' /etc/apt/sources.list{,.d} || {
|
||||
|
@ -39,9 +46,15 @@ grep -q -R 'jessie-backports' /etc/apt/sources.list{,.d} || {
|
|||
ynh_package_install_from_equivs ../conf/${DEPS_PKG_NAME}.control \
|
||||
|| ynh_die "Unable to install dependencies"
|
||||
|
||||
# Create tmp directory and install app inside
|
||||
TMPDIR=$(ynh_mkdir_tmp)
|
||||
extract_roundcube "$TMPDIR"
|
||||
# Create system user dedicace for this app
|
||||
ynh_system_user_create $app
|
||||
|
||||
# Create final_path directory and install app inside
|
||||
sudo mkdir -p $final_path
|
||||
extract_roundcube "${final_path}"
|
||||
# Change owner by admin for execute composer
|
||||
sudo chown -R admin: "${final_path}"
|
||||
init_composer "${final_path}"
|
||||
|
||||
# Install the new Roundcube version
|
||||
sudo php "${TMPDIR}/bin/installto.sh" "$DESTDIR" --force --accept \
|
||||
|
@ -52,39 +65,39 @@ rm -rf "$TMPDIR"
|
|||
deskey=$(ynh_string_random 24)
|
||||
|
||||
# Copy and set Roundcube configuration
|
||||
rc_conf="${DESTDIR}/config/config.inc.php"
|
||||
sed -i "s/#DESKEY#/${deskey}/g" ../conf/config.inc.php
|
||||
sed -i "s/#DBUSER#/${dbuser}/g" ../conf/config.inc.php
|
||||
sed -i "s/#DBPASS#/${dbpass}/g" ../conf/config.inc.php
|
||||
sed -i "s/#DBNAME#/${dbname}/g" ../conf/config.inc.php
|
||||
sudo cp ../conf/config.inc.php "$rc_conf"
|
||||
rc_conf="${final_path}/config/config.inc.php"
|
||||
cp ../conf/config.inc.php "$rc_conf"
|
||||
ynh_substitute_char "#DESKEY#" "$deskey" "$rc_conf"
|
||||
ynh_substitute_char "#DBUSER#" "$dbuser" "$rc_conf"
|
||||
ynh_substitute_char "#DBPASS#" "$dbpass" "$rc_conf"
|
||||
ynh_substitute_char "#DBNAME#" "$dbname" "$rc_conf"
|
||||
|
||||
# Fix installation directories and permissions
|
||||
sudo mkdir -p "${DESTDIR}/logs" "${DESTDIR}/temp"
|
||||
sudo chown -R www-data: "$DESTDIR"
|
||||
# Install files and set permissions
|
||||
sudo mkdir -p "${final_path}/logs" "${final_path}/temp"
|
||||
sudo chown -R $app: "${final_path}"
|
||||
|
||||
# Check if dependencies need to be updated with composer
|
||||
if [[ -f ${DESTDIR}/composer.json ]]; then
|
||||
exec_composer www-data "$DESTDIR" update --no-dev --prefer-dist
|
||||
exec_composer admin "${final_path}" update --no-dev --prefer-dist
|
||||
else
|
||||
init_composer "$DESTDIR" www-data
|
||||
init_composer "${final_path}" admin
|
||||
fi
|
||||
|
||||
# Install some plugins manually
|
||||
sudo rm -rf "${DESTDIR}/plugins/ldapAliasSync"
|
||||
sudo cp -r ../sources/plugins/ldapAliasSync "${DESTDIR}/plugins"
|
||||
sudo chown -R www-data: "${DESTDIR}/plugins/ldapAliasSync"
|
||||
sudo rm -rf "${final_path}/plugins/ldapAliasSync"
|
||||
sudo cp -r ../sources/plugins/ldapAliasSync "${final_path}/plugins"
|
||||
sudo chown -R $app: "${final_path}/plugins/ldapAliasSync"
|
||||
installed_plugins=" 'ldapAliasSync',"
|
||||
|
||||
# Update or install additional plugins
|
||||
exec_composer www-data "$DESTDIR" require \
|
||||
exec_composer admin "${final_path}" require \
|
||||
"johndoh/contextmenu dev-release-2.1" \
|
||||
"sblaisot/automatic_addressbook"
|
||||
installed_plugins+=" 'contextmenu', 'automatic_addressbook',"
|
||||
|
||||
# Guess with_carddav value if empty
|
||||
if [[ -z "${with_carddav:-}" ]]; then
|
||||
[[ -f "${DESTDIR}/plugins/carddav/config.inc.php" ]] \
|
||||
[[ -f "${final_path}/plugins/carddav/config.inc.php" ]] \
|
||||
&& with_carddav=1 \
|
||||
|| with_carddav=0
|
||||
ynh_app_setting_set "$app" with_carddav "$with_carddav"
|
||||
|
@ -92,7 +105,7 @@ fi
|
|||
|
||||
# Update or instal CardDAV plugin
|
||||
if [[ $with_carddav -eq 1 ]]; then
|
||||
install_carddav "$DESTDIR" \
|
||||
install_carddav "${final_path}" \
|
||||
&& installed_plugins+=" 'carddav'," \
|
||||
|| echo "Unable to install CardDAV plugin" >&2
|
||||
fi
|
||||
|
@ -101,20 +114,12 @@ fi
|
|||
sudo sed -i "s#^\s*// installed plugins#&\n ${installed_plugins}#" \
|
||||
"$rc_conf"
|
||||
|
||||
# Copy and set nginx configuration
|
||||
nginx_conf="/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
||||
sed -i "s@#PATH#@${path:-/}@g" ../conf/nginx.conf
|
||||
sed -i "s@#DESTDIR#@${DESTDIR}/@g" ../conf/nginx.conf
|
||||
sudo cp ../conf/nginx.conf "$nginx_conf"
|
||||
# Modify Nginx configuration file and copy it to Nginx conf directory
|
||||
ynh_nginx_config
|
||||
|
||||
# Copy and set php-fpm configuration
|
||||
phpfpm_conf="/etc/php5/fpm/pool.d/${app}.conf"
|
||||
sed -i "s@#POOLNAME#@${app}@g" ../conf/php-fpm.conf
|
||||
sed -i "s@#DESTDIR#@${DESTDIR}/@g" ../conf/php-fpm.conf
|
||||
sudo cp ../conf/php-fpm.conf "$phpfpm_conf"
|
||||
sudo chown root: $phpfpm_conf
|
||||
sudo chmod 644 $phpfpm_conf
|
||||
# Create the php-fpm pool config
|
||||
ynh_fpm_config
|
||||
|
||||
# Reload services
|
||||
sudo service php5-fpm restart || true
|
||||
sudo service nginx reload || true
|
||||
sudo systemctl restart php5-fpm
|
||||
sudo systemctl reload nginx
|
||||
|
|
|
@ -3,18 +3,33 @@
|
|||
"description": "The Roundcube Webmail suite",
|
||||
"license": "GPL-3.0+",
|
||||
"repositories": [
|
||||
{
|
||||
"type": "vcs",
|
||||
"url": "https://github.com/roundcube/Net_Sieve.git"
|
||||
},
|
||||
{
|
||||
"type": "composer",
|
||||
"url": "https://plugins.roundcube.net/"
|
||||
},
|
||||
{
|
||||
"type": "vcs",
|
||||
"url": "https://git.kolab.org/diffusion/PNL/php-net_ldap.git"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"roundcube/plugin-installer": "dev-master",
|
||||
"roundcube/net_sieve": "~1.5.0"
|
||||
"php": ">=5.4.0",
|
||||
"pear/pear-core-minimal": "~1.10.1",
|
||||
"pear/net_socket": "~1.2.1",
|
||||
"pear/auth_sasl": "~1.1.0",
|
||||
"pear/net_idna2": "~0.2.0",
|
||||
"pear/mail_mime": "~1.10.0",
|
||||
"pear/net_smtp": "~1.7.1",
|
||||
"pear/crypt_gpg": "~1.6.0",
|
||||
"pear/net_sieve": "~1.4.0",
|
||||
"roundcube/plugin-installer": "~0.1.6",
|
||||
"endroid/qrcode": "~1.6.5"
|
||||
},
|
||||
"minimum-stability": "dev"
|
||||
}
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~5.7.15"
|
||||
},
|
||||
"suggest": {
|
||||
"pear/net_ldap2": "~2.2.0 required for connecting to LDAP",
|
||||
"kolab/Net_LDAP3": "dev-master required for connecting to LDAP"
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue