mirror of
https://github.com/YunoHost-Apps/flarum_ynh.git
synced 2024-09-03 18:36:24 +02:00
Apply last example_ynh
This commit is contained in:
parent
cc55d72ef3
commit
69cd2bc8dd
17 changed files with 716 additions and 884 deletions
39
README.md
39
README.md
|
@ -1,11 +1,16 @@
|
|||
# Flarum for YunoHost
|
||||
|
||||
[![Integration level](https://dash.yunohost.org/integration/flarum.svg)](https://dash.yunohost.org/appci/app/flarum) ![](https://ci-apps.yunohost.org/ci/badges/flarum.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/flarum.maintain.svg)
|
||||
[![Install Flarum with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=flarum)
|
||||
|
||||
[![Integration level](https://ci-apps.yunohost.org/ci/logs/flarum%20%28Apps%29.svg)](https://dash.yunohost.org/appci/app/flarum) [![Flarum version](https://img.shields.io/badge/flarum-0.1.0--beta.12-green.svg)](https://github.com/flarum/flarum/releases/tag/v0.1.0-beta.12) ![PHP version](https://img.shields.io/badge/php-7.3-green.svg)
|
||||
> *This package allows you to install Flarum quickly and simply on a YunoHost server.
|
||||
If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.*
|
||||
|
||||
## Overview
|
||||
[Flarum](http://flarum.org/), an open-source forum software, packaged for [YunoHost](https://yunohost.org/), a self-hosting server operating server.
|
||||
|
||||
## Screenshots
|
||||
|
||||
![](http://flarum.org/img/screenshot_2x.png)
|
||||
|
||||
## Features
|
||||
|
@ -76,3 +81,35 @@ If you are facing an error while uploading large files into the forum, PHP may b
|
|||
In `/etc/php/*php_version*/fpm/pool.d/*app_id*.conf`, you can uncomment (remove `;` at the beginning of the line) and increase the values of `upload_max_filesize` and `post_max_size` (both values are in bytes).
|
||||
|
||||
Reload PHP-FPM with `sudo service php*php_version*-fpm reload`.
|
||||
|
||||
## Documentation
|
||||
|
||||
* Official documentation: https://flarum.org/docs/
|
||||
|
||||
## YunoHost specific features
|
||||
|
||||
#### Supported architectures
|
||||
|
||||
* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/flarum%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/flarum/)
|
||||
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/flarum%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/flarum/)
|
||||
|
||||
## Links
|
||||
|
||||
* Report a bug: https://github.com/YunoHost-Apps/flarum_ynh/issues
|
||||
* App website: https://flarum.org/
|
||||
* Upstream app repository: https://github.com/flarum/flarum
|
||||
* YunoHost website: https://yunohost.org/
|
||||
|
||||
---
|
||||
|
||||
Developer info
|
||||
----------------
|
||||
|
||||
Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/flarum_ynh/tree/testing).
|
||||
|
||||
To try the testing branch, please proceed like that.
|
||||
```
|
||||
sudo yunohost app install https://github.com/YunoHost-Apps/flarum_ynh/tree/testing --debug
|
||||
or
|
||||
sudo yunohost app upgrade flarum -u https://github.com/YunoHost-Apps/flarum_ynh/tree/testing --debug
|
||||
```
|
||||
|
|
|
@ -20,21 +20,13 @@
|
|||
upgrade=1
|
||||
backup_restore=1
|
||||
multi_instance=1
|
||||
incorrect_path=1
|
||||
# This test is no longer necessary since the version 2.7 (PR: https://github.com/YunoHost/yunohost/pull/304), you can still do it if your app could be installed with this version.
|
||||
# incorrect_path=1
|
||||
port_already_use=0
|
||||
change_url=1
|
||||
;;; Levels
|
||||
Level 1=auto
|
||||
Level 2=auto
|
||||
Level 3=auto
|
||||
# Level 4 : HTTP Auth included with the extension tituspijean/flarum-ext-auth-ssowat
|
||||
Level 4=1
|
||||
# If the level 5 (Package linter) is forced to 1. Please add justifications here.
|
||||
Level 5=auto
|
||||
Level 6=auto
|
||||
Level 7=auto
|
||||
Level 8=0
|
||||
Level 9=0
|
||||
Level 10=0
|
||||
;;; Options
|
||||
#Email=
|
||||
#Notification=none
|
||||
|
|
|
@ -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)
|
||||
[__USER__]
|
||||
|
||||
; 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 = www-data
|
||||
|
||||
; The address on which to accept FastCGI requests.
|
||||
; Valid syntaxes are:
|
||||
; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific address on
|
||||
; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on
|
||||
; a specific port;
|
||||
; 'port' - to listen on a TCP socket to all addresses on a
|
||||
; specific port;
|
||||
; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
|
||||
; a specific port;
|
||||
; 'port' - to listen on a TCP socket to all addresses
|
||||
; (IPv6 and IPv4-mapped) on a specific port;
|
||||
; '/path/to/unix/socket' - to listen on a unix socket.
|
||||
; Note: This value is mandatory.
|
||||
listen = /var/run/php-fpm-__USER__.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 = __USER__
|
||||
listen.group = www-data
|
||||
listen.mode = 0660
|
||||
; 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/php-fpm-__USER__.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 = __USER__
|
||||
listen.group = www-data
|
||||
listen.mode = 0660
|
||||
; 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 = __USER__
|
||||
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 = 6
|
||||
|
||||
|
@ -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 = 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: /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 = 600s
|
||||
; 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/__USER__.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 = 600s
|
|||
; 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/__USER__.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 = 600s
|
||||
|
||||
; Set open file descriptor rlimit.
|
||||
; Default Value: system defined value
|
||||
|
@ -204,6 +367,23 @@ chdir = __FINALPATH__
|
|||
; 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
|
||||
|
@ -239,14 +419,14 @@ catch_workers_output = yes
|
|||
;php_admin_value[memory_limit] = 32M
|
||||
|
||||
; Common values to change to increase file upload limit
|
||||
;php_value[upload_max_filesize] = 50M
|
||||
;php_value[post_max_size] = 50M
|
||||
;php_value[mail.add_x_header] = Off
|
||||
; 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_value[max_execution_time] = 600
|
||||
php_value[max_input_time] = 600
|
||||
php_value[memory_limit] = 256M
|
||||
;php_value[short_open_tag] = On
|
||||
; 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
|
||||
|
||||
env[COMPOSER_HOME] = __FINALPATH__/.composer
|
||||
|
|
46
issue_template.md
Normal file
46
issue_template.md
Normal file
|
@ -0,0 +1,46 @@
|
|||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us debug, it would be nice to fill the template as much as you can to help us, help you and help us all.
|
||||
|
||||
---
|
||||
|
||||
**How to post a meaningful bug report**
|
||||
1. *Read this whole template first.*
|
||||
2. *Determine if you are on the right place:*
|
||||
- *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change url...), you are on the right place!*
|
||||
- *Otherwise, the issue may be due to Flarum itself. Refer to its documentation or repository for help.*
|
||||
- *If you have a doubt, post here, we will figure it out together.*
|
||||
3. *Delete the italic comments as you write over them below, and remove this guide.*
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
*A clear and concise description of what the bug is.*
|
||||
|
||||
**Versions**
|
||||
- Hardware: *VPS bought online / Old laptop or computer / Raspberry Pi at home / Internet Cube with VPN / Other ARM board / ...*
|
||||
- YunoHost version: x.x.x
|
||||
- I have access to my server: *Through SSH | through the webadmin | direct access via keyboard / screen | ...*
|
||||
- Are you in a special context or did you perform some particular tweaking on your YunoHost instance ?: *no / yes*
|
||||
- If yes, please explain:
|
||||
- Using, or trying to install package version/branch:
|
||||
- If upgrading, current package version: *can be found in the admin, or with `yunohost app info $app_id`*
|
||||
|
||||
**To Reproduce**
|
||||
*Steps to reproduce the behavior.*
|
||||
- *If you performed a command from the CLI, the command itself is enough. For example:*
|
||||
```sh
|
||||
sudo yunohost app install flarum
|
||||
```
|
||||
- *If you used the webadmin, please perform the equivalent command from the CLI first.*
|
||||
- *If the error occurs in your browser, explain what you did:*
|
||||
1. *Go to '...'*
|
||||
2. *Click on '....'*
|
||||
3. *Scroll down to '....'*
|
||||
4. *See error*
|
||||
|
||||
**Expected behavior**
|
||||
*A clear and concise description of what you expected to happen. You can remove this section if the command above is enough to understand your intent.*
|
||||
|
||||
**Logs**
|
||||
*After a failed command, YunoHost makes the log available to you, but also to others, thanks to `yunohost log display [log name] --share`. The actual command, with the correct log name, is displayed at the end of the failed attempt in the CLI. Execute it and copy here the share link it outputs.*
|
||||
*If applicable and useful, add screenshots to help explain your problem.*
|
|
@ -7,23 +7,25 @@
|
|||
"fr": "Un forum de nouvelle génération, simplement.",
|
||||
"de": "Forum der nächsten Generation leicht gemacht."
|
||||
},
|
||||
"version": "0.1.0-beta.13~ynh1",
|
||||
"url": "http://flarum.org/",
|
||||
"license": "MIT",
|
||||
"version": "0.1.0-beta.13~ynh1",
|
||||
"maintainer": {
|
||||
"name": "tituspijean",
|
||||
"email": "tituspijean@outlook.com"
|
||||
},
|
||||
"requirements": {
|
||||
"yunohost": ">= 3.7.0"
|
||||
"yunohost": ">= 3.8.1"
|
||||
},
|
||||
"multi_instance": true,
|
||||
"services": [
|
||||
"nginx",
|
||||
"php7.0-fpm",
|
||||
"mysql"
|
||||
],
|
||||
"arguments": {
|
||||
"install": [{
|
||||
"install" : [
|
||||
{
|
||||
"name": "domain",
|
||||
"type": "display_text",
|
||||
"ask": {
|
||||
|
@ -32,12 +34,12 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"name": "domain",
|
||||
"type": "domain",
|
||||
"ask": {
|
||||
"en": "Choose a domain name for Flarum",
|
||||
"fr": "Choisissez un nom de domaine pour Flarum",
|
||||
"de": "Wählen einen Domain-Namen für Flarum"
|
||||
"name": "domain",
|
||||
"type": "domain",
|
||||
"ask": {
|
||||
"en": "Choose a domain name for Flarum",
|
||||
"fr": "Choisissez un nom de domaine pour Flarum",
|
||||
"de": "Wählen einen Domain-Namen für Flarum"
|
||||
},
|
||||
"example": "example.com"
|
||||
},
|
||||
|
|
18
pull_request_template.md
Normal file
18
pull_request_template.md
Normal file
|
@ -0,0 +1,18 @@
|
|||
## Problem
|
||||
- *Description of why you made this PR*
|
||||
|
||||
## Solution
|
||||
- *And how do you fix that problem*
|
||||
|
||||
## PR Status
|
||||
- [ ] Code finished.
|
||||
- [ ] Tested with Package_check.
|
||||
- [ ] Fix or enhancement tested.
|
||||
- [ ] Upgrade from last version tested.
|
||||
- [ ] Can be reviewed and tested.
|
||||
|
||||
## Package_check results
|
||||
---
|
||||
*If you have access to [App Continuous Integration for packagers](https://yunohost.org/#/packaging_apps_ci) you can provide a link to the package_check results like below, replacing '-NUM-' in this link by the PR number and USERNAME by your username on the ci-apps-dev. Or you provide a screenshot or a pastebin of the results*
|
||||
|
||||
[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/flarum_ynh%20PR-NUM-%20(USERNAME)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/flarum_ynh%20PR-NUM-%20(USERNAME)/)
|
|
@ -4,10 +4,12 @@
|
|||
|
||||
# dependencies used by the app
|
||||
pkg_dependencies=""
|
||||
extra_pkg_dependencies="php7.3-curl php7.3-dom php7.3-gd php7.3-json php7.3-mbstring php7.3-pdo-mysql php7.3-tokenizer php7.3-zip"
|
||||
|
||||
YNH_PHP_VERSION="7.3"
|
||||
|
||||
extra_php_dependencies="php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-dom php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-json php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-pdo-mysql php${YNH_PHP_VERSION}-tokenizer php${YNH_PHP_VERSION}-zip"
|
||||
|
||||
# Version numbers
|
||||
php_version="7.3"
|
||||
project_version="~0.1.0-beta.13"
|
||||
core_version="~0.1.0-beta.13"
|
||||
ssowat_version="dev-0.1.0-beta.13"
|
||||
|
|
|
@ -15,7 +15,6 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
|
||||
ynh_clean_setup () {
|
||||
### Remove this function if there's nothing to clean before calling the remove script.
|
||||
true
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
|
@ -24,55 +23,55 @@ ynh_abort_if_errors
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..." --time --weight=1
|
||||
ynh_print_info --message="Loading installation settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||
|
||||
#=================================================
|
||||
# STANDARD BACKUP STEPS
|
||||
# DECLARE DATA AND CONF FILES TO BACKUP
|
||||
#=================================================
|
||||
ynh_print_info --message="Declaring files to be backed up..."
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up the main app directory..." --time --weight=1
|
||||
|
||||
ynh_backup --src_path="$final_path"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up nginx web server configuration..." --time --weight=1
|
||||
|
||||
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up php-fpm configuration..." --time --weight=1
|
||||
|
||||
ynh_backup --src_path="/etc/php/${php_version}/fpm/pool.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE MYSQL DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up the MySQL database..." --time --weight=1
|
||||
|
||||
ynh_mysql_dump_db --database="$db_name" > db.sql
|
||||
ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC BACKUP
|
||||
#=================================================
|
||||
# BACKUP LOGROTATE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up logrotate configuration..." --time --weight=1
|
||||
|
||||
ynh_backup --src_path="/etc/logrotate.d/$app"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE MYSQL DATABASE
|
||||
#=================================================
|
||||
ynh_print_info --message="Backing up the MySQL database..."
|
||||
|
||||
ynh_mysql_dump_db --database="$db_name" > db.sql
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --time --last
|
||||
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|
||||
|
|
|
@ -24,7 +24,7 @@ app=$YNH_APP_INSTANCE_NAME
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..." --time --weight=1
|
||||
ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||
|
||||
# Needed for helper "ynh_add_nginx_config"
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
|
@ -34,6 +34,23 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
|||
#db_user=$db_name
|
||||
#db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
|
||||
|
||||
#=================================================
|
||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up the app before changing its url (may take a while)..."
|
||||
|
||||
# Backup the current version of the app
|
||||
ynh_backup_before_upgrade
|
||||
ynh_clean_setup () {
|
||||
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
|
||||
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||
|
||||
# restore it if the upgrade fails
|
||||
ynh_restore_upgradebackup
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# CHECK WHICH PARTS SHOULD BE CHANGED
|
||||
#=================================================
|
||||
|
@ -55,14 +72,14 @@ fi
|
|||
#=================================================
|
||||
# STOP SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping a systemd service..." --time --weight=1
|
||||
ynh_script_progression --message="Stopping a systemd service..." --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# MODIFY URL IN NGINX CONF
|
||||
#=================================================
|
||||
ynh_script_progression --message="Updating nginx web server configuration..." --time --weight=1
|
||||
ynh_script_progression --message="Updating nginx web server configuration..." --weight=1
|
||||
|
||||
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
||||
|
||||
|
@ -118,7 +135,7 @@ fi
|
|||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading nginx web server..." --time --weight=1
|
||||
ynh_script_progression --message="Reloading nginx web server..." --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
|
@ -126,4 +143,4 @@ ynh_systemd_action --service_name=nginx --action=reload
|
|||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Change of URL completed for $app" --time --last
|
||||
ynh_script_progression --message="Change of URL completed for $app" --last
|
||||
|
|
|
@ -1,334 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# From PR https://github.com/YunoHost/yunohost/pull/881
|
||||
# _ynh_install_app_dependencies has a different name to not be override by source /usr/share/yunohost/helpers
|
||||
|
||||
# Define and install dependencies with a equivs control file
|
||||
#
|
||||
# This helper can/should only be called once per app
|
||||
#
|
||||
# example : _ynh_install_app_dependencies dep1 dep2 "dep3|dep4|dep5"
|
||||
#
|
||||
# usage: _ynh_install_app_dependencies dep [dep [...]]
|
||||
# | arg: dep - the package name to install in dependence. Writing "dep3|dep4|dep5" can be used to specify alternatives. For example : dep1 dep2 "dep3|dep4|dep5" will require to install dep1 and dep 2 and (dep3 or dep4 or dep5).
|
||||
#
|
||||
# Requires YunoHost version 2.6.4 or higher.
|
||||
_ynh_install_app_dependencies () {
|
||||
local dependencies=$@
|
||||
# Add a comma for each space between packages. But not add a comma if the space separate a version specification. (See below)
|
||||
dependencies="$(echo "$dependencies" | sed 's/\([^\<=\>]\)\ \([^(]\)/\1, \2/g')"
|
||||
local dependencies=${dependencies//|/ | }
|
||||
local manifest_path="../manifest.json"
|
||||
if [ ! -e "$manifest_path" ]; then
|
||||
manifest_path="../settings/manifest.json" # Into the restore script, the manifest is not at the same place
|
||||
fi
|
||||
|
||||
local version=$(grep '\"version\": ' "$manifest_path" | cut -d '"' -f 4) # Retrieve the version number in the manifest file.
|
||||
if [ ${#version} -eq 0 ]; then
|
||||
version="1.0"
|
||||
fi
|
||||
local dep_app=${app//_/-} # Replace all '_' by '-'
|
||||
|
||||
# Handle specific versions
|
||||
if [[ "$dependencies" =~ [\<=\>] ]]
|
||||
then
|
||||
# Replace version specifications by relationships syntax
|
||||
# https://www.debian.org/doc/debian-policy/ch-relationships.html
|
||||
# Sed clarification
|
||||
# [^(\<=\>] ignore if it begins by ( or < = >. To not apply twice.
|
||||
# [\<=\>] matches < = or >
|
||||
# \+ matches one or more occurence of the previous characters, for >= or >>.
|
||||
# [^,]\+ matches all characters except ','
|
||||
# Ex: 'package>=1.0' will be replaced by 'package (>= 1.0)'
|
||||
dependencies="$(echo "$dependencies" | sed 's/\([^(\<=\>]\)\([\<=\>]\+\)\([^,]\+\)/\1 (\2 \3)/g')"
|
||||
fi
|
||||
|
||||
#
|
||||
# Epic ugly hack to fix the goddamn dependency nightmare of sury
|
||||
# Sponsored by the "Djeezusse Fokin Kraiste Why Do Adminsys Has To Be So Fucking Complicated I Should Go Grow Potatoes Instead Of This Shit" collective
|
||||
# https://github.com/YunoHost/issues/issues/1407
|
||||
#
|
||||
# If we require to install php dependency
|
||||
if echo $dependencies | grep -q 'php';
|
||||
then
|
||||
# And we have packages from sury installed (7.0.33-10+weirdshiftafter instead of 7.0.33-0 on debian)
|
||||
if dpkg --list | grep "php7.0" | grep -q -v "7.0.33-0+deb9"
|
||||
then
|
||||
# And sury ain't already installed
|
||||
if ! grep -nrq "sury" /etc/apt/sources.list*
|
||||
then
|
||||
# Re-add sury
|
||||
ynh_install_extra_repo --repo="https://packages.sury.org/php/ $(lsb_release -sc) main" --key="https://packages.sury.org/php/apt.gpg" --name=extra_php_version
|
||||
|
||||
# Pin this sury repository to prevent sury of doing shit
|
||||
ynh_pin_repo --package="*" --pin="origin \"packages.sury.org\"" --priority=200 --name=extra_php_version
|
||||
ynh_pin_repo --package="php7.0*" --pin="origin \"packages.sury.org\"" --priority=600 --name=extra_php_version --append
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
cat > /tmp/${dep_app}-ynh-deps.control << EOF # Make a control file for equivs-build
|
||||
Section: misc
|
||||
Priority: optional
|
||||
Package: ${dep_app}-ynh-deps
|
||||
Version: ${version}
|
||||
Depends: ${dependencies}
|
||||
Architecture: all
|
||||
Description: Fake package for ${app} (YunoHost app) dependencies
|
||||
This meta-package is only responsible of installing its dependencies.
|
||||
EOF
|
||||
ynh_package_install_from_equivs /tmp/${dep_app}-ynh-deps.control \
|
||||
|| ynh_die --message="Unable to install dependencies" # Install the fake package and its dependencies
|
||||
rm /tmp/${dep_app}-ynh-deps.control
|
||||
ynh_app_setting_set --app=$app --key=apt_dependencies --value="$dependencies"
|
||||
}
|
||||
|
||||
# Add dependencies to install with _ynh_install_app_dependencies
|
||||
#
|
||||
# [internal]
|
||||
#
|
||||
# usage: ynh_add_app_dependencies --package=phpversion [--replace]
|
||||
# | arg: -p, --package - Packages to add as dependencies for the app.
|
||||
# | arg: -r, --replace - Replace dependencies instead of adding to existing ones.
|
||||
ynh_add_app_dependencies () {
|
||||
# Declare an array to define the options of this helper.
|
||||
local legacy_args=pr
|
||||
declare -Ar args_array=( [p]=package= [r]=replace)
|
||||
local package
|
||||
local replace
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
replace=${replace:-0}
|
||||
|
||||
local current_dependencies=""
|
||||
if [ $replace -eq 0 ]
|
||||
then
|
||||
local dep_app=${app//_/-} # Replace all '_' by '-'
|
||||
if ynh_package_is_installed --package="${dep_app}-ynh-deps"
|
||||
then
|
||||
current_dependencies="$(dpkg-query --show --showformat='${Depends}' ${dep_app}-ynh-deps) "
|
||||
fi
|
||||
|
||||
current_dependencies=${current_dependencies// | /|}
|
||||
fi
|
||||
|
||||
_ynh_install_app_dependencies "${current_dependencies}${package}"
|
||||
}
|
||||
|
||||
# Install packages from an extra repository properly.
|
||||
#
|
||||
# usage: ynh_install_extra_app_dependencies --repo="repo" --package="dep1 dep2" [--key=key_url] [--name=name]
|
||||
# | arg: -r, --repo - Complete url of the extra repository.
|
||||
# | arg: -p, --package - The packages to install from this extra repository
|
||||
# | arg: -k, --key - url to get the public key.
|
||||
# | arg: -n, --name - Name for the files for this repo, $app as default value.
|
||||
ynh_install_extra_app_dependencies () {
|
||||
# Declare an array to define the options of this helper.
|
||||
local legacy_args=rpkn
|
||||
declare -Ar args_array=( [r]=repo= [p]=package= [k]=key= [n]=name= )
|
||||
local repo
|
||||
local package
|
||||
local key
|
||||
local name
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
name="${name:-$app}"
|
||||
key=${key:-}
|
||||
|
||||
# Set a key only if asked
|
||||
if [ -n "$key" ]
|
||||
then
|
||||
key="--key=$key"
|
||||
fi
|
||||
# Add an extra repository for those packages
|
||||
ynh_install_extra_repo --repo="$repo" $key --priority=995 --name=$name
|
||||
|
||||
# Install requested dependencies from this extra repository.
|
||||
ynh_add_app_dependencies --package="$package"
|
||||
|
||||
# Remove this extra repository after packages are installed
|
||||
ynh_remove_extra_repo --name=$app
|
||||
}
|
||||
|
||||
# Add an extra repository correctly, pin it and get the key.
|
||||
#
|
||||
# [internal]
|
||||
#
|
||||
# usage: ynh_install_extra_repo --repo="repo" [--key=key_url] [--priority=priority_value] [--name=name] [--append]
|
||||
# | arg: -r, --repo - Complete url of the extra repository.
|
||||
# | arg: -k, --key - url to get the public key.
|
||||
# | arg: -p, --priority - Priority for the pin
|
||||
# | arg: -n, --name - Name for the files for this repo, $app as default value.
|
||||
# | arg: -a, --append - Do not overwrite existing files.
|
||||
ynh_install_extra_repo () {
|
||||
# Declare an array to define the options of this helper.
|
||||
local legacy_args=rkpna
|
||||
declare -Ar args_array=( [r]=repo= [k]=key= [p]=priority= [n]=name= [a]=append )
|
||||
local repo
|
||||
local key
|
||||
local priority
|
||||
local name
|
||||
local append
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
name="${name:-$app}"
|
||||
append=${append:-0}
|
||||
key=${key:-}
|
||||
priority=${priority:-}
|
||||
|
||||
if [ $append -eq 1 ]
|
||||
then
|
||||
append="--append"
|
||||
wget_append="tee -a"
|
||||
else
|
||||
append=""
|
||||
wget_append="tee"
|
||||
fi
|
||||
|
||||
# Split the repository into uri, suite and components.
|
||||
# Remove "deb " at the beginning of the repo.
|
||||
repo="${repo#deb }"
|
||||
|
||||
# Get the uri
|
||||
local uri="$(echo "$repo" | awk '{ print $1 }')"
|
||||
|
||||
# Get the suite
|
||||
local suite="$(echo "$repo" | awk '{ print $2 }')"
|
||||
|
||||
# Get the components
|
||||
local component="${repo##$uri $suite }"
|
||||
|
||||
# Add the repository into sources.list.d
|
||||
ynh_add_repo --uri="$uri" --suite="$suite" --component="$component" --name="$name" $append
|
||||
|
||||
# Pin the new repo with the default priority, so it won't be used for upgrades.
|
||||
# Build $pin from the uri without http and any sub path
|
||||
local pin="${uri#*://}"
|
||||
pin="${pin%%/*}"
|
||||
# Set a priority only if asked
|
||||
if [ -n "$priority" ]
|
||||
then
|
||||
priority="--priority=$priority"
|
||||
fi
|
||||
ynh_pin_repo --package="*" --pin="origin \"$pin\"" $priority --name="$name" $append
|
||||
|
||||
# Get the public key for the repo
|
||||
if [ -n "$key" ]
|
||||
then
|
||||
mkdir -p "/etc/apt/trusted.gpg.d"
|
||||
wget -q "$key" -O - | gpg --dearmor | $wget_append /etc/apt/trusted.gpg.d/$name.gpg > /dev/null
|
||||
fi
|
||||
|
||||
# Update the list of package with the new repo
|
||||
ynh_package_update
|
||||
}
|
||||
|
||||
# Remove an extra repository and the assiociated configuration.
|
||||
#
|
||||
# [internal]
|
||||
#
|
||||
# usage: ynh_remove_extra_repo [--name=name]
|
||||
# | arg: -n, --name - Name for the files for this repo, $app as default value.
|
||||
ynh_remove_extra_repo () {
|
||||
# Declare an array to define the options of this helper.
|
||||
local legacy_args=n
|
||||
declare -Ar args_array=( [n]=name= )
|
||||
local name
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
name="${name:-$app}"
|
||||
|
||||
ynh_secure_remove "/etc/apt/sources.list.d/$name.list"
|
||||
ynh_secure_remove "/etc/apt/preferences.d/$name"
|
||||
ynh_secure_remove "/etc/apt/trusted.gpg.d/$name.gpg"
|
||||
ynh_secure_remove "/etc/apt/trusted.gpg.d/$name.asc"
|
||||
|
||||
# Update the list of package to exclude the old repo
|
||||
ynh_package_update
|
||||
}
|
||||
|
||||
# Add a repository.
|
||||
#
|
||||
# [internal]
|
||||
#
|
||||
# usage: ynh_add_repo --uri=uri --suite=suite --component=component [--name=name] [--append]
|
||||
# | arg: -u, --uri - Uri of the repository.
|
||||
# | arg: -s, --suite - Suite of the repository.
|
||||
# | arg: -c, --component - Component of the repository.
|
||||
# | arg: -n, --name - Name for the files for this repo, $app as default value.
|
||||
# | arg: -a, --append - Do not overwrite existing files.
|
||||
#
|
||||
# Example for a repo like deb http://forge.yunohost.org/debian/ stretch stable
|
||||
# uri suite component
|
||||
# ynh_add_repo --uri=http://forge.yunohost.org/debian/ --suite=stretch --component=stable
|
||||
#
|
||||
ynh_add_repo () {
|
||||
# Declare an array to define the options of this helper.
|
||||
local legacy_args=uscna
|
||||
declare -Ar args_array=( [u]=uri= [s]=suite= [c]=component= [n]=name= [a]=append )
|
||||
local uri
|
||||
local suite
|
||||
local component
|
||||
local name
|
||||
local append
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
name="${name:-$app}"
|
||||
append=${append:-0}
|
||||
|
||||
if [ $append -eq 1 ]
|
||||
then
|
||||
append="tee -a"
|
||||
else
|
||||
append="tee"
|
||||
fi
|
||||
|
||||
mkdir -p "/etc/apt/sources.list.d"
|
||||
# Add the new repo in sources.list.d
|
||||
echo "deb $uri $suite $component" \
|
||||
| $append "/etc/apt/sources.list.d/$name.list"
|
||||
}
|
||||
|
||||
# Pin a repository.
|
||||
#
|
||||
# [internal]
|
||||
#
|
||||
# usage: ynh_pin_repo --package=packages --pin=pin_filter [--priority=priority_value] [--name=name] [--append]
|
||||
# | arg: -p, --package - Packages concerned by the pin. Or all, *.
|
||||
# | arg: -i, --pin - Filter for the pin.
|
||||
# | arg: -p, --priority - Priority for the pin
|
||||
# | arg: -n, --name - Name for the files for this repo, $app as default value.
|
||||
# | arg: -a, --append - Do not overwrite existing files.
|
||||
#
|
||||
# See https://manpages.debian.org/stretch/apt/apt_preferences.5.en.html for information about pinning.
|
||||
#
|
||||
ynh_pin_repo () {
|
||||
# Declare an array to define the options of this helper.
|
||||
local legacy_args=pirna
|
||||
declare -Ar args_array=( [p]=package= [i]=pin= [r]=priority= [n]=name= [a]=append )
|
||||
local package
|
||||
local pin
|
||||
local priority
|
||||
local name
|
||||
local append
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
package="${package:-*}"
|
||||
priority=${priority:-50}
|
||||
name="${name:-$app}"
|
||||
append=${append:-0}
|
||||
|
||||
if [ $append -eq 1 ]
|
||||
then
|
||||
append="tee -a"
|
||||
else
|
||||
append="tee"
|
||||
fi
|
||||
|
||||
mkdir -p "/etc/apt/preferences.d"
|
||||
echo "Package: $package
|
||||
Pin: $pin
|
||||
Pin-Priority: $priority
|
||||
" \
|
||||
| $append "/etc/apt/preferences.d/$name"
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Execute a command with Composer
|
||||
#
|
||||
# usage: ynh_composer_exec [--user=$app] [--phpversion=phpversion] [--workdir=$final_path] --commands="commands"
|
||||
# | arg: -u, --user - User to perform the action with
|
||||
# | arg: -v, --phpversion - PHP version to use with composer
|
||||
# | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path.
|
||||
# | arg: -c, --commands - Commands to execute.
|
||||
ynh_composer_exec () {
|
||||
# Declare an array to define the options of this helper.
|
||||
local legacy_args=uvwc
|
||||
declare -Ar args_array=( [u]=user= [v]=phpversion= [w]=workdir= [c]=commands= )
|
||||
local user
|
||||
local phpversion
|
||||
local workdir
|
||||
local commands
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
user="${user:-$app}"
|
||||
phpversion="${phpversion:-7.0}"
|
||||
workdir="${workdir:-$final_path}"
|
||||
|
||||
exec_as $user COMPOSER_HOME="$workdir/.composer" \
|
||||
php${phpversion} "$workdir/composer.phar" $commands \
|
||||
-d "$workdir" --no-interaction --ansi
|
||||
}
|
||||
|
||||
# Install and initialize Composer in the given directory
|
||||
#
|
||||
# usage: ynh_install_composer [--user=$app] [--phpversion=phpversion] [--workdir=$final_path] [--install_args="--optimize-autoloader"]
|
||||
# | arg: -u, --user - User to perform the action with
|
||||
# | arg: -v, --phpversion - PHP version to use with composer
|
||||
# | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path.
|
||||
# | arg: -a, --install_args - Additional arguments provided to the composer install. Argument --no-dev already included
|
||||
ynh_install_composer () {
|
||||
# Declare an array to define the options of this helper.
|
||||
local legacy_args=uvwa
|
||||
declare -Ar args_array=( [u]=user= [v]=phpversion= [w]=workdir= [a]=install_args=)
|
||||
local user
|
||||
local phpversion
|
||||
local workdir
|
||||
local install_args
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
user="${user:-$app}"
|
||||
workdir="${workdir:-$final_path}"
|
||||
phpversion="${phpversion:-7.0}"
|
||||
install_args="${install_args:-}"
|
||||
|
||||
curl -sS https://getcomposer.org/installer \
|
||||
| exec_as $user COMPOSER_HOME="$workdir/.composer" \
|
||||
php${phpversion} -- --install-dir="$workdir" \
|
||||
|| ynh_die "Unable to install Composer."
|
||||
|
||||
# update dependencies to create composer.lock
|
||||
#ynh_composer_exec --user=$user --phpversion="${phpversion}" --workdir="$workdir" --commands="install --no-dev $install_args" \
|
||||
# || ynh_die "Unable to update core dependencies with Composer."
|
||||
}
|
53
scripts/experimental_helpers/ynh_composer__2
Normal file
53
scripts/experimental_helpers/ynh_composer__2
Normal file
|
@ -0,0 +1,53 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Execute a command with Composer
|
||||
#
|
||||
# usage: ynh_composer_exec [--phpversion=phpversion] [--workdir=$final_path] --commands="commands"
|
||||
# | arg: -v, --phpversion - PHP version to use with composer
|
||||
# | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path.
|
||||
# | arg: -c, --commands - Commands to execute.
|
||||
ynh_composer_exec () {
|
||||
# Declare an array to define the options of this helper.
|
||||
local legacy_args=vwc
|
||||
declare -Ar args_array=( [v]=phpversion= [w]=workdir= [c]=commands= )
|
||||
local phpversion
|
||||
local workdir
|
||||
local commands
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
workdir="${workdir:-$final_path}"
|
||||
phpversion="${phpversion:-$YNH_PHP_VERSION}"
|
||||
|
||||
COMPOSER_HOME="$workdir/.composer" \
|
||||
php${phpversion} "$workdir/composer.phar" $commands \
|
||||
-d "$workdir" --no-interaction
|
||||
}
|
||||
|
||||
# Install and initialize Composer in the given directory
|
||||
#
|
||||
# usage: ynh_install_composer [--phpversion=phpversion] [--workdir=$final_path] [--install_args="--optimize-autoloader"]
|
||||
# | arg: -v, --phpversion - PHP version to use with composer
|
||||
# | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path.
|
||||
# | arg: -a, --install_args - Additional arguments provided to the composer install. Argument --no-dev already include
|
||||
ynh_install_composer () {
|
||||
# Declare an array to define the options of this helper.
|
||||
local legacy_args=vwa
|
||||
declare -Ar args_array=( [v]=phpversion= [w]=workdir= [a]=install_args=)
|
||||
local phpversion
|
||||
local workdir
|
||||
local install_args
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
workdir="${workdir:-$final_path}"
|
||||
phpversion="${phpversion:-$YNH_PHP_VERSION}"
|
||||
install_args="${install_args:-}"
|
||||
|
||||
curl -sS https://getcomposer.org/installer \
|
||||
| COMPOSER_HOME="$workdir/.composer" \
|
||||
php${phpversion} -- --install-dir="$workdir" \
|
||||
|| ynh_die "Unable to install Composer."
|
||||
|
||||
# update dependencies to create composer.lock
|
||||
ynh_composer_exec --phpversion="${phpversion}" --workdir="$workdir" --commands="install --no-dev $install_args" \
|
||||
|| ynh_die "Unable to update core dependencies with Composer."
|
||||
}
|
|
@ -1,77 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Install another version of php.
|
||||
#
|
||||
# usage: ynh_install_php --phpversion=phpversion [--package=packages]
|
||||
# | arg: -v, --phpversion - Version of php to install. Can be one of 7.1, 7.2 or 7.3
|
||||
# | arg: -p, --package - Additionnal php packages to install
|
||||
ynh_install_php () {
|
||||
# Declare an array to define the options of this helper.
|
||||
local legacy_args=vp
|
||||
declare -Ar args_array=( [v]=phpversion= [p]=package= )
|
||||
local phpversion
|
||||
local package
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
package=${package:-}
|
||||
|
||||
# Store php_version into the config of this app
|
||||
ynh_app_setting_set $app php_version $phpversion
|
||||
|
||||
if [ "$phpversion" == "7.0" ]
|
||||
then
|
||||
ynh_die "Do not use ynh_install_php to install php7.0"
|
||||
fi
|
||||
|
||||
# Store the ID of this app and the version of php requested for it
|
||||
echo "$YNH_APP_INSTANCE_NAME:$phpversion" | tee --append "/etc/php/ynh_app_version"
|
||||
|
||||
# Add an extra repository for those packages
|
||||
ynh_install_extra_repo --repo="https://packages.sury.org/php/ $(lsb_release -sc) main" --key="https://packages.sury.org/php/apt.gpg" --priority=995 --name=extra_php_version
|
||||
|
||||
# Install requested dependencies from this extra repository.
|
||||
# Install php-fpm first, otherwise php will install apache as a dependency.
|
||||
ynh_add_app_dependencies --package="php${phpversion}-fpm"
|
||||
ynh_add_app_dependencies --package="php$phpversion php${phpversion}-common $package"
|
||||
|
||||
# Set php7.0 back as the default version for php-cli.
|
||||
update-alternatives --set php /usr/bin/php7.0
|
||||
|
||||
# Remove this extra repository after packages are installed
|
||||
ynh_remove_extra_repo --name=extra_php_version
|
||||
|
||||
# Advertise service in admin panel
|
||||
yunohost service add php${phpversion}-fpm --log "/var/log/php${phpversion}-fpm.log"
|
||||
}
|
||||
|
||||
ynh_remove_php () {
|
||||
# Get the version of php used by this app
|
||||
local phpversion=$(ynh_app_setting_get $app php_version)
|
||||
|
||||
if [ "$phpversion" == "7.0" ] || [ -z "$phpversion" ]
|
||||
then
|
||||
if [ "$phpversion" == "7.0" ]
|
||||
then
|
||||
ynh_print_err "Do not use ynh_remove_php to install php7.0"
|
||||
fi
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Remove the line for this app
|
||||
sed --in-place "/$YNH_APP_INSTANCE_NAME:$phpversion/d" "/etc/php/ynh_app_version"
|
||||
|
||||
# If no other app uses this version of php, remove it.
|
||||
if ! grep --quiet "$phpversion" "/etc/php/ynh_app_version"
|
||||
then
|
||||
# Purge php dependences for this version.
|
||||
ynh_package_autopurge "php$phpversion php${phpversion}-fpm php${phpversion}-common"
|
||||
# Remove the service from the admin panel
|
||||
yunohost service remove php${phpversion}-fpm
|
||||
fi
|
||||
|
||||
# If no other app uses alternate php versions, remove the extra repo for php
|
||||
if [ ! -s "/etc/php/ynh_app_version" ]
|
||||
then
|
||||
ynh_secure_remove /etc/php/ynh_app_version
|
||||
fi
|
||||
}
|
272
scripts/install
272
scripts/install
|
@ -7,10 +7,8 @@
|
|||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source experimental_helpers/_ynh_add_extra_apt_repos
|
||||
source experimental_helpers/ynh_install_php
|
||||
source experimental_helpers/ynh_exec_as
|
||||
source experimental_helpers/ynh_composer
|
||||
source experimental_helpers/ynh_composer__2
|
||||
source experimental_helpers/ynh_send_readme_to_admin
|
||||
source experimental_helpers/hardware
|
||||
source experimental_helpers/ynh_add_swap
|
||||
|
@ -21,107 +19,73 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
|
||||
ynh_clean_setup () {
|
||||
### Remove this function if there's nothing to clean before calling the remove script.
|
||||
true
|
||||
true
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#===================================================
|
||||
#=================================================
|
||||
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
||||
#===================================================
|
||||
|
||||
# This is a multi-instance app, meaning it can be installed several times independently
|
||||
# The id of the app as stated in the manifest is available as $YNH_APP_ID
|
||||
# The instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2", ...)
|
||||
# The app instance name is available as $YNH_APP_INSTANCE_NAME
|
||||
# - the first time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample
|
||||
# - the second time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample__2
|
||||
# - ynhexample__{N} for the subsequent installations, with N=3,4, ...
|
||||
# The app instance name is probably what you are interested the most, since this is
|
||||
# guaranteed to be unique. This is a good unique identifier to define installation path,
|
||||
# db names, ...
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
# Retrieve arguments
|
||||
#=================================================
|
||||
|
||||
domain=$YNH_APP_ARG_DOMAIN
|
||||
path_url=$YNH_APP_ARG_PATH
|
||||
admin=$YNH_APP_ARG_ADMIN
|
||||
title=$YNH_APP_ARG_TITLE
|
||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||
language=$YNH_APP_ARG_LANGUAGE
|
||||
title=$YNH_APP_ARG_TITLE
|
||||
bazaar_extension=$YNH_APP_ARG_BAZAAR_EXTENSION
|
||||
|
||||
#===================================================
|
||||
admin_pwd=$(ynh_string_random --length=8)
|
||||
admin_mail=$(ynh_user_get_info --username=$admin --key=mail)
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||
#===================================================
|
||||
#=================================================
|
||||
ynh_script_progression --message="Validating installation parameters..."
|
||||
|
||||
final_path=/var/www/$app
|
||||
test ! -e "$final_path" || ynh_die "This path already contains a folder"
|
||||
|
||||
# Normalize the url path syntax
|
||||
path_url=$(ynh_normalize_url_path $path_url)
|
||||
|
||||
# Check web path availability
|
||||
ynh_webpath_available $domain $path_url
|
||||
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
||||
|
||||
# Register (book) web path
|
||||
ynh_webpath_register $app $domain $path_url
|
||||
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
|
||||
|
||||
#===================================================
|
||||
# CHECK IF THE APP CAN BE INSTALLED WITH CURRENT RAM
|
||||
#===================================================
|
||||
ynh_script_progression --message="Ensuring sufficient memory..." --time --weight=1
|
||||
|
||||
# Check RAM
|
||||
if [[ $(ynh_get_ram --free) < 1000 ]]; then
|
||||
ynh_add_swap --size=1000
|
||||
fi
|
||||
|
||||
#===================================================
|
||||
#=================================================
|
||||
# STORE SETTINGS FROM MANIFEST
|
||||
#===================================================
|
||||
#=================================================
|
||||
ynh_script_progression --message="Storing installation settings..."
|
||||
|
||||
# Save app settings
|
||||
ynh_app_setting_set $app domain $domain
|
||||
ynh_app_setting_set $app path $path_url
|
||||
ynh_app_setting_set $app admin $admin
|
||||
ynh_app_setting_set $app language $language
|
||||
ynh_app_setting_set $app php_version $php_version
|
||||
ynh_app_setting_set $app project_version $project_version
|
||||
ynh_app_setting_set $app core_version $core_version
|
||||
ynh_app_setting_set $app ssowat_version $ssowat_version
|
||||
ynh_app_setting_set $app bazaar_extension $bazaar_extension
|
||||
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
||||
ynh_app_setting_set --app=$app --key=path --value=$path_url
|
||||
ynh_app_setting_set --app=$app --key=admin --value=$admin
|
||||
ynh_app_setting_set --app=$app --key=is_public --value=$is_public
|
||||
ynh_app_setting_set --app=$app --key=language --value=$language
|
||||
ynh_app_setting_set --app=$app --key=project_version --value=$project_version
|
||||
ynh_app_setting_set --app=$app --key=core_version --value=$core_version
|
||||
ynh_app_setting_set --app=$app --key=ssowat_version --value=$ssowat_version
|
||||
ynh_app_setting_set --app=$app --key=bazaar_extension --value=$bazaar_extension
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
#=================================================
|
||||
# INSTALL PHP
|
||||
#=================================================
|
||||
|
||||
if [ "$(lsb_release --codename --short)" = "buster" ]; then
|
||||
pkg_dependencies="$pkg_dependencies $extra_pkg_dependencies"
|
||||
else
|
||||
ynh_script_progression --message="Installing php${php_version}..." --time --weight=1
|
||||
ynh_install_php --phpversion="${php_version}" --package="$extra_pkg_dependencies"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing dependencies..." --time --weight=1
|
||||
ynh_script_progression --message="Installing dependencies..." --weight=1
|
||||
|
||||
_ynh_install_app_dependencies "$pkg_dependencies"
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
#=================================================
|
||||
# CREATE A MYSQL DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Creating a MySQL database..."
|
||||
|
||||
db_name=$(ynh_sanitize_dbid $app)
|
||||
ynh_app_setting_set $app db_name $db_name
|
||||
ynh_mysql_setup_db $db_name $db_name
|
||||
ynh_app_setting_set "$app" db_pwd "$db_pwd"
|
||||
db_name=$(ynh_sanitize_dbid --db_name=$app)
|
||||
db_user=$db_name
|
||||
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
||||
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name
|
||||
ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
|
@ -146,70 +110,55 @@ fi
|
|||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config
|
||||
|
||||
#===================================================
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#===================================================
|
||||
ynh_script_progression --message="Configuring system user..." --time --weight=1
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring system user..." --weight=1
|
||||
|
||||
# Create a system user
|
||||
ynh_system_user_create $app $final_path
|
||||
ynh_system_user_create --username=$app --home_dir=$final_path
|
||||
# Adding it to www-data group
|
||||
usermod -a -G www-data $app
|
||||
|
||||
#=================================================
|
||||
# PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring php-fpm..."
|
||||
|
||||
# Create a dedicated php-fpm config
|
||||
ynh_add_fpm_config $php_version
|
||||
ynh_add_fpm_config --usage=low --footprint=low --package="$extra_php_dependencies"
|
||||
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||
|
||||
#=================================================
|
||||
# INSTALL AND INITIALIZE COMPOSER
|
||||
# SPECIFIC SETUP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing Flarum with Composer..." --time --weight=1
|
||||
|
||||
# Create composer directory and making sure it is writable
|
||||
mkdir -p "$final_path/.composer"
|
||||
chown -R $app: $final_path
|
||||
|
||||
# Installing composer
|
||||
ynh_install_composer --user=$app --phpversion=$php_version --workdir=$final_path
|
||||
|
||||
# Set Flarum version
|
||||
ynh_composer_exec --user=$app --phpversion=$php_version --workdir=$final_path \
|
||||
--commands="require flarum/core:$core_version --prefer-lowest --no-update"
|
||||
|
||||
# Require SSOwat extension
|
||||
ynh_composer_exec --user=$app --phpversion=$php_version --workdir=$final_path \
|
||||
--commands="require tituspijean/flarum-ext-auth-ssowat:$ssowat_version --no-update"
|
||||
|
||||
# Update and download dependencies
|
||||
ynh_composer_exec --user=$app --phpversion=$php_version --workdir=$final_path \
|
||||
--commands="update"
|
||||
|
||||
#=================================================
|
||||
# SETUP LOGROTATE
|
||||
# CHECK IF THE APP CAN BE INSTALLED WITH CURRENT RAM
|
||||
#=================================================
|
||||
ynh_script_progression --message="Ensuring sufficient memory..." --weight=1
|
||||
|
||||
# Use logrotate to manage app-specific logfile(s)
|
||||
ynh_use_logrotate
|
||||
|
||||
#=================================================
|
||||
# SETUP PERMISSIONS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring permissions..." --time --weight=1
|
||||
|
||||
# Make app public if necessary
|
||||
if [ $is_public -eq 1 ]
|
||||
then
|
||||
# Everyone can access the app.
|
||||
# The "main" permission is automatically created before the install script.
|
||||
ynh_permission_update --permission "main" --add "visitors"
|
||||
# Check RAM
|
||||
if [[ $(ynh_get_ram --free) < 1000 ]]; then
|
||||
ynh_add_swap --size=1000
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
# INSTALL COMPOSER DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing composer dependencies..."
|
||||
|
||||
systemctl reload nginx
|
||||
ynh_exec_warn_less ynh_install_composer --phpversion="$phpversion" --workdir="$final_path"
|
||||
|
||||
# Set Flarum version
|
||||
ynh_composer_exec --user=$app --phpversion=$phpversion --workdir=$final_path \
|
||||
--commands="require flarum/core:$core_version --prefer-lowest --no-update"
|
||||
|
||||
# Require SSOwat extension
|
||||
ynh_composer_exec --user=$app --phpversion=$phpversion --workdir=$final_path \
|
||||
--commands="require tituspijean/flarum-ext-auth-ssowat:$ssowat_version --no-update"
|
||||
|
||||
# Update and download dependencies
|
||||
ynh_composer_exec --user=$app --phpversion=$phpversion --workdir=$final_path \
|
||||
--commands="update"
|
||||
|
||||
#=================================================
|
||||
# FLARUM POST-INSTALL
|
||||
|
@ -219,22 +168,20 @@ ynh_script_progression --message="Configuring Flarum..." --time --weight=2
|
|||
# Copy the configuration.yml to working directory
|
||||
finalflarumconf="$final_path/configuration.yml"
|
||||
cp ../conf/configuration.yml $finalflarumconf
|
||||
chown $app: $finalflarumconf
|
||||
# Generate admin password and retrieve their email address
|
||||
admin_pwd=$(ynh_string_random 8)
|
||||
admin_mail=$(ynh_user_get_info $admin mail)
|
||||
|
||||
# Populate configuration.yml
|
||||
ynh_replace_string "__DOMAIN__" "$domain" "$finalflarumconf"
|
||||
ynh_replace_string "/__PATH__" "$path_url" "$finalflarumconf"
|
||||
ynh_replace_string "__USER__" "$app" "$finalflarumconf"
|
||||
ynh_replace_string "__DB_PWD__" "$db_pwd" "$finalflarumconf"
|
||||
ynh_replace_string "__ADMIN__" "$admin" "$finalflarumconf"
|
||||
ynh_replace_string "__ADMIN_PWD__" "$admin_pwd" "$finalflarumconf"
|
||||
ynh_replace_string "__ADMIN_EML__" "$admin_mail" "$finalflarumconf"
|
||||
ynh_replace_string "__FORUM_TITLE__" "$title" "$finalflarumconf"
|
||||
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$finalflarumconf"
|
||||
ynh_replace_string --match_string="/__PATH__" --replace_string="$path_url" --target_file="$finalflarumconf"
|
||||
ynh_replace_string --match_string="__USER__" --replace_string="$app" --target_file="$finalflarumconf"
|
||||
ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$finalflarumconf"
|
||||
ynh_replace_string --match_string="__ADMIN__" --replace_string="$admin" --target_file="$finalflarumconf"
|
||||
ynh_replace_string --match_string="__ADMIN_PWD__" --replace_string="$admin_pwd" --target_file="$finalflarumconf"
|
||||
ynh_replace_string --match_string="__ADMIN_EML__" --replace_string="$admin_mail" --target_file="$finalflarumconf"
|
||||
ynh_replace_string --match_string="__FORUM_TITLE__" --replace_string="$title" --target_file="$finalflarumconf"
|
||||
|
||||
# Execute post-installation
|
||||
pushd $final_path
|
||||
exec_as $app php$php_version -d $final_path -d memory_limit=-1 flarum install -f configuration.yml
|
||||
exec_as $app php$phpversion -d $final_path -d memory_limit=-1 flarum install -f configuration.yml
|
||||
# Delete configuration.yml as it contains sensitive data
|
||||
ynh_secure_remove $finalflarumconf
|
||||
popd
|
||||
|
@ -246,56 +193,89 @@ sql_command="REPLACE INTO \`settings\` (\`key\`, \`value\`) VALUES
|
|||
('mail_from', '$app@$domain'),
|
||||
('mail_host', 'localhost'),
|
||||
('mail_port', '587');"
|
||||
ynh_mysql_execute_as_root "$sql_command" $db_name
|
||||
ynh_mysql_execute_as_root --sql="$sql_command" --database=$db_name
|
||||
|
||||
# Enable and set up the SSOwat auth extension
|
||||
ynh_script_progression --message="Enabling and configuring SSOwat extension..." --time --weight=2
|
||||
ynh_script_progression --message="Enabling and configuring SSOwat extension..." --weight=2
|
||||
activate_flarum_extension $db_name "tituspijean-auth-ssowat"
|
||||
ssowatdomain=$(</etc/yunohost/current_host)
|
||||
sql_command="INSERT INTO \`settings\` (\`key\`, \`value\`) VALUES ('tituspijean-auth-ssowat.domain', '$ssowatdomain'), ('tituspijean-auth-ssowat.onlyUse', '0');"
|
||||
ynh_mysql_execute_as_root "$sql_command" $db_name
|
||||
ynh_mysql_execute_as_root --sql="$sql_command" --database=$db_name
|
||||
|
||||
# Install, activate and set language extensions
|
||||
case $language in
|
||||
fr)
|
||||
ynh_script_progression --message="Installing French extension..." --time --weight=2
|
||||
ynh_composer_exec --user=$app --phpversion=$php_version --workdir=$final_path --commands="require milescellar/lang-french"
|
||||
ynh_script_progression --message="Installing French extension..." --weight=2
|
||||
ynh_composer_exec --user=$app --phpversion=$phpversion --workdir=$final_path --commands="require milescellar/lang-french"
|
||||
activate_flarum_extension $db_name "milescellar-lang-french"
|
||||
sql_command="UPDATE \`settings\` SET \`value\` = 'fr' WHERE \`settings\`.\`key\` = 'default_locale'"
|
||||
ynh_mysql_execute_as_root "$sql_command" $db_name
|
||||
ynh_mysql_execute_as_root --sql="$sql_command" --database=$db_name
|
||||
;;
|
||||
de)
|
||||
ynh_script_progression --message="Installing German extension..." --time --weight=2
|
||||
ynh_composer_exec --user=$app --phpversion=$php_version --workdir=$final_path --commands="require cbmainz/flarum-de"
|
||||
ynh_script_progression --message="Installing German extension..." --weight=2
|
||||
ynh_composer_exec --user=$app --phpversion=$phpversion --workdir=$final_path --commands="require cbmainz/flarum-de"
|
||||
activate_flarum_extension $db_name "cbmainz-de"
|
||||
sql_command="UPDATE \`settings\` SET \`value\` = 'de' WHERE \`settings\`.\`key\` = 'default_locale'"
|
||||
ynh_mysql_execute_as_root "$sql_command" $db_name
|
||||
ynh_mysql_execute_as_root --sql="$sql_command" --database=$db_name
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ $bazaar_extension -eq 1 ]; then
|
||||
ynh_script_progression --message="Installing Bazaar extension..." --time --weight=2
|
||||
ynh_composer_exec --user=$app --phpversion=$php_version --workdir=$final_path --commands="require extiverse/bazaar"
|
||||
ynh_script_progression --message="Installing Bazaar extension..." --weight=2
|
||||
ynh_composer_exec --user=$app --phpversion=$phpversion --workdir=$final_path --commands="require extiverse/bazaar"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# SECURE FILES AND DIRECTORIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Securing files and directories..."
|
||||
|
||||
### For security reason, any app should set the permissions to root: before anything else.
|
||||
### Then, if write authorization is needed, any access should be given only to directories
|
||||
### that really need such authorization.
|
||||
|
||||
# Set right permissions
|
||||
# Set permissions to app files
|
||||
chown -R $app:www-data $final_path
|
||||
|
||||
#=================================================
|
||||
# SETUP LOGROTATE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring log rotation..."
|
||||
|
||||
# Use logrotate to manage application logfile(s)
|
||||
ynh_use_logrotate
|
||||
|
||||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring SSOwat..." --weight=1
|
||||
|
||||
# Make app public if necessary
|
||||
if [ $is_public -eq 1 ]
|
||||
then
|
||||
# Everyone can access the app.
|
||||
# The "main" permission is automatically created before the install script.
|
||||
ynh_permission_update --permission "main" --add "visitors"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading nginx web server..."
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# SEND CREDENTIALS TO ADMIN
|
||||
#=================================================
|
||||
ynh_script_progression --message="Sending generated admin credentials by email, but you can log in with your YunoHost credentials!" --weight=1
|
||||
|
||||
ynh_script_progression --message="Sending generated admin credentials by email, but you can log in with your YunoHost credentials!" --time --weight=1
|
||||
app_message="User : $admin, password : $admin_pwd
|
||||
Change your password!
|
||||
Your forum is accessible at https://$domain$path_url"
|
||||
ynh_send_readme_to_admin "$app_message" "$admin"
|
||||
ynh_print_warn "$app_message"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Installation of $app completed"
|
||||
|
|
|
@ -7,20 +7,17 @@
|
|||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source experimental_helpers/_ynh_add_extra_apt_repos
|
||||
source experimental_helpers/ynh_install_php
|
||||
source experimental_helpers/ynh_add_swap
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..." --time --weight=1
|
||||
ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
db_user=$db_name
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
|
@ -30,7 +27,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
|||
#=================================================
|
||||
# REMOVE THE MYSQL DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing the MySQL database..." --time --weight=1
|
||||
ynh_script_progression --message="Removing the MySQL database..." --weight=1
|
||||
|
||||
# Remove a database if it exists, along with the associated user
|
||||
ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
|
||||
|
@ -38,30 +35,23 @@ ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
|
|||
#=================================================
|
||||
# REMOVE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing dependencies..." --time --weight=1
|
||||
ynh_script_progression --message="Removing dependencies..." --weight=1
|
||||
|
||||
# Remove metapackage and its dependencies
|
||||
ynh_remove_app_dependencies
|
||||
if [ "$(lsb_release --codename --short)" != "buster" ]; then
|
||||
ynh_remove_php
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# REMOVE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing app main directory..." --time --weight=1
|
||||
ynh_script_progression --message="Removing app main directory..." --weight=1
|
||||
|
||||
# Remove the app directory securely
|
||||
ynh_secure_remove --file="$final_path"
|
||||
|
||||
# Remove the temporary upgrade directory securely
|
||||
ynh_secure_remove --file="/tmp/$app"
|
||||
ynh_secure_remove --file="/tmp/${app}backup"
|
||||
|
||||
#=================================================
|
||||
# REMOVE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing nginx web server configuration..." --time --weight=1
|
||||
ynh_script_progression --message="Removing nginx web server configuration..." --weight=1
|
||||
|
||||
# Remove the dedicated nginx config
|
||||
ynh_remove_nginx_config
|
||||
|
@ -69,7 +59,7 @@ ynh_remove_nginx_config
|
|||
#=================================================
|
||||
# REMOVE PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing php-fpm configuration..." --time --weight=1
|
||||
ynh_script_progression --message="Removing php-fpm configuration..." --weight=1
|
||||
|
||||
# Remove the dedicated php-fpm config
|
||||
ynh_remove_fpm_config
|
||||
|
@ -77,7 +67,7 @@ ynh_remove_fpm_config
|
|||
#=================================================
|
||||
# REMOVE LOGROTATE CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing logrotate configuration..." --time --weight=1
|
||||
ynh_script_progression --message="Removing logrotate configuration..." --weight=1
|
||||
|
||||
# Remove the app-specific logrotate config
|
||||
ynh_remove_logrotate
|
||||
|
@ -85,7 +75,7 @@ ynh_remove_logrotate
|
|||
#=================================================
|
||||
# SPECIFIC REMOVE
|
||||
#=================================================
|
||||
# REMOVE THE CRON FILE
|
||||
# REMOVE VARIOUS FILES
|
||||
#=================================================
|
||||
|
||||
# Remove the log files
|
||||
|
@ -96,7 +86,7 @@ ynh_secure_remove --file="/var/log/$app"
|
|||
#=================================================
|
||||
# REMOVE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing the dedicated system user..." --time --weight=1
|
||||
ynh_script_progression --message="Removing the dedicated system user..." --weight=1
|
||||
|
||||
# Delete a system user
|
||||
ynh_system_user_delete --username=$app
|
||||
|
@ -104,7 +94,7 @@ ynh_system_user_delete --username=$app
|
|||
#===================================================
|
||||
# REMOVE SWAP
|
||||
#===================================================
|
||||
ynh_script_progression --message="Removing swap..." --time --weight=1
|
||||
ynh_script_progression --message="Removing swap..." --weight=1
|
||||
|
||||
ynh_del_swap
|
||||
|
||||
|
@ -112,4 +102,4 @@ ynh_del_swap
|
|||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Removal of $app completed" --time --last
|
||||
ynh_script_progression --message="Removal of $app completed" --last
|
||||
|
|
|
@ -8,11 +8,6 @@
|
|||
|
||||
#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
||||
source ../settings/scripts/_common.sh
|
||||
source ../settings/scripts/experimental_helpers/_ynh_add_extra_apt_repos
|
||||
source ../settings/scripts/experimental_helpers/ynh_install_php
|
||||
source ../settings/scripts/experimental_helpers/ynh_exec_as
|
||||
source ../settings/scripts/experimental_helpers/ynh_composer
|
||||
source ../settings/scripts/experimental_helpers/ynh_send_readme_to_admin
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
|
@ -25,42 +20,47 @@ ynh_abort_if_errors
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
path_url=$(ynh_app_setting_get $app path)
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
db_name=$(ynh_app_setting_get $app db_name)
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
db_user=$db_name
|
||||
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE RESTORED
|
||||
#=================================================
|
||||
ynh_script_progression --message="Validating restoration parameters..."
|
||||
|
||||
ynh_webpath_available $domain $path_url \
|
||||
|| ynh_die "Path not available: ${domain}${path_url}"
|
||||
ynh_webpath_available --domain=$domain --path_url=$path_url \
|
||||
|| ynh_die --message="Path not available: ${domain}${path_url}"
|
||||
test ! -d $final_path \
|
||||
|| ynh_die "There is already a directory: $final_path "
|
||||
|| ynh_die --message="There is already a directory: $final_path "
|
||||
|
||||
#=================================================
|
||||
# STANDARD RESTORATION STEPS
|
||||
#=================================================
|
||||
# RESTORE THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the nginx configuration..."
|
||||
|
||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the app main directory..." --time --weight=1
|
||||
ynh_script_progression --message="Restoring the app main directory..." --weight=1
|
||||
|
||||
ynh_restore_file --origin_path="$final_path"
|
||||
|
||||
#=================================================
|
||||
# RECREATE THE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Recreating the dedicated system user..." --time --weight=1
|
||||
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
|
||||
|
||||
# Create the dedicated user (if not existing)
|
||||
ynh_system_user_create --username=$app
|
||||
|
@ -68,65 +68,61 @@ ynh_system_user_create --username=$app
|
|||
#=================================================
|
||||
# RESTORE USER RIGHTS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring user rights..."
|
||||
|
||||
# Set right permissions
|
||||
chown -R $app: $final_path
|
||||
chown -R $app:www-data $final_path/storage
|
||||
chmod -R 0775 $final_path
|
||||
|
||||
#=================================================
|
||||
# INSTALL PHP
|
||||
#=================================================
|
||||
|
||||
if [ "$(lsb_release --codename --short)" = "buster" ]; then
|
||||
pkg_dependencies="$pkg_dependencies $extra_pkg_dependencies"
|
||||
else
|
||||
ynh_script_progression --message="Installing php${php_version}..." --time --weight=1
|
||||
ynh_install_php --phpversion="${php_version}" --package="$extra_pkg_dependencies"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring PHP-FPM configuration..."
|
||||
|
||||
ynh_restore_file --origin_path="/etc/php/${php_version}/fpm/pool.d/$app.conf"
|
||||
ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
|
||||
|
||||
# Recreate a dedicated php-fpm config
|
||||
ynh_add_fpm_config --usage=low --footprint=low --package="$extra_php_dependencies"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC RESTORATION
|
||||
#=================================================
|
||||
# REINSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reinstalling dependencies..." --time --weight=1
|
||||
ynh_script_progression --message="Reinstalling dependencies..." --weight=1
|
||||
|
||||
# Define and install dependencies
|
||||
ynh_install_app_dependencies "$pkg_dependencies"
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE MYSQL DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the MySQL database..."
|
||||
|
||||
db_pwd=$(ynh_app_setting_get $app mysqlpwd)
|
||||
ynh_mysql_setup_db $db_name $db_name $db_pwd
|
||||
ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql
|
||||
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
|
||||
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
|
||||
ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE LOGROTATE CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the logrotate configuration..."
|
||||
|
||||
ynh_restore_file "/etc/logrotate.d/$app"
|
||||
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# RELOAD NGINX AND PHP-FPM
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading nginx web server and php-fpm..." --time --weight=1
|
||||
ynh_script_progression --message="Reloading nginx web server and php-fpm..." --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=php${php_version}-fpm --action=reload
|
||||
ynh_systemd_action --service_name=php$phpversion-fpm --action=reload
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Restoration completed for $app" --time --last
|
||||
ynh_script_progression --message="Restoration completed for $app" --last
|
||||
|
|
212
scripts/upgrade
212
scripts/upgrade
|
@ -7,11 +7,8 @@
|
|||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source experimental_helpers/_ynh_add_extra_apt_repos
|
||||
source experimental_helpers/ynh_install_php
|
||||
source experimental_helpers/ynh_exec_as
|
||||
source experimental_helpers/ynh_composer
|
||||
source experimental_helpers/ynh_send_readme_to_admin
|
||||
source experimental_helpers/ynh_composer__2
|
||||
source experimental_helpers/hardware
|
||||
source experimental_helpers/ynh_add_swap
|
||||
source /usr/share/yunohost/helpers
|
||||
|
@ -19,13 +16,14 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..." --time --weight=1
|
||||
ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||
admin=$(ynh_app_setting_get --app=$app --key=admin)
|
||||
is_public=$(ynh_app_setting_get --app=$app --key=is_public)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
language=$(ynh_app_setting_get --app=$app --key=language)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
|
@ -38,29 +36,23 @@ bazaar_extension=$(ynh_app_setting_get --app=$app --key=bazaar_extension)
|
|||
#=================================================
|
||||
# CHECK VERSION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Checking version..."
|
||||
|
||||
### This helper will compare the version of the currently installed app and the version of the upstream package.
|
||||
### $upgrade_type can have 2 different values
|
||||
### - UPGRADE_APP if the upstream app version has changed
|
||||
### - UPGRADE_PACKAGE if only the YunoHost package has changed
|
||||
### ynh_check_app_version_changed will stop the upgrade if the app is up to date.
|
||||
### UPGRADE_APP should be used to upgrade the core app only if there's an upgrade to do.
|
||||
upgrade_type=$(ynh_check_app_version_changed)
|
||||
|
||||
#===================================================
|
||||
# CHECK IF THE APP CAN BE INSTALLED WITH CURRENT RAM
|
||||
#===================================================
|
||||
ynh_script_progression --message="Ensuring sufficient memory..." --time --weight=1
|
||||
|
||||
# Check RAM
|
||||
if [[ $(ynh_get_ram --free) < 1000 ]]; then
|
||||
ynh_add_swap --size=1000
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Ensuring downward compatibility..." --time --weight=1
|
||||
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
||||
|
||||
# Fix is_public as a boolean value
|
||||
if [ "$is_public" = "Yes" ]; then
|
||||
ynh_app_setting_set --app=$app --key=is_public --value=1
|
||||
is_public=1
|
||||
elif [ "$is_public" = "No" ]; then
|
||||
ynh_app_setting_set --app=$app --key=is_public --value=0
|
||||
is_public=0
|
||||
fi
|
||||
|
||||
# If db_name doesn't exist, create it
|
||||
if [ -z "$db_name" ]; then
|
||||
|
@ -106,7 +98,7 @@ if [[ $old_project_version == "v*" ]]; then $old_project_version = ${old_project
|
|||
#=================================================
|
||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --time --weight=1
|
||||
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1
|
||||
|
||||
# Backup the current version of the app
|
||||
ynh_backup_before_upgrade
|
||||
|
@ -122,19 +114,47 @@ ynh_abort_if_errors
|
|||
#=================================================
|
||||
|
||||
# Normalize the URL path syntax
|
||||
# N.B. : this is for app installations before YunoHost 2.7
|
||||
# where this value might be something like /foo/ or foo/
|
||||
# instead of /foo ....
|
||||
# If nobody installed your app before 2.7, then you may
|
||||
# safely remove this line
|
||||
path_url=$(ynh_normalize_url_path --path_url=$path_url)
|
||||
|
||||
#=================================================
|
||||
# STANDARD UPGRADE STEPS
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
ynh_script_progression --message="Upgrading source files..."
|
||||
|
||||
# Create a temporary directory
|
||||
tmpdir="$(mktemp -d)"
|
||||
cp -R $final_path/* $tmpdir
|
||||
|
||||
# Deleting current app directory
|
||||
ynh_secure_remove --file="$final_path"
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir="$final_path"
|
||||
|
||||
# Copy config.php back into Flarum
|
||||
cp -f $tmpdir/config.php $final_path
|
||||
|
||||
# Copy assets from old app version. Can be either in root folder or in "public" folder
|
||||
if [ -d $tmpdir/assets ]; then
|
||||
cp -Rf $tmpdir/assets $final_path/public
|
||||
fi
|
||||
if [ -d $tmpdir/public/assets ]; then
|
||||
cp -Rf $tmpdir/public/assets $final_path/public
|
||||
fi
|
||||
|
||||
# Clean temp directory
|
||||
ynh_secure_remove --file="$tmpdir"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading nginx web server configuration..." --time --weight=1
|
||||
ynh_script_progression --message="Upgrading nginx web server configuration..." --weight=1
|
||||
|
||||
# Bug in Nginx with locations and aliases (see http://stackoverflow.com/a/35102259 )
|
||||
if [ $path_url = "/" ]; then
|
||||
|
@ -146,99 +166,65 @@ fi
|
|||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config
|
||||
|
||||
#=================================================
|
||||
# UPGRADE PHP7.3
|
||||
#=================================================
|
||||
|
||||
if [ "$(lsb_release --codename --short)" = "buster" ]; then
|
||||
pkg_dependencies="$pkg_dependencies $extra_pkg_dependencies"
|
||||
else
|
||||
ynh_script_progression --message="Upgrading php${php_version}..." --time --weight=1
|
||||
ynh_install_php --phpversion="${php_version}" --package="$extra_pkg_dependencies"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# UPGRADE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading dependencies..." --time --weight=1
|
||||
ynh_script_progression --message="Upgrading dependencies..." --weight=1
|
||||
|
||||
_ynh_install_app_dependencies "$pkg_dependencies"
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Making sure dedicated system user exists..." --time --weight=1
|
||||
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
|
||||
|
||||
# Create a dedicated user (if not existing)
|
||||
ynh_system_user_create $app $final_path
|
||||
ynh_system_user_create --username=$app --home_dir=$final_path
|
||||
# Adding it to www-data group
|
||||
usermod -a -G www-data $app
|
||||
|
||||
#=================================================
|
||||
# PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading php-fpm configuration..." --time --weight=1
|
||||
ynh_script_progression --message="Upgrading php-fpm configuration..." --weight=1
|
||||
|
||||
# Create a dedicated php-fpm config
|
||||
ynh_add_fpm_config $php_version
|
||||
ynh_add_fpm_config --usage=low --footprint=low --package="$extra_php_dependencies"
|
||||
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC UPGRADE
|
||||
#===================================================
|
||||
# CHECK IF THE APP CAN BE INSTALLED WITH CURRENT RAM
|
||||
#===================================================
|
||||
ynh_script_progression --message="Ensuring sufficient memory..." --weight=1
|
||||
|
||||
# Check RAM
|
||||
if [[ $(ynh_get_ram --free) < 1000 ]]; then
|
||||
ynh_add_swap --size=1000
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# COMPOSER AND FLARUM UPGRADE
|
||||
#=================================================
|
||||
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
# If the app is too old, let's be safe and reinstall all files.
|
||||
if dpkg --compare-versions "$old_core_version" "lt" "0.1.0-beta.9"; then
|
||||
ynh_script_progression --message="Upgrading source files..." --time --weight=1
|
||||
|
||||
# Backing up the app directory
|
||||
tmpbak="/tmp/${app}backup"
|
||||
ynh_secure_remove --file="$tmpbak"
|
||||
mkdir -p $tmpbak
|
||||
cp -R $final_path/* $tmpbak
|
||||
|
||||
# Deleting current app directory
|
||||
ynh_secure_remove --file="$final_path"
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir="$final_path"
|
||||
|
||||
# Setting user rights
|
||||
chown -R $app:www-data $final_path
|
||||
|
||||
# Install Composer and Flarum
|
||||
ynh_install_composer --user=$app --phpversion=$php_version --workdir=$final_path
|
||||
|
||||
# Copy config.php back into Flarum
|
||||
cp -f $tmpbak/config.php $final_path
|
||||
|
||||
# Copy assets from old app version. Can be either in root folder or in "public" folder
|
||||
if [ -d $tmpbak/assets ]; then
|
||||
cp -Rf $tmpbak/assets $final_path/public
|
||||
fi
|
||||
if [ -d $tmpbak/public/assets ]; then
|
||||
cp -Rf $tmpbak/public/assets $final_path/public
|
||||
fi
|
||||
|
||||
# Clean temp directory
|
||||
ynh_secure_remove $tmpbak
|
||||
fi
|
||||
|
||||
# Set right permissions
|
||||
chown -R $app:www-data $final_path
|
||||
|
||||
# Install Composer and Flarum
|
||||
ynh_install_composer --user=$app --phpversion=$phpversion --workdir=$final_path
|
||||
|
||||
# Perform migrations and clear cache
|
||||
pushd $final_path
|
||||
ynh_script_progression --message="Upgrading Flarum and its extensions..." --time --weight=1
|
||||
ynh_composer_exec --user=$app --phpversion=$php_version --workdir=$final_path \
|
||||
ynh_script_progression --message="Upgrading Flarum and its extensions..." --weight=1
|
||||
ynh_composer_exec --user=$app --phpversion=$phpversion --workdir=$final_path \
|
||||
--commands="require tituspijean/flarum-ext-auth-ssowat:$ssowat_version --no-update"
|
||||
ynh_composer_exec --user=$app --phpversion=$php_version --workdir=$final_path \
|
||||
ynh_composer_exec --user=$app --phpversion=$phpversion --workdir=$final_path \
|
||||
--commands="require flarum/core:$core_version --prefer-dist --update-no-dev -a --update-with-all-dependencies"
|
||||
exec_as $app php$php_version flarum migrate
|
||||
exec_as $app php$php_version flarum cache:clear
|
||||
exec_as $app php$phpversion flarum migrate
|
||||
exec_as $app php$phpversion flarum cache:clear
|
||||
popd
|
||||
fi
|
||||
|
||||
|
@ -246,7 +232,7 @@ fi
|
|||
# FLARUM EXTENSIONS
|
||||
#=================================================
|
||||
|
||||
if ! exec_as $app php$php_version flarum info | grep -q "tituspijean-auth-ssowat" | grep -q $ssowat_version;
|
||||
if ! exec_as $app php$phpversion flarum info | grep -q "tituspijean-auth-ssowat" | grep -q $ssowat_version;
|
||||
then
|
||||
# Install and activate the SSOwat auth extension
|
||||
activate_flarum_extension $db_name "tituspijean-auth-ssowat"
|
||||
|
@ -259,15 +245,15 @@ fi
|
|||
# Install, activate and set language extensions
|
||||
case $language in
|
||||
fr)
|
||||
ynh_script_progression --message="Installing French extension..." --time --weight=2
|
||||
ynh_composer_exec --user=$app --phpversion=$php_version --workdir=$final_path --commands="require milescellar/lang-french"
|
||||
ynh_script_progression --message="Installing French extension..." --weight=2
|
||||
ynh_composer_exec --user=$app --phpversion=$phpversion --workdir=$final_path --commands="require milescellar/lang-french"
|
||||
activate_flarum_extension $db_name "milescellar-lang-french"
|
||||
sql_command="UPDATE \`settings\` SET \`value\` = 'fr' WHERE \`settings\`.\`key\` = 'default_locale'"
|
||||
ynh_mysql_execute_as_root "$sql_command" $db_name
|
||||
;;
|
||||
de)
|
||||
ynh_script_progression --message="Installing German extension..." --time --weight=2
|
||||
ynh_composer_exec --user=$app --phpversion=$php_version --workdir=$final_path --commands="require cbmainz/flarum-de"
|
||||
ynh_script_progression --message="Installing German extension..." --weight=2
|
||||
ynh_composer_exec --user=$app --phpversion=$phpversion --workdir=$final_path --commands="require cbmainz/flarum-de"
|
||||
activate_flarum_extension $db_name "cbmainz-de"
|
||||
sql_command="UPDATE \`settings\` SET \`value\` = 'de' WHERE \`settings\`.\`key\` = 'default_locale'"
|
||||
ynh_mysql_execute_as_root "$sql_command" $db_name
|
||||
|
@ -276,19 +262,24 @@ esac
|
|||
ynh_print_info "You may need to manually enable your language extension in Flarum's admin panel."
|
||||
|
||||
if [ $bazaar_extension -eq 1 ]; then
|
||||
ynh_script_progression --message="Installing Bazaar extension..." --time --weight=2
|
||||
ynh_composer_exec --user=$app --phpversion=$php_version --workdir=$final_path --commands="require extiverse/bazaar"
|
||||
ynh_script_progression --message="Installing Bazaar extension..." --weight=2
|
||||
ynh_composer_exec --user=$app --phpversion=$phpversion --workdir=$final_path --commands="require extiverse/bazaar"
|
||||
fi
|
||||
|
||||
# Clear cache
|
||||
pushd $final_path
|
||||
exec_as $app php$php_version flarum cache:clear
|
||||
exec_as $app php$phpversion flarum cache:clear
|
||||
popd
|
||||
|
||||
# Save version settings
|
||||
ynh_app_setting_set $app project_version $project_version
|
||||
ynh_app_setting_set $app core_version $core_version
|
||||
ynh_app_setting_set $app ssowat_version $ssowat_version
|
||||
|
||||
#=================================================
|
||||
# SETUP LOGROTATE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading logrotate configuration..." --time --weight=1
|
||||
ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1
|
||||
|
||||
# Use logrotate to manage app-specific logfile(s)
|
||||
ynh_use_logrotate --non-append
|
||||
|
@ -298,24 +289,28 @@ ynh_use_logrotate --non-append
|
|||
#=================================================
|
||||
# SECURE FILES AND DIRECTORIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Securing files and directories..."
|
||||
|
||||
### For security reason, any app should set the permissions to root: before anything else.
|
||||
### Then, if write authorization is needed, any access should be given only to directories
|
||||
### that really need such authorization.
|
||||
|
||||
# Set right permissions
|
||||
# Set permissions on app files
|
||||
chown -R $app:www-data $final_path
|
||||
|
||||
#=================================================
|
||||
# SETUP PERMISSIONS
|
||||
# SETUP SSOWAT
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading SSOwat configuration..." --weight=1
|
||||
|
||||
#ynh_script_progression --message="Upgrading permissions configuration..." --time --weight=1
|
||||
# Make app public if necessary
|
||||
if [ $is_public -eq 1 ]
|
||||
then
|
||||
# Everyone can access the app.
|
||||
# The "main" permission is automatically created before the install script.
|
||||
ynh_permission_update --permission "main" --add "visitors"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading nginx web server..." --time --weight=1
|
||||
ynh_script_progression --message="Reloading nginx web server..." --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
|
@ -323,9 +318,4 @@ ynh_systemd_action --service_name=nginx --action=reload
|
|||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_app_setting_set $app php_version $php_version
|
||||
ynh_app_setting_set $app project_version $project_version
|
||||
ynh_app_setting_set $app core_version $core_version
|
||||
ynh_app_setting_set $app ssowat_version $ssowat_version
|
||||
|
||||
ynh_script_progression --message="Upgrade of $app completed" --time --last
|
||||
ynh_script_progression --message="Upgrade of $app completed" --last
|
||||
|
|
Loading…
Reference in a new issue