mirror of
https://github.com/YunoHost-Apps/leed_ynh.git
synced 2024-09-03 19:26:32 +02:00
commit
638864dd9b
13 changed files with 438 additions and 279 deletions
|
@ -8,7 +8,7 @@ location __PATH__/ {
|
||||||
try_files $uri $uri/ index.php;
|
try_files $uri $uri/ index.php;
|
||||||
location ~ [^/]\.php(/|$) {
|
location ~ [^/]\.php(/|$) {
|
||||||
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
|
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
|
||||||
fastcgi_pass unix:/var/run/php5-fpm-__NAME__.sock;
|
fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock;
|
||||||
fastcgi_index index.php;
|
fastcgi_index index.php;
|
||||||
include fastcgi_params;
|
include fastcgi_params;
|
||||||
fastcgi_param REMOTE_USER $remote_user;
|
fastcgi_param REMOTE_USER $remote_user;
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
; Start a new pool named 'www'.
|
; Start a new pool named 'www'.
|
||||||
; the variable $pool can we used in any directive and will be replaced by the
|
; the variable $pool can be used in any directive and will be replaced by the
|
||||||
; pool name ('www' here)
|
; pool name ('www' here)
|
||||||
[__NAMETOCHANGE__]
|
[__NAMETOCHANGE__]
|
||||||
|
|
||||||
; Per pool prefix
|
; Per pool prefix
|
||||||
; It only applies on the following directives:
|
; It only applies on the following directives:
|
||||||
|
; - 'access.log'
|
||||||
; - 'slowlog'
|
; - 'slowlog'
|
||||||
; - 'listen' (unixsocket)
|
; - 'listen' (unixsocket)
|
||||||
; - 'chroot'
|
; - 'chroot'
|
||||||
|
@ -24,28 +25,38 @@ group = __USER__
|
||||||
|
|
||||||
; The address on which to accept FastCGI requests.
|
; The address on which to accept FastCGI requests.
|
||||||
; Valid syntaxes are:
|
; Valid syntaxes are:
|
||||||
; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific address on
|
; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on
|
||||||
; a specific port;
|
; a specific port;
|
||||||
; 'port' - to listen on a TCP socket to all addresses on a
|
; 'port' - to listen on a TCP socket to all addresses on a
|
||||||
; specific port;
|
; 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.
|
; '/path/to/unix/socket' - to listen on a unix socket.
|
||||||
; Note: This value is mandatory.
|
; Note: This value is mandatory.
|
||||||
listen = /var/run/php5-fpm-__NAMETOCHANGE__.sock
|
listen = /var/run/php/php7.0-fpm-__NAMETOCHANGE__.sock
|
||||||
|
|
||||||
; Set listen(2) backlog.
|
; Set listen(2) backlog.
|
||||||
; Default Value: 128 (-1 on FreeBSD and OpenBSD)
|
; Default Value: 511 (-1 on FreeBSD and OpenBSD)
|
||||||
;listen.backlog = 128
|
;listen.backlog = 511
|
||||||
|
|
||||||
; Set permissions for unix socket, if one is used. In Linux, read/write
|
; 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
|
; permissions must be set in order to allow connections from a web server. Many
|
||||||
; BSD-derived systems allow connections regardless of permissions.
|
; BSD-derived systems allow connections regardless of permissions.
|
||||||
; Default Values: user and group are set as the running user
|
; Default Values: user and group are set as the running user
|
||||||
; mode is set to 0660
|
; mode is set to 0660
|
||||||
listen.owner = www-data
|
listen.owner = www-data
|
||||||
listen.group = www-data
|
listen.group = www-data
|
||||||
;listen.mode = 0660
|
;listen.mode = 0660
|
||||||
|
|
||||||
; List of ipv4 addresses of FastCGI clients which are allowed to connect.
|
; When POSIX Access Control Lists are supported you can set them using
|
||||||
|
; these options, value is a comma separated list of user/group names.
|
||||||
|
; When set, listen.owner and listen.group are ignored
|
||||||
|
;listen.acl_users =
|
||||||
|
;listen.acl_groups =
|
||||||
|
|
||||||
|
; List of addresses (IPv4/IPv6) of FastCGI clients which are allowed to connect.
|
||||||
; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original
|
; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original
|
||||||
; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address
|
; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address
|
||||||
; must be separated by a comma. If this value is left blank, connections will be
|
; must be separated by a comma. If this value is left blank, connections will be
|
||||||
|
@ -59,7 +70,13 @@ listen.group = www-data
|
||||||
; - The pool processes will inherit the master process priority
|
; - The pool processes will inherit the master process priority
|
||||||
; unless it specified otherwise
|
; unless it specified otherwise
|
||||||
; Default Value: no set
|
; Default Value: no set
|
||||||
; priority = -19
|
; process.priority = -19
|
||||||
|
|
||||||
|
; 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.
|
; Choose how the process manager will control the number of child processes.
|
||||||
; Possible Values:
|
; Possible Values:
|
||||||
|
@ -117,12 +134,12 @@ pm.max_spare_servers = 3
|
||||||
; Note: Used only when pm is set to 'ondemand'
|
; Note: Used only when pm is set to 'ondemand'
|
||||||
; Default Value: 10s
|
; Default Value: 10s
|
||||||
;pm.process_idle_timeout = 10s;
|
;pm.process_idle_timeout = 10s;
|
||||||
|
|
||||||
; The number of requests each child process should execute before respawning.
|
; The number of requests each child process should execute before respawning.
|
||||||
; This can be useful to work around memory leaks in 3rd party libraries. For
|
; This can be useful to work around memory leaks in 3rd party libraries. For
|
||||||
; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
|
; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
|
||||||
; Default Value: 0
|
; Default Value: 0
|
||||||
pm.max_requests = 500
|
; pm.max_requests = 500
|
||||||
|
|
||||||
; The URI to view the FPM status page. If this value is not set, no URI will be
|
; The URI to view the FPM status page. If this value is not set, no URI will be
|
||||||
; recognized as a status page. It shows the following informations:
|
; recognized as a status page. It shows the following informations:
|
||||||
|
@ -170,7 +187,7 @@ pm.max_requests = 500
|
||||||
;
|
;
|
||||||
; By default the status page only outputs short status. Passing 'full' in the
|
; By default the status page only outputs short status. Passing 'full' in the
|
||||||
; query string will also return status for each pool process.
|
; query string will also return status for each pool process.
|
||||||
; Example:
|
; Example:
|
||||||
; http://www.foo.bar/status?full
|
; http://www.foo.bar/status?full
|
||||||
; http://www.foo.bar/status?json&full
|
; http://www.foo.bar/status?json&full
|
||||||
; http://www.foo.bar/status?html&full
|
; http://www.foo.bar/status?html&full
|
||||||
|
@ -215,7 +232,7 @@ pm.max_requests = 500
|
||||||
; last request memory: 0
|
; last request memory: 0
|
||||||
;
|
;
|
||||||
; Note: There is a real-time FPM status monitoring sample web page available
|
; Note: There is a real-time FPM status monitoring sample web page available
|
||||||
; It's available in: ${prefix}/share/fpm/status.html
|
; It's available in: /usr/share/php/7.0/fpm/status.html
|
||||||
;
|
;
|
||||||
; Note: The value must start with a leading slash (/). The value can be
|
; Note: The value must start with a leading slash (/). The value can be
|
||||||
; anything, but it may not be a good idea to use the .php extension or it
|
; anything, but it may not be a good idea to use the .php extension or it
|
||||||
|
@ -275,7 +292,7 @@ pm.max_requests = 500
|
||||||
; - %{megabytes}M
|
; - %{megabytes}M
|
||||||
; - %{mega}M
|
; - %{mega}M
|
||||||
; %n: pool name
|
; %n: pool name
|
||||||
; %o: ouput header
|
; %o: output header
|
||||||
; it must be associated with embraces to specify the name of the header:
|
; it must be associated with embraces to specify the name of the header:
|
||||||
; - %{Content-Type}o
|
; - %{Content-Type}o
|
||||||
; - %{X-Powered-By}o
|
; - %{X-Powered-By}o
|
||||||
|
@ -283,7 +300,7 @@ pm.max_requests = 500
|
||||||
; - ....
|
; - ....
|
||||||
; %p: PID of the child that serviced the request
|
; %p: PID of the child that serviced the request
|
||||||
; %P: PID of the parent 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 query string
|
||||||
; %Q: the '?' character if query string exists
|
; %Q: the '?' character if query string exists
|
||||||
; %r: the request URI (without the query string, see %q and %Q)
|
; %r: the request URI (without the query string, see %q and %Q)
|
||||||
; %R: remote IP address
|
; %R: remote IP address
|
||||||
|
@ -291,47 +308,51 @@ pm.max_requests = 500
|
||||||
; %t: server time the request was received
|
; %t: server time the request was received
|
||||||
; it can accept a strftime(3) format:
|
; it can accept a strftime(3) format:
|
||||||
; %d/%b/%Y:%H:%M:%S %z (default)
|
; %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)
|
; %T: time the log has been written (the request has finished)
|
||||||
; it can accept a strftime(3) format:
|
; it can accept a strftime(3) format:
|
||||||
; %d/%b/%Y:%H:%M:%S %z (default)
|
; %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
|
; %u: remote user
|
||||||
;
|
;
|
||||||
; Default: "%R - %u %t \"%m %r\" %s"
|
; Default: "%R - %u %t \"%m %r\" %s"
|
||||||
;access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%"
|
; access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%"
|
||||||
|
|
||||||
; The log file for slow requests
|
; The log file for slow requests
|
||||||
; Default Value: not set
|
; Default Value: not set
|
||||||
; Note: slowlog is mandatory if request_slowlog_timeout is set
|
; Note: slowlog is mandatory if request_slowlog_timeout is set
|
||||||
slowlog = /var/log/nginx/__NAMETOCHANGE__.slow.log
|
; slowlog = log/$pool.log.slow
|
||||||
|
|
||||||
; The timeout for serving a single request after which a PHP backtrace will be
|
; The timeout for serving a single request after which a PHP backtrace will be
|
||||||
; dumped to the 'slowlog' file. A value of '0s' means 'off'.
|
; dumped to the 'slowlog' file. A value of '0s' means 'off'.
|
||||||
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
|
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
|
||||||
; Default Value: 0
|
; Default Value: 0
|
||||||
request_slowlog_timeout = 5s
|
;request_slowlog_timeout = 0
|
||||||
|
|
||||||
; The timeout for serving a single request after which the worker process will
|
; 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
|
; 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'.
|
; 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)
|
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
|
||||||
; Default Value: 0
|
; Default Value: 0
|
||||||
request_terminate_timeout = 1d
|
request_terminate_timeout = 1d
|
||||||
|
|
||||||
; Set open file descriptor rlimit.
|
; Set open file descriptor rlimit.
|
||||||
; Default Value: system defined value
|
; Default Value: system defined value
|
||||||
;rlimit_files = 1024
|
;rlimit_files = 1024
|
||||||
|
|
||||||
; Set max core size rlimit.
|
; Set max core size rlimit.
|
||||||
; Possible Values: 'unlimited' or an integer greater or equal to 0
|
; Possible Values: 'unlimited' or an integer greater or equal to 0
|
||||||
; Default Value: system defined value
|
; Default Value: system defined value
|
||||||
;rlimit_core = 0
|
;rlimit_core = 0
|
||||||
|
|
||||||
; Chroot to this directory at the start. This value must be defined as an
|
; Chroot to this directory at the start. This value must be defined as an
|
||||||
; absolute path. When this value is not set, chroot is not used.
|
; absolute path. When this value is not set, chroot is not used.
|
||||||
; Note: you can prefix with '$prefix' to chroot to the pool prefix or one
|
; Note: you can prefix with '$prefix' to chroot to the pool prefix or one
|
||||||
; of its subdirectories. If the pool prefix is not set, the global prefix
|
; of its subdirectories. If the pool prefix is not set, the global prefix
|
||||||
; will be used instead.
|
; will be used instead.
|
||||||
; Note: chrooting is a great security feature and should be used whenever
|
; Note: chrooting is a great security feature and should be used whenever
|
||||||
; possible. However, all PHP paths will be relative to the chroot
|
; possible. However, all PHP paths will be relative to the chroot
|
||||||
; (error_log, sessions.save_path, ...).
|
; (error_log, sessions.save_path, ...).
|
||||||
; Default Value: not set
|
; Default Value: not set
|
||||||
|
@ -347,16 +368,25 @@ chdir = __FINALPATH__
|
||||||
; Note: on highloaded environement, this can cause some delay in the page
|
; Note: on highloaded environement, this can cause some delay in the page
|
||||||
; process time (several ms).
|
; process time (several ms).
|
||||||
; Default Value: no
|
; Default Value: no
|
||||||
catch_workers_output = yes
|
;catch_workers_output = yes
|
||||||
|
|
||||||
|
; Clear environment in FPM workers
|
||||||
|
; Prevents arbitrary environment variables from reaching FPM worker processes
|
||||||
|
; by clearing the environment in workers before env vars specified in this
|
||||||
|
; pool configuration are added.
|
||||||
|
; Setting to "no" will make all environment variables available to PHP code
|
||||||
|
; via getenv(), $_ENV and $_SERVER.
|
||||||
|
; Default Value: yes
|
||||||
|
;clear_env = no
|
||||||
|
|
||||||
; Limits the extensions of the main script FPM will allow to parse. This can
|
; 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
|
; 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
|
; FPM to .php extensions to prevent malicious users to use other extensions to
|
||||||
; exectute php code.
|
; execute php code.
|
||||||
; Note: set an empty value to allow all extensions.
|
; Note: set an empty value to allow all extensions.
|
||||||
; Default Value: .php
|
; Default Value: .php
|
||||||
;security.limit_extensions = .php .php3 .php4 .php5
|
;security.limit_extensions = .php .php3 .php4 .php5 .php7
|
||||||
|
|
||||||
; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from
|
; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from
|
||||||
; the current environment.
|
; the current environment.
|
||||||
; Default Value: clean env
|
; Default Value: clean env
|
||||||
|
@ -370,7 +400,7 @@ catch_workers_output = yes
|
||||||
; overwrite the values previously defined in the php.ini. The directives are the
|
; overwrite the values previously defined in the php.ini. The directives are the
|
||||||
; same as the PHP SAPI:
|
; same as the PHP SAPI:
|
||||||
; php_value/php_flag - you can set classic ini defines which can
|
; php_value/php_flag - you can set classic ini defines which can
|
||||||
; be overwritten from PHP call 'ini_set'.
|
; be overwritten from PHP call 'ini_set'.
|
||||||
; php_admin_value/php_admin_flag - these directives won't be overwritten by
|
; php_admin_value/php_admin_flag - these directives won't be overwritten by
|
||||||
; PHP call 'ini_set'
|
; PHP call 'ini_set'
|
||||||
; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no.
|
; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no.
|
||||||
|
|
|
@ -31,6 +31,28 @@
|
||||||
"type": "bool",
|
"type": "bool",
|
||||||
"default": true
|
"default": true
|
||||||
}]
|
}]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Global configuration",
|
||||||
|
"id": "global_config",
|
||||||
|
"options": [{
|
||||||
|
"name": "Send HTML email to admin ?",
|
||||||
|
"help": "Allow app scripts to send HTML mails instead of plain text.",
|
||||||
|
"id": "email_type",
|
||||||
|
"type": "bool",
|
||||||
|
"default": true
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Global configuration",
|
||||||
|
"id": "global_config",
|
||||||
|
"options": [{
|
||||||
|
"name": "Send HTML email to admin ?",
|
||||||
|
"help": "Allow app scripts to send HTML mails instead of plain text.",
|
||||||
|
"id": "email_type",
|
||||||
|
"type": "bool",
|
||||||
|
"default": true
|
||||||
|
}]
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
"en": "Leed is a minimalistic RSS feed aggregator which allows quick and non-intrusive reading of feeds.",
|
"en": "Leed is a minimalistic RSS feed aggregator which allows quick and non-intrusive reading of feeds.",
|
||||||
"fr": "Leed est un agrégateur RSS minimaliste qui permet la consultation de flux RSS de manière rapide et non intrusive."
|
"fr": "Leed est un agrégateur RSS minimaliste qui permet la consultation de flux RSS de manière rapide et non intrusive."
|
||||||
},
|
},
|
||||||
"version": "1.8.3~ynh5",
|
"version": "1.8.3~ynh6",
|
||||||
"url": "http://leed.idleman.fr/",
|
"url": "http://leed.idleman.fr/",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"maintainer": {
|
"maintainer": {
|
||||||
|
@ -14,12 +14,12 @@
|
||||||
"email": "maniackc_dev@crudelis.fr"
|
"email": "maniackc_dev@crudelis.fr"
|
||||||
},
|
},
|
||||||
"requirements": {
|
"requirements": {
|
||||||
"yunohost": ">= 3.3.3"
|
"yunohost": ">= 3.4"
|
||||||
},
|
},
|
||||||
"multi_instance": true,
|
"multi_instance": true,
|
||||||
"services": [
|
"services": [
|
||||||
"nginx",
|
"nginx",
|
||||||
"php5-fpm",
|
"php7.0-fpm",
|
||||||
"mysql"
|
"mysql"
|
||||||
],
|
],
|
||||||
"arguments": {
|
"arguments": {
|
||||||
|
|
|
@ -52,210 +52,6 @@ bool_to_true_false () {
|
||||||
# FUTUR OFFICIAL HELPERS
|
# FUTUR OFFICIAL HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Internal helper design to allow helpers to use getopts to manage their arguments
|
|
||||||
#
|
|
||||||
# [internal]
|
|
||||||
#
|
|
||||||
# example: function my_helper()
|
|
||||||
# {
|
|
||||||
# declare -Ar args_array=( [a]=arg1= [b]=arg2= [c]=arg3 )
|
|
||||||
# local arg1
|
|
||||||
# local arg2
|
|
||||||
# local arg3
|
|
||||||
# ynh_handle_getopts_args "$@"
|
|
||||||
#
|
|
||||||
# [...]
|
|
||||||
# }
|
|
||||||
# my_helper --arg1 "val1" -b val2 -c
|
|
||||||
#
|
|
||||||
# usage: ynh_handle_getopts_args "$@"
|
|
||||||
# | arg: $@ - Simply "$@" to tranfert all the positionnal arguments to the function
|
|
||||||
#
|
|
||||||
# This helper need an array, named "args_array" with all the arguments used by the helper
|
|
||||||
# that want to use ynh_handle_getopts_args
|
|
||||||
# Be carreful, this array has to be an associative array, as the following example:
|
|
||||||
# declare -Ar args_array=( [a]=arg1 [b]=arg2= [c]=arg3 )
|
|
||||||
# Let's explain this array:
|
|
||||||
# a, b and c are short options, -a, -b and -c
|
|
||||||
# arg1, arg2 and arg3 are the long options associated to the previous short ones. --arg1, --arg2 and --arg3
|
|
||||||
# For each option, a short and long version has to be defined.
|
|
||||||
# Let's see something more significant
|
|
||||||
# declare -Ar args_array=( [u]=user [f]=finalpath= [d]=database )
|
|
||||||
#
|
|
||||||
# NB: Because we're using 'declare' without -g, the array will be declared as a local variable.
|
|
||||||
#
|
|
||||||
# Please keep in mind that the long option will be used as a variable to store the values for this option.
|
|
||||||
# For the previous example, that means that $finalpath will be fill with the value given as argument for this option.
|
|
||||||
#
|
|
||||||
# Also, in the previous example, finalpath has a '=' at the end. That means this option need a value.
|
|
||||||
# So, the helper has to be call with --finalpath /final/path, --finalpath=/final/path or -f /final/path, the variable $finalpath will get the value /final/path
|
|
||||||
# If there's many values for an option, -f /final /path, the value will be separated by a ';' $finalpath=/final;/path
|
|
||||||
# For an option without value, like --user in the example, the helper can be called only with --user or -u. $user will then get the value 1.
|
|
||||||
#
|
|
||||||
# To keep a retrocompatibility, a package can still call a helper, using getopts, with positional arguments.
|
|
||||||
# The "legacy mode" will manage the positional arguments and fill the variable in the same order than they are given in $args_array.
|
|
||||||
# e.g. for `my_helper "val1" val2`, arg1 will be filled with val1, and arg2 with val2.
|
|
||||||
ynh_handle_getopts_args () {
|
|
||||||
# Manage arguments only if there's some provided
|
|
||||||
set +x
|
|
||||||
if [ $# -ne 0 ]
|
|
||||||
then
|
|
||||||
# Store arguments in an array to keep each argument separated
|
|
||||||
local arguments=("$@")
|
|
||||||
|
|
||||||
# For each option in the array, reduce to short options for getopts (e.g. for [u]=user, --user will be -u)
|
|
||||||
# And built parameters string for getopts
|
|
||||||
# ${!args_array[@]} is the list of all option_flags in the array (An option_flag is 'u' in [u]=user, user is a value)
|
|
||||||
local getopts_parameters=""
|
|
||||||
local option_flag=""
|
|
||||||
for option_flag in "${!args_array[@]}"
|
|
||||||
do
|
|
||||||
# Concatenate each option_flags of the array to build the string of arguments for getopts
|
|
||||||
# Will looks like 'abcd' for -a -b -c -d
|
|
||||||
# If the value of an option_flag finish by =, it's an option with additionnal values. (e.g. --user bob or -u bob)
|
|
||||||
# Check the last character of the value associate to the option_flag
|
|
||||||
if [ "${args_array[$option_flag]: -1}" = "=" ]
|
|
||||||
then
|
|
||||||
# For an option with additionnal values, add a ':' after the letter for getopts.
|
|
||||||
getopts_parameters="${getopts_parameters}${option_flag}:"
|
|
||||||
else
|
|
||||||
getopts_parameters="${getopts_parameters}${option_flag}"
|
|
||||||
fi
|
|
||||||
# Check each argument given to the function
|
|
||||||
local arg=""
|
|
||||||
# ${#arguments[@]} is the size of the array
|
|
||||||
for arg in `seq 0 $(( ${#arguments[@]} - 1 ))`
|
|
||||||
do
|
|
||||||
# And replace long option (value of the option_flag) by the short option, the option_flag itself
|
|
||||||
# (e.g. for [u]=user, --user will be -u)
|
|
||||||
# Replace long option with =
|
|
||||||
arguments[arg]="${arguments[arg]//--${args_array[$option_flag]}/-${option_flag} }"
|
|
||||||
# And long option without =
|
|
||||||
arguments[arg]="${arguments[arg]//--${args_array[$option_flag]%=}/-${option_flag}}"
|
|
||||||
done
|
|
||||||
done
|
|
||||||
|
|
||||||
# Read and parse all the arguments
|
|
||||||
# Use a function here, to use standart arguments $@ and be able to use shift.
|
|
||||||
parse_arg () {
|
|
||||||
# Read all arguments, until no arguments are left
|
|
||||||
while [ $# -ne 0 ]
|
|
||||||
do
|
|
||||||
# Initialize the index of getopts
|
|
||||||
OPTIND=1
|
|
||||||
# Parse with getopts only if the argument begin by -, that means the argument is an option
|
|
||||||
# getopts will fill $parameter with the letter of the option it has read.
|
|
||||||
local parameter=""
|
|
||||||
getopts ":$getopts_parameters" parameter || true
|
|
||||||
|
|
||||||
if [ "$parameter" = "?" ]
|
|
||||||
then
|
|
||||||
ynh_die --message="Invalid argument: -${OPTARG:-}"
|
|
||||||
elif [ "$parameter" = ":" ]
|
|
||||||
then
|
|
||||||
ynh_die --message="-$OPTARG parameter requires an argument."
|
|
||||||
else
|
|
||||||
local shift_value=1
|
|
||||||
# Use the long option, corresponding to the short option read by getopts, as a variable
|
|
||||||
# (e.g. for [u]=user, 'user' will be used as a variable)
|
|
||||||
# Also, remove '=' at the end of the long option
|
|
||||||
# The variable name will be stored in 'option_var'
|
|
||||||
local option_var="${args_array[$parameter]%=}"
|
|
||||||
# If this option doesn't take values
|
|
||||||
# if there's a '=' at the end of the long option name, this option takes values
|
|
||||||
if [ "${args_array[$parameter]: -1}" != "=" ]
|
|
||||||
then
|
|
||||||
# 'eval ${option_var}' will use the content of 'option_var'
|
|
||||||
eval ${option_var}=1
|
|
||||||
else
|
|
||||||
# Read all other arguments to find multiple value for this option.
|
|
||||||
# Load args in a array
|
|
||||||
local all_args=("$@")
|
|
||||||
|
|
||||||
# If the first argument is longer than 2 characters,
|
|
||||||
# There's a value attached to the option, in the same array cell
|
|
||||||
if [ ${#all_args[0]} -gt 2 ]; then
|
|
||||||
# Remove the option and the space, so keep only the value itself.
|
|
||||||
all_args[0]="${all_args[0]#-${parameter} }"
|
|
||||||
# Reduce the value of shift, because the option has been removed manually
|
|
||||||
shift_value=$(( shift_value - 1 ))
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Declare the content of option_var as a variable.
|
|
||||||
eval ${option_var}=""
|
|
||||||
# Then read the array value per value
|
|
||||||
local i
|
|
||||||
for i in `seq 0 $(( ${#all_args[@]} - 1 ))`
|
|
||||||
do
|
|
||||||
# If this argument is an option, end here.
|
|
||||||
if [ "${all_args[$i]:0:1}" == "-" ]
|
|
||||||
then
|
|
||||||
# Ignore the first value of the array, which is the option itself
|
|
||||||
if [ "$i" -ne 0 ]; then
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
# Else, add this value to this option
|
|
||||||
# Each value will be separated by ';'
|
|
||||||
if [ -n "${!option_var}" ]
|
|
||||||
then
|
|
||||||
# If there's already another value for this option, add a ; before adding the new value
|
|
||||||
eval ${option_var}+="\;"
|
|
||||||
fi
|
|
||||||
eval ${option_var}+=\"${all_args[$i]}\"
|
|
||||||
shift_value=$(( shift_value + 1 ))
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Shift the parameter and its argument(s)
|
|
||||||
shift $shift_value
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
# LEGACY MODE
|
|
||||||
# Check if there's getopts arguments
|
|
||||||
if [ "${arguments[0]:0:1}" != "-" ]
|
|
||||||
then
|
|
||||||
# If not, enter in legacy mode and manage the arguments as positionnal ones..
|
|
||||||
# Dot not echo, to prevent to go through a helper output. But print only in the log.
|
|
||||||
set -x; echo "! Helper used in legacy mode !" > /dev/null; set +x
|
|
||||||
local i
|
|
||||||
for i in `seq 0 $(( ${#arguments[@]} -1 ))`
|
|
||||||
do
|
|
||||||
# Try to use legacy_args as a list of option_flag of the array args_array
|
|
||||||
# Otherwise, fallback to getopts_parameters to get the option_flag. But an associative arrays isn't always sorted in the correct order...
|
|
||||||
# Remove all ':' in getopts_parameters
|
|
||||||
getopts_parameters=${legacy_args:-${getopts_parameters//:}}
|
|
||||||
# Get the option_flag from getopts_parameters, by using the option_flag according to the position of the argument.
|
|
||||||
option_flag=${getopts_parameters:$i:1}
|
|
||||||
if [ -z "$option_flag" ]; then
|
|
||||||
ynh_print_warn --message="Too many arguments ! \"${arguments[$i]}\" will be ignored."
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
# Use the long option, corresponding to the option_flag, as a variable
|
|
||||||
# (e.g. for [u]=user, 'user' will be used as a variable)
|
|
||||||
# Also, remove '=' at the end of the long option
|
|
||||||
# The variable name will be stored in 'option_var'
|
|
||||||
local option_var="${args_array[$option_flag]%=}"
|
|
||||||
|
|
||||||
# Store each value given as argument in the corresponding variable
|
|
||||||
# The values will be stored in the same order than $args_array
|
|
||||||
eval ${option_var}+=\"${arguments[$i]}\"
|
|
||||||
done
|
|
||||||
unset legacy_args
|
|
||||||
else
|
|
||||||
# END LEGACY MODE
|
|
||||||
# Call parse_arg and pass the modified list of args as an array of arguments.
|
|
||||||
parse_arg "${arguments[@]}"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
set -x
|
|
||||||
}
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# Install or update the main directory yunohost.multimedia
|
# Install or update the main directory yunohost.multimedia
|
||||||
#
|
#
|
||||||
# usage: ynh_multimedia_build_main_dir
|
# usage: ynh_multimedia_build_main_dir
|
||||||
|
@ -517,27 +313,6 @@ ynh_check_app_version_changed () {
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Delete a file checksum from the app settings
|
|
||||||
#
|
|
||||||
# $app should be defined when calling this helper
|
|
||||||
#
|
|
||||||
# usage: ynh_remove_file_checksum file
|
|
||||||
# | arg: -f, --file= - The file for which the checksum will be deleted
|
|
||||||
ynh_delete_file_checksum () {
|
|
||||||
# Declare an array to define the options of this helper.
|
|
||||||
declare -Ar args_array=( [f]=file= )
|
|
||||||
local file
|
|
||||||
# Manage arguments with getopts
|
|
||||||
ynh_handle_getopts_args "$@"
|
|
||||||
|
|
||||||
local checksum_setting_name=checksum_${file//[\/ ]/_} # Replace all '/' and ' ' by '_'
|
|
||||||
ynh_app_setting_delete $app $checksum_setting_name
|
|
||||||
}
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# EXPERIMENTAL HELPERS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# Start (or other actions) a service, print a log in case of failure and optionnaly wait until the service is completely started
|
# Start (or other actions) a service, print a log in case of failure and optionnaly wait until the service is completely started
|
||||||
#
|
#
|
||||||
# usage: ynh_systemd_action [-n service_name] [-a action] [ [-l "line to match"] [-p log_path] [-t timeout] [-e length] ]
|
# usage: ynh_systemd_action [-n service_name] [-a action] [ [-l "line to match"] [-p log_path] [-t timeout] [-e length] ]
|
||||||
|
@ -629,10 +404,92 @@ ynh_clean_check_starting () {
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
# Print a message as INFO and show progression during an app script
|
||||||
|
#
|
||||||
|
# usage: ynh_script_progression --message=message [--weight=weight] [--time]
|
||||||
|
# | arg: -m, --message= - The text to print
|
||||||
|
# | arg: -w, --weight= - The weight for this progression. This value is 1 by default. Use a bigger value for a longer part of the script.
|
||||||
|
# | arg: -t, --time= - Print the execution time since the last call to this helper. Especially usefull to define weights.
|
||||||
|
# | arg: -l, --last= - Use for the last call of the helper, to fill te progression bar.
|
||||||
|
increment_progression=0
|
||||||
|
previous_weight=0
|
||||||
|
# Define base_time when the file is sourced
|
||||||
|
base_time=$(date +%s)
|
||||||
|
ynh_script_progression () {
|
||||||
|
# Declare an array to define the options of this helper.
|
||||||
|
declare -Ar args_array=( [m]=message= [w]=weight= [t]=time [l]=last )
|
||||||
|
local message
|
||||||
|
local weight
|
||||||
|
local time
|
||||||
|
local last
|
||||||
|
# Manage arguments with getopts
|
||||||
|
ynh_handle_getopts_args "$@"
|
||||||
|
weight=${weight:-1}
|
||||||
|
time=${time:-0}
|
||||||
|
last=${last:-0}
|
||||||
|
|
||||||
|
# Get execution time since the last $base_time
|
||||||
|
local exec_time=$(( $(date +%s) - $base_time ))
|
||||||
|
base_time=$(date +%s)
|
||||||
|
|
||||||
|
# Get the number of occurrences of 'ynh_script_progression' in the script. Except those are commented.
|
||||||
|
local helper_calls="$(grep --count "^[^#]*ynh_script_progression" $0)"
|
||||||
|
# Get the number of call with a weight value
|
||||||
|
local weight_calls=$(grep --perl-regexp --count "^[^#]*ynh_script_progression.*(--weight|-w )" $0)
|
||||||
|
|
||||||
|
# Get the weight of each occurrences of 'ynh_script_progression' in the script using --weight
|
||||||
|
local weight_valuesA="$(grep --perl-regexp "^[^#]*ynh_script_progression.*--weight" $0 | sed 's/.*--weight[= ]\([[:digit:]].*\)/\1/g')"
|
||||||
|
# Get the weight of each occurrences of 'ynh_script_progression' in the script using -w
|
||||||
|
local weight_valuesB="$(grep --perl-regexp "^[^#]*ynh_script_progression.*-w " $0 | sed 's/.*-w[= ]\([[:digit:]].*\)/\1/g')"
|
||||||
|
# Each value will be on a different line.
|
||||||
|
# Remove each 'end of line' and replace it by a '+' to sum the values.
|
||||||
|
local weight_values=$(( $(echo "$weight_valuesA" | tr '\n' '+') + $(echo "$weight_valuesB" | tr '\n' '+') 0 ))
|
||||||
|
|
||||||
|
# max_progression is a total number of calls to this helper.
|
||||||
|
# Less the number of calls with a weight value.
|
||||||
|
# Plus the total of weight values
|
||||||
|
local max_progression=$(( $helper_calls - $weight_calls + $weight_values ))
|
||||||
|
|
||||||
|
# Increment each execution of ynh_script_progression in this script by the weight of the previous call.
|
||||||
|
increment_progression=$(( $increment_progression + $previous_weight ))
|
||||||
|
# Store the weight of the current call in $previous_weight for next call
|
||||||
|
previous_weight=$weight
|
||||||
|
|
||||||
|
# Set the scale of the progression bar
|
||||||
|
local scale=20
|
||||||
|
# progress_string(1,2) should have the size of the scale.
|
||||||
|
local progress_string1="####################"
|
||||||
|
local progress_string0="...................."
|
||||||
|
|
||||||
|
# Reduce $increment_progression to the size of the scale
|
||||||
|
if [ $last -eq 0 ]
|
||||||
|
then
|
||||||
|
local effective_progression=$(( $increment_progression * $scale / $max_progression ))
|
||||||
|
# If last is specified, fill immediately the progression_bar
|
||||||
|
else
|
||||||
|
local effective_progression=$scale
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Build $progression_bar from progress_string(1,2) according to $effective_progression
|
||||||
|
local progression_bar="${progress_string1:0:$effective_progression}${progress_string0:0:$(( $scale - $effective_progression ))}"
|
||||||
|
|
||||||
|
local print_exec_time=""
|
||||||
|
if [ $time -eq 1 ]
|
||||||
|
then
|
||||||
|
print_exec_time=" [$(date +%Hh%Mm,%Ss --date="0 + $exec_time sec")]"
|
||||||
|
fi
|
||||||
|
|
||||||
|
ynh_print_info "[$progression_bar] > ${message}${print_exec_time}"
|
||||||
|
}
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# EXPERIMENTAL HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# Send an email to inform the administrator
|
# Send an email to inform the administrator
|
||||||
#
|
#
|
||||||
# usage: ynh_send_readme_to_admin --app_message=app_message [--recipients=recipients] [--type=type]
|
# usage: ynh_send_readme_to_admin --app_message=app_message [--recipients=recipients] [--type=type]
|
||||||
# | arg: -m --app_message= - The message to send to the administrator.
|
# | arg: -m --app_message= - The file with the content to send to the administrator.
|
||||||
# | arg: -r, --recipients= - The recipients of this email. Use spaces to separate multiples recipients. - default: root
|
# | arg: -r, --recipients= - The recipients of this email. Use spaces to separate multiples recipients. - default: root
|
||||||
# example: "root admin@domain"
|
# example: "root admin@domain"
|
||||||
# If you give the name of a YunoHost user, ynh_send_readme_to_admin will find its email adress for you
|
# If you give the name of a YunoHost user, ynh_send_readme_to_admin will find its email adress for you
|
||||||
|
@ -645,11 +502,16 @@ ynh_send_readme_to_admin() {
|
||||||
local recipients
|
local recipients
|
||||||
local type
|
local type
|
||||||
# Manage arguments with getopts
|
# Manage arguments with getopts
|
||||||
|
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
app_message="${app_message:-...No specific information...}"
|
app_message="${app_message:-}"
|
||||||
recipients="${recipients:-root}"
|
recipients="${recipients:-root}"
|
||||||
type="${type:-install}"
|
type="${type:-install}"
|
||||||
|
|
||||||
|
# Get the value of admin_mail_html
|
||||||
|
admin_mail_html=$(ynh_app_setting_get $app admin_mail_html)
|
||||||
|
admin_mail_html="${admin_mail_html:-0}"
|
||||||
|
|
||||||
# Retrieve the email of users
|
# Retrieve the email of users
|
||||||
find_mails () {
|
find_mails () {
|
||||||
local list_mails="$1"
|
local list_mails="$1"
|
||||||
|
@ -696,12 +558,53 @@ ynh_send_readme_to_admin() {
|
||||||
|
|
||||||
Specific information for the application $app.
|
Specific information for the application $app.
|
||||||
|
|
||||||
$app_message
|
$(if [ -n "$app_message" ]
|
||||||
|
then
|
||||||
|
cat "$app_message"
|
||||||
|
else
|
||||||
|
echo "...No specific information..."
|
||||||
|
fi)
|
||||||
|
|
||||||
---
|
---
|
||||||
Automatic diagnosis data from YunoHost
|
Automatic diagnosis data from YunoHost
|
||||||
|
|
||||||
$(yunohost tools diagnosis | grep -B 100 "services:" | sed '/services:/d')"
|
__PRE_TAG1__$(yunohost tools diagnosis | grep -B 100 "services:" | sed '/services:/d')__PRE_TAG2__"
|
||||||
|
|
||||||
|
# Store the message into a file for further modifications.
|
||||||
|
echo "$mail_message" > mail_to_send
|
||||||
|
|
||||||
|
# If a html email is required. Apply html tags to the message.
|
||||||
|
if [ "$admin_mail_html" -eq 1 ]
|
||||||
|
then
|
||||||
|
# Insert 'br' tags at each ending of lines.
|
||||||
|
ynh_replace_string "$" "<br>" mail_to_send
|
||||||
|
|
||||||
|
# Insert starting HTML tags
|
||||||
|
sed --in-place '1s@^@<!DOCTYPE html>\n<html>\n<head></head>\n<body>\n@' mail_to_send
|
||||||
|
|
||||||
|
# Keep tabulations
|
||||||
|
ynh_replace_string " " "\ \ " mail_to_send
|
||||||
|
ynh_replace_string "\t" "\ \ " mail_to_send
|
||||||
|
|
||||||
|
# Insert url links tags
|
||||||
|
ynh_replace_string "__URL_TAG1__\(.*\)__URL_TAG2__\(.*\)__URL_TAG3__" "<a href=\"\2\">\1</a>" mail_to_send
|
||||||
|
|
||||||
|
# Insert pre tags
|
||||||
|
ynh_replace_string "__PRE_TAG1__" "<pre>" mail_to_send
|
||||||
|
ynh_replace_string "__PRE_TAG2__" "<\pre>" mail_to_send
|
||||||
|
|
||||||
|
# Insert finishing HTML tags
|
||||||
|
echo -e "\n</body>\n</html>" >> mail_to_send
|
||||||
|
|
||||||
|
# Otherwise, remove tags to keep a plain text.
|
||||||
|
else
|
||||||
|
# Remove URL tags
|
||||||
|
ynh_replace_string "__URL_TAG[1,3]__" "" mail_to_send
|
||||||
|
ynh_replace_string "__URL_TAG2__" ": " mail_to_send
|
||||||
|
|
||||||
|
# Remove PRE tags
|
||||||
|
ynh_replace_string "__PRE_TAG[1-2]__" "" mail_to_send
|
||||||
|
fi
|
||||||
|
|
||||||
# Define binary to use for mail command
|
# Define binary to use for mail command
|
||||||
if [ -e /usr/bin/bsd-mailx ]
|
if [ -e /usr/bin/bsd-mailx ]
|
||||||
|
@ -711,8 +614,15 @@ $(yunohost tools diagnosis | grep -B 100 "services:" | sed '/services:/d')"
|
||||||
local mail_bin=/usr/bin/mail.mailutils
|
local mail_bin=/usr/bin/mail.mailutils
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "$admin_mail_html" -eq 1 ]
|
||||||
|
then
|
||||||
|
content_type="text/html"
|
||||||
|
else
|
||||||
|
content_type="text/plain"
|
||||||
|
fi
|
||||||
|
|
||||||
# Send the email to the recipients
|
# Send the email to the recipients
|
||||||
echo "$mail_message" | $mail_bin -a "Content-Type: text/plain; charset=UTF-8" -s "$mail_subject" "$recipients"
|
cat mail_to_send | $mail_bin -a "Content-Type: $content_type; charset=UTF-8" -s "$mail_subject" "$recipients"
|
||||||
}
|
}
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -883,3 +793,65 @@ ynh_download_file () {
|
||||||
# Move the file to its destination
|
# Move the file to its destination
|
||||||
mv $filename $dest_dir
|
mv $filename $dest_dir
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Create a changelog for an app after an upgrade.
|
||||||
|
#
|
||||||
|
# The changelog is printed into the file ./changelog for the time of the upgrade.
|
||||||
|
#
|
||||||
|
# In order to create a changelog, ynh_app_changelog will get info from /etc/yunohost/apps/$app/status.json
|
||||||
|
# In order to find the current commit use by the app.
|
||||||
|
# The remote repository, and the branch.
|
||||||
|
# The changelog will be only the commits since the current revision.
|
||||||
|
#
|
||||||
|
# Because of the need of those info, ynh_app_changelog works only
|
||||||
|
# with apps that have been installed from a list.
|
||||||
|
#
|
||||||
|
# usage: ynh_app_changelog
|
||||||
|
ynh_app_changelog () {
|
||||||
|
get_value_from_settings ()
|
||||||
|
{
|
||||||
|
local value="$1"
|
||||||
|
# Extract a value from the status.json file of an installed app.
|
||||||
|
|
||||||
|
grep "$value\": \"" /etc/yunohost/apps/$app/status.json | sed "s/.*$value\": \"\([^\"]*\).*/\1/"
|
||||||
|
}
|
||||||
|
|
||||||
|
local current_revision="$(get_value_from_settings revision)"
|
||||||
|
local repo="$(get_value_from_settings url)"
|
||||||
|
local branch="$(get_value_from_settings branch)"
|
||||||
|
# ynh_app_changelog works only with an app installed from a list.
|
||||||
|
if [ -z "$current_revision" ] || [ -z "$repo" ] || [ -z "$branch" ]
|
||||||
|
then
|
||||||
|
ynh_print_warn "Unable to build the changelog..."
|
||||||
|
touch changelog
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Fetch the history of the repository, without cloning it
|
||||||
|
mkdir git_history
|
||||||
|
(cd git_history
|
||||||
|
ynh_exec_warn_less git init
|
||||||
|
ynh_exec_warn_less git remote add -f origin $repo
|
||||||
|
# Get the line of the current commit of the installed app in the history.
|
||||||
|
local line_to_head=$(git log origin/$branch --pretty=oneline | grep --line-number "$current_revision" | cut -d':' -f1)
|
||||||
|
# Cut the history before the current commit, to keep only newer commits.
|
||||||
|
# Then use sed to reorganise each lines and have a nice list of commits since the last upgrade.
|
||||||
|
# This list is redirected into the file changelog
|
||||||
|
git log origin/$branch --pretty=oneline | head --lines=$(($line_to_head-1)) | sed 's/^\([[:alnum:]]*\)\(.*\)/*(\1) -> \2/g' > ../changelog)
|
||||||
|
# Remove 'Merge pull request' commits
|
||||||
|
sed -i '/Merge pull request #[[:digit:]]* from/d' changelog
|
||||||
|
# As well as conflict resolving commits
|
||||||
|
sed -i '/Merge branch .* into/d' changelog
|
||||||
|
|
||||||
|
# Get the value of admin_mail_html
|
||||||
|
admin_mail_html=$(ynh_app_setting_get $app admin_mail_html)
|
||||||
|
admin_mail_html="${admin_mail_html:-0}"
|
||||||
|
|
||||||
|
# If a html email is required. Apply html to the changelog.
|
||||||
|
if [ "$admin_mail_html" -eq 1 ]
|
||||||
|
then
|
||||||
|
sed -in-place "s@\*(\([[:alnum:]]*\)) -> \(.*\)@* __URL_TAG1__\2__URL_TAG2__${repo}/commit/\1__URL_TAG3__@g" changelog
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# RETRIEVE ARGUMENTS
|
# RETRIEVE ARGUMENTS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Retrieve arguments from the manifest"
|
||||||
|
|
||||||
# Get is_public
|
# Get is_public
|
||||||
is_public=${YNH_ACTION_IS_PUBLIC}
|
is_public=${YNH_ACTION_IS_PUBLIC}
|
||||||
|
@ -38,6 +39,12 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
# MOVE TO PUBLIC OR PRIVATE
|
# MOVE TO PUBLIC OR PRIVATE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
if [ $is_public -eq 0 ]; then
|
||||||
|
public_private="private"
|
||||||
|
else
|
||||||
|
public_private="public"
|
||||||
|
fi
|
||||||
|
ynh_script_progression --message="Move the application to $public_private" --weight=3
|
||||||
|
|
||||||
if [ $is_public -eq 0 ]
|
if [ $is_public -eq 0 ]
|
||||||
then
|
then
|
||||||
|
@ -49,6 +56,7 @@ else
|
||||||
ynh_app_setting_set $app unprotected_uris "/"
|
ynh_app_setting_set $app unprotected_uris "/"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
ynh_script_progression --message="Reconfigure SSOwat"
|
||||||
# Regen ssowat configuration
|
# Regen ssowat configuration
|
||||||
yunohost app ssowatconf
|
yunohost app ssowatconf
|
||||||
|
|
||||||
|
@ -58,5 +66,12 @@ ynh_app_setting_set $app is_public $is_public
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Reload nginx"
|
||||||
|
|
||||||
ynh_systemd_action --action=reload --service_name=nginx
|
ynh_systemd_action --action=reload --service_name=nginx
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Execution completed" --last
|
||||||
|
|
|
@ -19,6 +19,7 @@ ynh_abort_if_errors
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Load settings" --weight=2
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
@ -32,6 +33,7 @@ db_pwd=$(ynh_app_setting_get "$app" mysqlpwd)
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE APP MAIN DIR
|
# BACKUP THE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Backup the app main dir"
|
||||||
|
|
||||||
CHECK_SIZE "$final_path"
|
CHECK_SIZE "$final_path"
|
||||||
ynh_backup "$final_path"
|
ynh_backup "$final_path"
|
||||||
|
@ -39,18 +41,21 @@ ynh_backup "$final_path"
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP NGINX CONFIGURATION
|
# BACKUP NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Backup nginx configuration"
|
||||||
|
|
||||||
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
|
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP PHP-FPM CONFIGURATION
|
# BACKUP PHP-FPM CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Backup php-fpm configuration"
|
||||||
|
|
||||||
ynh_backup "/etc/php5/fpm/pool.d/$app.conf"
|
ynh_backup "/etc/php/7.0/fpm/pool.d/$app.conf"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE MYSQL DATABASE
|
# BACKUP THE MYSQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Backup the mysql database" --weight=2
|
||||||
|
|
||||||
ynh_mysql_dump_db "$db_name" > db.sql
|
ynh_mysql_dump_db "$db_name" > db.sql
|
||||||
CHECK_SIZE "db.sql"
|
CHECK_SIZE "db.sql"
|
||||||
|
@ -58,6 +63,7 @@ CHECK_SIZE "db.sql"
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP FAIL2BAN CONFIGURATION
|
# BACKUP FAIL2BAN CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Backup fail2ban configuration"
|
||||||
|
|
||||||
ynh_backup "/etc/fail2ban/jail.d/$app.conf"
|
ynh_backup "/etc/fail2ban/jail.d/$app.conf"
|
||||||
ynh_backup "/etc/fail2ban/filter.d/$app.conf"
|
ynh_backup "/etc/fail2ban/filter.d/$app.conf"
|
||||||
|
@ -67,5 +73,12 @@ ynh_backup "/etc/fail2ban/filter.d/$app.conf"
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE CRON FILE
|
# BACKUP THE CRON FILE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Backup cron file"
|
||||||
|
|
||||||
ynh_backup "/etc/cron.d/$app"
|
ynh_backup "/etc/cron.d/$app"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Backup completed" --last
|
||||||
|
|
|
@ -12,6 +12,7 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# RETRIEVE ARGUMENTS
|
# RETRIEVE ARGUMENTS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Retrieve arguments from the manifest"
|
||||||
|
|
||||||
old_domain=$YNH_APP_OLD_DOMAIN
|
old_domain=$YNH_APP_OLD_DOMAIN
|
||||||
old_path=$YNH_APP_OLD_PATH
|
old_path=$YNH_APP_OLD_PATH
|
||||||
|
@ -24,12 +25,14 @@ app=$YNH_APP_INSTANCE_NAME
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Load settings" --weight=2
|
||||||
|
|
||||||
final_path=$(ynh_app_setting_get $app final_path)
|
final_path=$(ynh_app_setting_get $app final_path)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK THE SYNTAX OF THE PATHS
|
# CHECK THE SYNTAX OF THE PATHS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Check the syntax of the paths"
|
||||||
|
|
||||||
test -n "$old_path" || old_path="/"
|
test -n "$old_path" || old_path="/"
|
||||||
test -n "$new_path" || new_path="/"
|
test -n "$new_path" || new_path="/"
|
||||||
|
@ -39,6 +42,7 @@ old_path=$(ynh_normalize_url_path $old_path)
|
||||||
#=================================================
|
#=================================================
|
||||||
# ACTIVATE MAINTENANCE MODE
|
# ACTIVATE MAINTENANCE MODE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Activate maintenance mode"
|
||||||
|
|
||||||
path_url=$old_path
|
path_url=$old_path
|
||||||
domain=$old_domain
|
domain=$old_domain
|
||||||
|
@ -72,6 +76,7 @@ ynh_abort_if_errors
|
||||||
#=================================================
|
#=================================================
|
||||||
# MODIFY URL IN NGINX CONF
|
# MODIFY URL IN NGINX CONF
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Modify url in nginx configuration" --weight=2
|
||||||
|
|
||||||
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
||||||
|
|
||||||
|
@ -121,6 +126,7 @@ ynh_replace_string "https://$old_domain${old_path}" "https://$domain_path" "/et
|
||||||
#=================================================
|
#=================================================
|
||||||
# UPDATE THE DATABASE
|
# UPDATE THE DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Update the database"
|
||||||
|
|
||||||
ynh_mysql_execute_as_root "UPDATE leed_configuration SET value='$domain_path/' WHERE value LIKE '%${old_domain}%'" $app
|
ynh_mysql_execute_as_root "UPDATE leed_configuration SET value='$domain_path/' WHERE value LIKE '%${old_domain}%'" $app
|
||||||
|
|
||||||
|
@ -129,13 +135,21 @@ ynh_mysql_execute_as_root "UPDATE leed_configuration SET value='$domain_path/' W
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Reload nginx"
|
||||||
|
|
||||||
ynh_systemd_action --action=reload --service_name=nginx
|
ynh_systemd_action --action=reload --service_name=nginx
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DEACTIVE MAINTENANCE MODE
|
# DEACTIVE MAINTENANCE MODE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Disable maintenance mode"
|
||||||
|
|
||||||
path_url=$old_path
|
path_url=$old_path
|
||||||
domain=$old_domain
|
domain=$old_domain
|
||||||
ynh_maintenance_mode_OFF
|
ynh_maintenance_mode_OFF
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Change of url completed" --last
|
||||||
|
|
|
@ -41,6 +41,11 @@ old_overwrite_phpfpm="$(ynh_app_setting_get $app overwrite_phpfpm)"
|
||||||
old_overwrite_phpfpm=$(bool_to_true_false $old_overwrite_phpfpm)
|
old_overwrite_phpfpm=$(bool_to_true_false $old_overwrite_phpfpm)
|
||||||
overwrite_phpfpm="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_PHPFPM:-$old_overwrite_phpfpm}"
|
overwrite_phpfpm="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_PHPFPM:-$old_overwrite_phpfpm}"
|
||||||
|
|
||||||
|
# Type of admin mail configuration
|
||||||
|
old_admin_mail_html="$(ynh_app_setting_get $app admin_mail_html)"
|
||||||
|
old_admin_mail_html=$(bool_to_true_false $old_admin_mail_html)
|
||||||
|
admin_mail_html="${YNH_CONFIG_MAIN_GLOBAL_CONFIG_EMAIL_TYPE:-$old_admin_mail_html}"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SHOW_CONFIG FUNCTION FOR 'SHOW' COMMAND
|
# SHOW_CONFIG FUNCTION FOR 'SHOW' COMMAND
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -53,6 +58,8 @@ show_config() {
|
||||||
|
|
||||||
echo "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_NGINX=$overwrite_nginx"
|
echo "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_NGINX=$overwrite_nginx"
|
||||||
echo "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_PHPFPM=$overwrite_phpfpm"
|
echo "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_PHPFPM=$overwrite_phpfpm"
|
||||||
|
|
||||||
|
echo "YNH_CONFIG_MAIN_GLOBAL_CONFIG_EMAIL_TYPE=$admin_mail_html"
|
||||||
}
|
}
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -74,6 +81,10 @@ apply_config() {
|
||||||
# Set overwrite_phpfpm
|
# Set overwrite_phpfpm
|
||||||
overwrite_phpfpm=$(bool_to_01 $overwrite_phpfpm)
|
overwrite_phpfpm=$(bool_to_01 $overwrite_phpfpm)
|
||||||
ynh_app_setting_set $app overwrite_phpfpm "$overwrite_phpfpm"
|
ynh_app_setting_set $app overwrite_phpfpm "$overwrite_phpfpm"
|
||||||
|
|
||||||
|
# Set admin_mail_html
|
||||||
|
admin_mail_html=$(bool_to_01 $admin_mail_html)
|
||||||
|
ynh_app_setting_set $app admin_mail_html "$admin_mail_html"
|
||||||
}
|
}
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -19,6 +19,7 @@ ynh_abort_if_errors
|
||||||
#=================================================
|
#=================================================
|
||||||
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Retrieve arguments from the manifest"
|
||||||
|
|
||||||
domain=$YNH_APP_ARG_DOMAIN
|
domain=$YNH_APP_ARG_DOMAIN
|
||||||
path_url=$YNH_APP_ARG_PATH
|
path_url=$YNH_APP_ARG_PATH
|
||||||
|
@ -32,6 +33,7 @@ app=$YNH_APP_INSTANCE_NAME
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK IF THE APP CAN BE INSTALLED WITH THIS ARGS
|
# CHECK IF THE APP CAN BE INSTALLED WITH THIS ARGS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Check if the app can be installed" --weight=2
|
||||||
|
|
||||||
final_path=/var/www/$app
|
final_path=/var/www/$app
|
||||||
test ! -e "$final_path" || ynh_die "This path already contains a folder"
|
test ! -e "$final_path" || ynh_die "This path already contains a folder"
|
||||||
|
@ -45,18 +47,22 @@ ynh_webpath_register $app $domain $path_url
|
||||||
#=================================================
|
#=================================================
|
||||||
# STORE SETTINGS FROM MANIFEST
|
# STORE SETTINGS FROM MANIFEST
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Store settings from manifest" --weight=2
|
||||||
|
|
||||||
ynh_app_setting_set $app admin $admin
|
ynh_app_setting_set $app admin $admin
|
||||||
ynh_app_setting_set $app language $language
|
ynh_app_setting_set $app language $language
|
||||||
ynh_app_setting_set $app domain $domain
|
ynh_app_setting_set $app domain $domain
|
||||||
|
|
||||||
ynh_app_setting_set $app overwrite_nginx "1"
|
ynh_app_setting_set $app overwrite_nginx "1"
|
||||||
ynh_app_setting_set $app overwrite_phpfpm "1"
|
ynh_app_setting_set $app overwrite_phpfpm "1"
|
||||||
|
ynh_app_setting_set $app admin_mail_html "1"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD MODIFICATIONS
|
# STANDARD MODIFICATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE A MYSQL DATABASE
|
# CREATE A MYSQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Create a mysql database"
|
||||||
|
|
||||||
db_name=$(ynh_sanitize_dbid $app)
|
db_name=$(ynh_sanitize_dbid $app)
|
||||||
ynh_app_setting_set $app db_name $db_name
|
ynh_app_setting_set $app db_name $db_name
|
||||||
|
@ -65,6 +71,7 @@ ynh_mysql_setup_db $db_name $db_name
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Download, check and unpack source" --weight=3
|
||||||
|
|
||||||
ynh_app_setting_set $app final_path $final_path
|
ynh_app_setting_set $app final_path $final_path
|
||||||
# Download, check integrity and uncompress the source from app.src
|
# Download, check integrity and uncompress the source from app.src
|
||||||
|
@ -73,6 +80,7 @@ ynh_setup_source "$final_path"
|
||||||
#=================================================
|
#=================================================
|
||||||
# NGINX CONFIGURATION
|
# NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Configure nginx" --weight=2
|
||||||
|
|
||||||
# Create a dedicated nginx config
|
# Create a dedicated nginx config
|
||||||
ynh_add_nginx_config
|
ynh_add_nginx_config
|
||||||
|
@ -80,6 +88,7 @@ ynh_add_nginx_config
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE DEDICATED USER
|
# CREATE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Create a dedicated user" --weight=2
|
||||||
|
|
||||||
# Create a dedicated system user
|
# Create a dedicated system user
|
||||||
ynh_system_user_create $app
|
ynh_system_user_create $app
|
||||||
|
@ -87,6 +96,7 @@ ynh_system_user_create $app
|
||||||
#=================================================
|
#=================================================
|
||||||
# PHP-FPM CONFIGURATION
|
# PHP-FPM CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Configure php-fpm" --weight=2
|
||||||
|
|
||||||
# Create a dedicated php-fpm config
|
# Create a dedicated php-fpm config
|
||||||
ynh_add_fpm_config
|
ynh_add_fpm_config
|
||||||
|
@ -96,6 +106,7 @@ ynh_add_fpm_config
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETTING UP WITH CURL
|
# SETTING UP WITH CURL
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Install Leed with Curl" --weight=5
|
||||||
|
|
||||||
# Set right permissions for curl install
|
# Set right permissions for curl install
|
||||||
chown -R $app: $final_path
|
chown -R $app: $final_path
|
||||||
|
@ -122,6 +133,7 @@ code_sync=$(mysql -h localhost -u $db_name -p$db_pwd -s $db_name -e 'SELECT valu
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP CRON FILE FOR SYNCHRONISATION
|
# SETUP CRON FILE FOR SYNCHRONISATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Setup a cron file"
|
||||||
|
|
||||||
ynh_replace_string "__ADMIN__" "$admin" ../conf/cron_leed
|
ynh_replace_string "__ADMIN__" "$admin" ../conf/cron_leed
|
||||||
ynh_replace_string "__DOMAIN__" "$domain" ../conf/cron_leed
|
ynh_replace_string "__DOMAIN__" "$domain" ../conf/cron_leed
|
||||||
|
@ -144,6 +156,7 @@ chown -R $app $final_path/cache $final_path/plugins $final_path/updates
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP FAIL2BAN
|
# SETUP FAIL2BAN
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Configure fail2ban" --weight=9
|
||||||
|
|
||||||
# Create a dedicated fail2ban config
|
# Create a dedicated fail2ban config
|
||||||
ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="PHP message: Leed: wrong login for .* client: <HOST>" --max_retry=5
|
ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="PHP message: Leed: wrong login for .* client: <HOST>" --max_retry=5
|
||||||
|
@ -151,6 +164,7 @@ ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failreg
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SSOWAT
|
# SETUP SSOWAT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Setup SSOwat" --weight=2
|
||||||
|
|
||||||
# Make app private if necessary
|
# Make app private if necessary
|
||||||
ynh_app_setting_set $app is_public "$is_public"
|
ynh_app_setting_set $app is_public "$is_public"
|
||||||
|
@ -165,6 +179,7 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Reload nginx" --weight=3
|
||||||
|
|
||||||
ynh_systemd_action --action=reload --service_name=nginx
|
ynh_systemd_action --action=reload --service_name=nginx
|
||||||
|
|
||||||
|
@ -176,12 +191,18 @@ ynh_systemd_action --action=reload --service_name=nginx
|
||||||
admin_panel="https://$(grep portal_domain /etc/ssowat/conf.json | cut -d'"' -f4)/yunohost/admin/#/apps/$app"
|
admin_panel="https://$(grep portal_domain /etc/ssowat/conf.json | cut -d'"' -f4)/yunohost/admin/#/apps/$app"
|
||||||
|
|
||||||
ynh_print_OFF
|
ynh_print_OFF
|
||||||
message="Please take note of your password for this application: '$user_pwd'.
|
echo "Please take note of your password for this application: '$user_pwd'.
|
||||||
|
|
||||||
You can configure this app easily by using the experimental config-panel feature: $admin_panel/config-panel.
|
You can configure this app easily by using the experimental __URL_TAG1__config-panel feature__URL_TAG2__$admin_panel/config-panel__URL_TAG3__.
|
||||||
You can also find some specific actions for this app by using the experimental action feature: $admin_panel/actions.
|
You can also find some specific actions for this app by using the experimental __URL_TAG1__action feature__URL_TAG2__$admin_panel/actions__URL_TAG3__.
|
||||||
|
|
||||||
If you're facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/leed_ynh"
|
If you're facing an issue or want to improve this app, please open a new issue in this __URL_TAG1__project__URL_TAG2__https://github.com/YunoHost-Apps/leed_ynh__URL_TAG3__." > mail_to_send
|
||||||
|
|
||||||
ynh_send_readme_to_admin --app_message="$message" --recipients="$admin" --type="install"
|
ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="$admin" --type="install"
|
||||||
ynh_print_ON
|
ynh_print_ON
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Installation completed" --last
|
||||||
|
|
|
@ -12,6 +12,7 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Load settings" --weight=2
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
@ -23,6 +24,7 @@ db_name=$(ynh_app_setting_get $app db_name)
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE THE MYSQL DATABASE
|
# REMOVE THE MYSQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Remove the mysql database"
|
||||||
|
|
||||||
# Remove a database if it exists, along with the associated user
|
# Remove a database if it exists, along with the associated user
|
||||||
ynh_mysql_remove_db $db_name $db_name
|
ynh_mysql_remove_db $db_name $db_name
|
||||||
|
@ -30,6 +32,7 @@ ynh_mysql_remove_db $db_name $db_name
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE APP MAIN DIR
|
# REMOVE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Remove app main directory"
|
||||||
|
|
||||||
# Remove the app directory securely
|
# Remove the app directory securely
|
||||||
ynh_secure_remove "/var/www/$app"
|
ynh_secure_remove "/var/www/$app"
|
||||||
|
@ -37,6 +40,7 @@ ynh_secure_remove "/var/www/$app"
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE NGINX CONFIGURATION
|
# REMOVE NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Remove nginx configuration" --weight=2
|
||||||
|
|
||||||
# Remove the dedicated nginx config
|
# Remove the dedicated nginx config
|
||||||
ynh_remove_nginx_config
|
ynh_remove_nginx_config
|
||||||
|
@ -44,6 +48,7 @@ ynh_remove_nginx_config
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE PHP-FPM CONFIGURATION
|
# REMOVE PHP-FPM CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Remove php-fpm configuration"
|
||||||
|
|
||||||
# Remove the dedicated php-fpm config
|
# Remove the dedicated php-fpm config
|
||||||
ynh_remove_fpm_config
|
ynh_remove_fpm_config
|
||||||
|
@ -51,6 +56,7 @@ ynh_remove_fpm_config
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE FAIL2BAN CONFIGURATION
|
# REMOVE FAIL2BAN CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Remove fail2ban configuration" --weight=5
|
||||||
|
|
||||||
# Remove the dedicated fail2ban config
|
# Remove the dedicated fail2ban config
|
||||||
ynh_remove_fail2ban_config
|
ynh_remove_fail2ban_config
|
||||||
|
@ -68,6 +74,13 @@ ynh_secure_remove "/etc/cron.d/$app"
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE DEDICATED USER
|
# REMOVE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Remove the dedicated user" --weight=2
|
||||||
|
|
||||||
# Delete dedicated system user
|
# Delete dedicated system user
|
||||||
ynh_system_user_delete $app
|
ynh_system_user_delete $app
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Deletion completed" --last
|
||||||
|
|
|
@ -19,6 +19,7 @@ ynh_abort_if_errors
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Load settings" --weight=2
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
@ -40,6 +41,7 @@ test ! -d $final_path \
|
||||||
#=================================================
|
#=================================================
|
||||||
# ACTIVATE MAINTENANCE MODE
|
# ACTIVATE MAINTENANCE MODE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Activate maintenance mode" --weight=2
|
||||||
|
|
||||||
ynh_maintenance_mode_ON
|
ynh_maintenance_mode_ON
|
||||||
|
|
||||||
|
@ -54,12 +56,14 @@ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE APP MAIN DIR
|
# RESTORE THE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Restore the app main directory"
|
||||||
|
|
||||||
ynh_restore_file "$final_path"
|
ynh_restore_file "$final_path"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE MYSQL DATABASE
|
# RESTORE THE MYSQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Restore the mysql database" --weight=3
|
||||||
|
|
||||||
db_pwd=$(ynh_app_setting_get $app mysqlpwd)
|
db_pwd=$(ynh_app_setting_get $app mysqlpwd)
|
||||||
ynh_mysql_setup_db $db_name $db_name $db_pwd
|
ynh_mysql_setup_db $db_name $db_name $db_pwd
|
||||||
|
@ -68,6 +72,7 @@ ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql
|
||||||
#=================================================
|
#=================================================
|
||||||
# RECREATE THE DEDICATED USER
|
# RECREATE THE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Recreate the dedicated user" --weight=2
|
||||||
|
|
||||||
# Create the dedicated user (if not existing)
|
# Create the dedicated user (if not existing)
|
||||||
ynh_system_user_create $app
|
ynh_system_user_create $app
|
||||||
|
@ -76,11 +81,12 @@ ynh_system_user_create $app
|
||||||
# RESTORE THE PHP-FPM CONFIGURATION
|
# RESTORE THE PHP-FPM CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_restore_file "/etc/php5/fpm/pool.d/$app.conf"
|
ynh_restore_file "/etc/php/7.0/fpm/pool.d/$app.conf"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE FAIL2BAN CONFIGURATION
|
# RESTORE FAIL2BAN CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Restore the fail2ban configuration" --weight=7
|
||||||
|
|
||||||
ynh_restore_file "/etc/fail2ban/jail.d/$app.conf"
|
ynh_restore_file "/etc/fail2ban/jail.d/$app.conf"
|
||||||
ynh_restore_file "/etc/fail2ban/filter.d/$app.conf"
|
ynh_restore_file "/etc/fail2ban/filter.d/$app.conf"
|
||||||
|
@ -105,13 +111,15 @@ chown -R $app $final_path/cache $final_path/plugins $final_path/updates
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX AND PHP-FPM
|
# RELOAD NGINX AND PHP-FPM
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Reload nginx and php-fpm"
|
||||||
|
|
||||||
ynh_systemd_action --action=reload --service_name=php5-fpm
|
ynh_systemd_action --action=reload --service_name=php7.0-fpm
|
||||||
ynh_systemd_action --action=reload --service_name=nginx
|
ynh_systemd_action --action=reload --service_name=nginx
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DEACTIVE MAINTENANCE MODE
|
# DEACTIVE MAINTENANCE MODE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Disable maintenance mode" --weight=2
|
||||||
|
|
||||||
ynh_maintenance_mode_OFF
|
ynh_maintenance_mode_OFF
|
||||||
|
|
||||||
|
@ -122,9 +130,15 @@ ynh_maintenance_mode_OFF
|
||||||
# Get main domain and buid the url of the admin panel of the app.
|
# Get main domain and buid the url of the admin panel of the app.
|
||||||
admin_panel="https://$(grep portal_domain /etc/ssowat/conf.json | cut -d'"' -f4)/yunohost/admin/#/apps/$app"
|
admin_panel="https://$(grep portal_domain /etc/ssowat/conf.json | cut -d'"' -f4)/yunohost/admin/#/apps/$app"
|
||||||
|
|
||||||
message="You can configure this app easily by using the experimental config-panel feature: $admin_panel/config-panel.
|
echo "You can configure this app easily by using the experimental __URL_TAG1__config-panel feature__URL_TAG2__$admin_panel/config-panel__URL_TAG3__.
|
||||||
You can also find some specific actions for this app by using the experimental action feature: $admin_panel/actions.
|
You can also find some specific actions for this app by using the experimental __URL_TAG1__action feature__URL_TAG2__$admin_panel/actions__URL_TAG3__.
|
||||||
|
|
||||||
If you're facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/leed_ynh"
|
If you're facing an issue or want to improve this app, please open a new issue in this __URL_TAG1__project__URL_TAG2__https://github.com/YunoHost-Apps/leed_ynh__URL_TAG3__." > mail_to_send
|
||||||
|
|
||||||
ynh_send_readme_to_admin --app_message="$message" --recipients="$admin" --type="restore"
|
ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="$admin" --type="restore"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Restoration completed" --last
|
||||||
|
|
|
@ -12,6 +12,7 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Load settings" --weight=3
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
@ -24,6 +25,7 @@ db_pwd=$(ynh_app_setting_get $app mysqlpwd)
|
||||||
db_name=$(ynh_app_setting_get $app db_name)
|
db_name=$(ynh_app_setting_get $app db_name)
|
||||||
overwrite_nginx=$(ynh_app_setting_get $app overwrite_nginx)
|
overwrite_nginx=$(ynh_app_setting_get $app overwrite_nginx)
|
||||||
overwrite_phpfpm=$(ynh_app_setting_get $app overwrite_phpfpm)
|
overwrite_phpfpm=$(ynh_app_setting_get $app overwrite_phpfpm)
|
||||||
|
admin_mail_html=$(ynh_app_setting_get $app admin_mail_html)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK VERSION
|
# CHECK VERSION
|
||||||
|
@ -34,6 +36,7 @@ upgrade_type=$(ynh_check_app_version_changed)
|
||||||
#=================================================
|
#=================================================
|
||||||
# ENSURE DOWNWARD COMPATIBILITY
|
# ENSURE DOWNWARD COMPATIBILITY
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Ensure downward compatibility"
|
||||||
|
|
||||||
# If final_path doesn't exist, create it
|
# If final_path doesn't exist, create it
|
||||||
if [ -z "$final_path" ]; then
|
if [ -z "$final_path" ]; then
|
||||||
|
@ -80,9 +83,16 @@ if [ -z "$overwrite_phpfpm" ]; then
|
||||||
ynh_app_setting_set $app overwrite_phpfpm $overwrite_phpfpm
|
ynh_app_setting_set $app overwrite_phpfpm $overwrite_phpfpm
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# If admin_mail_html doesn't exist, create it
|
||||||
|
if [ -z "$admin_mail_html" ]; then
|
||||||
|
admin_mail_html=1
|
||||||
|
ynh_app_setting_set $app admin_mail_html $admin_mail_html
|
||||||
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Backup the app before upgrading" --weight=4
|
||||||
|
|
||||||
# Backup the current version of the app
|
# Backup the current version of the app
|
||||||
ynh_backup_before_upgrade
|
ynh_backup_before_upgrade
|
||||||
|
@ -103,6 +113,7 @@ path_url=$(ynh_normalize_url_path $path_url)
|
||||||
#=================================================
|
#=================================================
|
||||||
# ACTIVATE MAINTENANCE MODE
|
# ACTIVATE MAINTENANCE MODE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Activate maintenance mode"
|
||||||
|
|
||||||
ynh_maintenance_mode_ON
|
ynh_maintenance_mode_ON
|
||||||
|
|
||||||
|
@ -114,6 +125,7 @@ ynh_maintenance_mode_ON
|
||||||
|
|
||||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||||
then
|
then
|
||||||
|
ynh_script_progression --message="Download, check and unpack source" --weight=3
|
||||||
# Download, check integrity, uncompress and patch the source from app.src
|
# Download, check integrity, uncompress and patch the source from app.src
|
||||||
ynh_setup_source "$final_path"
|
ynh_setup_source "$final_path"
|
||||||
fi
|
fi
|
||||||
|
@ -125,6 +137,7 @@ fi
|
||||||
# Overwrite the nginx configuration only if it's allowed
|
# Overwrite the nginx configuration only if it's allowed
|
||||||
if [ $overwrite_nginx -eq 1 ]
|
if [ $overwrite_nginx -eq 1 ]
|
||||||
then
|
then
|
||||||
|
ynh_script_progression --message="Reconfigure nginx" --weight=2
|
||||||
# Create a dedicated nginx config
|
# Create a dedicated nginx config
|
||||||
ynh_add_nginx_config
|
ynh_add_nginx_config
|
||||||
fi
|
fi
|
||||||
|
@ -132,6 +145,7 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE DEDICATED USER
|
# CREATE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Create a dedicated user"
|
||||||
|
|
||||||
# Create a dedicated user (if not existing)
|
# Create a dedicated user (if not existing)
|
||||||
ynh_system_user_create $app
|
ynh_system_user_create $app
|
||||||
|
@ -143,6 +157,7 @@ ynh_system_user_create $app
|
||||||
# Overwrite the php-fpm configuration only if it's allowed
|
# Overwrite the php-fpm configuration only if it's allowed
|
||||||
if [ $overwrite_phpfpm -eq 1 ]
|
if [ $overwrite_phpfpm -eq 1 ]
|
||||||
then
|
then
|
||||||
|
ynh_script_progression --message="Reconfigure php-fpm" --weight=2
|
||||||
# Create a dedicated php-fpm config
|
# Create a dedicated php-fpm config
|
||||||
ynh_add_fpm_config
|
ynh_add_fpm_config
|
||||||
fi
|
fi
|
||||||
|
@ -181,6 +196,7 @@ chown -R $app $final_path/cache $final_path/plugins $final_path/updates
|
||||||
|
|
||||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||||
then
|
then
|
||||||
|
ynh_script_progression --message="Upgrade Leed with curl" --weight=4
|
||||||
# Clear leed cache
|
# Clear leed cache
|
||||||
ynh_secure_remove $final_path/cache/*
|
ynh_secure_remove $final_path/cache/*
|
||||||
# Set the app as temporarily public for curl call
|
# Set the app as temporarily public for curl call
|
||||||
|
@ -196,6 +212,7 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
# UPGRADE FAIL2BAN
|
# UPGRADE FAIL2BAN
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Reconfigure fail2ban" --weight=8
|
||||||
|
|
||||||
# Create a dedicated fail2ban config
|
# Create a dedicated fail2ban config
|
||||||
ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="PHP message: Leed: wrong login for .* client: <HOST>" --max_retry=5
|
ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="PHP message: Leed: wrong login for .* client: <HOST>" --max_retry=5
|
||||||
|
@ -203,6 +220,7 @@ ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failreg
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SSOWAT
|
# SETUP SSOWAT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Reconfigure SSOwat"
|
||||||
|
|
||||||
# Make app private if necessary
|
# Make app private if necessary
|
||||||
if [ $is_public -eq 0 ];
|
if [ $is_public -eq 0 ];
|
||||||
|
@ -216,12 +234,14 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Reload nginx" --weight=2
|
||||||
|
|
||||||
ynh_systemd_action --action=reload --service_name=nginx
|
ynh_systemd_action --action=reload --service_name=nginx
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DEACTIVE MAINTENANCE MODE
|
# DEACTIVE MAINTENANCE MODE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Disable maintenance mode"
|
||||||
|
|
||||||
ynh_maintenance_mode_OFF
|
ynh_maintenance_mode_OFF
|
||||||
|
|
||||||
|
@ -232,9 +252,23 @@ ynh_maintenance_mode_OFF
|
||||||
# Get main domain and buid the url of the admin panel of the app.
|
# Get main domain and buid the url of the admin panel of the app.
|
||||||
admin_panel="https://$(grep portal_domain /etc/ssowat/conf.json | cut -d'"' -f4)/yunohost/admin/#/apps/$app"
|
admin_panel="https://$(grep portal_domain /etc/ssowat/conf.json | cut -d'"' -f4)/yunohost/admin/#/apps/$app"
|
||||||
|
|
||||||
message="You can configure this app easily by using the experimental config-panel feature: $admin_panel/config-panel.
|
# Build the changelog
|
||||||
You can also find some specific actions for this app by using the experimental action feature: $admin_panel/actions.
|
ynh_app_changelog || true
|
||||||
|
|
||||||
If you're facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/leed_ynh"
|
echo "You can configure this app easily by using the experimental __URL_TAG1__config-panel feature__URL_TAG2__$admin_panel/config-panel__URL_TAG3__.
|
||||||
|
You can also find some specific actions for this app by using the experimental __URL_TAG1__action feature__URL_TAG2__$admin_panel/actions__URL_TAG3__.
|
||||||
|
|
||||||
ynh_send_readme_to_admin --app_message="$message" --recipients="$admin" --type="upgrade"
|
If you're facing an issue or want to improve this app, please open a new issue in this __URL_TAG1__project__URL_TAG2__https://github.com/YunoHost-Apps/leed_ynh__URL_TAG3__.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Changelog since your last upgrade:
|
||||||
|
$(cat changelog)" > mail_to_send
|
||||||
|
|
||||||
|
ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="$admin" --type="upgrade"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Upgrade completed" --last
|
||||||
|
|
Loading…
Reference in a new issue