1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/fider_ynh.git synced 2024-09-03 18:36:11 +02:00

Merge branch 'master' into change_url_script

This commit is contained in:
Jimmy Monin 2017-08-23 17:09:52 +02:00
commit 078548ddd5
14 changed files with 984 additions and 279 deletions

40
check_process Normal file
View file

@ -0,0 +1,40 @@
# See here for more informations
# https://github.com/YunoHost/package_check#syntax-check_process-file
;; Test complet
; Manifest
domain="domain.tld" (DOMAIN)
path="/path" (PATH)
admin="john" (USER)
language="fr"
is_public=1 (PUBLIC|public=1|private=0)
password="pass"
port="666" (PORT)
; Checks
pkg_linter=1
setup_sub_dir=1
setup_root=1
setup_nourl=0
setup_private=1
setup_public=1
upgrade=1
backup_restore=1
multi_instance=1
incorrect_path=1
port_already_use=1
change_url=0
;;; Levels
Level 1=auto
Level 2=auto
Level 3=auto
# Level 4:
Level 4=0
# Level 5:
Level 5=auto
Level 6=auto
Level 7=auto
Level 8=0
Level 9=0
Level 10=0
;;; Options
Email=
Notification=none

View file

@ -1,2 +1,6 @@
SOURCE_URL=url of app's source SOURCE_URL=url of app's source
SOURCE_SUM=md5 or sha1 checksum SOURCE_SUM=sha256 checksum
SOURCE_SUM_PRG=sha256
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=

View file

@ -1,7 +1,11 @@
location YNH_WWW_PATH { location __PATH__ {
# Path to source # Path to source
alias YNH_WWW_ALIAS ; alias __FINALPATH__/ ;
if ($scheme = http) {
rewrite ^ https://$server_name$request_uri? permanent;
}
# Example PHP configuration (remove if not used) # Example PHP configuration (remove if not used)
index index.php; index index.php;
@ -12,13 +16,14 @@ location YNH_WWW_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.sock; fastcgi_pass unix:/var/run/php5-fpm-__NAME__.sock;
# Filename to be changed if dedicated php-fpm process is required # If you don't use a dedicated fpm config for your app,
# use a general fpm pool.
# This is to be used INSTEAD of line above # This is to be used INSTEAD of line above
# Don't forget to adjust scripts install/upgrade/remove/backup accordingly # Don't forget to adjust scripts install/upgrade/remove/backup accordingly
# #
#fastcgi_pass unix:/var/run/php5-fpm-YNH_WWW_APP.sock; #fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php; fastcgi_index index.php;
include fastcgi_params; include fastcgi_params;
@ -26,7 +31,7 @@ location YNH_WWW_PATH {
fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $request_filename; fastcgi_param SCRIPT_FILENAME $request_filename;
} }
# PHP configuration end # PHP configuration end
# Include SSOWAT user panel. # Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc; include conf.d/yunohost_panel.conf.inc;

View file

@ -1,7 +1,7 @@
; 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 we used in any directive and will be replaced by the
; pool name ('www' here) ; pool name ('www' here)
[YNH_WWW_APP] [__NAMETOCHANGE__]
; Per pool prefix ; Per pool prefix
; It only applies on the following directives: ; It only applies on the following directives:
@ -16,6 +16,12 @@
; Default Value: none ; Default Value: none
;prefix = /path/to/pools/$pool ;prefix = /path/to/pools/$pool
; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
; will be used.
user = __USER__
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 address on
@ -24,11 +30,20 @@
; specific port; ; 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-YNH_WWW_APP.sock listen = /var/run/php5-fpm-__NAMETOCHANGE__.sock
; Set listen(2) backlog. A value of '-1' means unlimited. ; Set listen(2) backlog. A value of '-1' means unlimited.
; Default Value: 128 (-1 on FreeBSD and OpenBSD) ; Default Value: 128 (-1 on FreeBSD and OpenBSD)
;listen.backlog = -1 ;listen.backlog = 128
; Set permissions for unix socket, if one is used. In Linux, read/write
; permissions must be set in order to allow connections from a web server. Many
; BSD-derived systems allow connections regardless of permissions.
; Default Values: user and group are set as the running user
; mode is set to 0660
listen.owner = www-data
listen.group = www-data
;listen.mode = 0660
; List of ipv4 addresses of FastCGI clients which are allowed to connect. ; List of ipv4 addresses 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
@ -38,26 +53,20 @@ listen = /var/run/php5-fpm-YNH_WWW_APP.sock
; Default Value: any ; Default Value: any
;listen.allowed_clients = 127.0.0.1 ;listen.allowed_clients = 127.0.0.1
; Set permissions for unix socket, if one is used. In Linux, read/write ; Specify the nice(2) priority to apply to the pool processes (only if set)
; permissions must be set in order to allow connections from a web server. Many ; The value can vary from -19 (highest priority) to 20 (lower priority)
; BSD-derived systems allow connections regardless of permissions. ; Note: - It will only work if the FPM master process is launched as root
; Default Values: user and group are set as the running user ; - The pool processes will inherit the master process priority
; mode is set to 0666 ; unless it specified otherwise
listen.owner = www-data ; Default Value: no set
listen.group = www-data ; priority = -19
listen.mode = 0600
; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
; will be used.
user = www-data
group = www-data
; Choose how the process manager will control the number of child processes. ; Choose how the process manager will control the number of child processes.
; Possible Values: ; Possible Values:
; static - a fixed number (pm.max_children) of child processes; ; static - a fixed number (pm.max_children) of child processes;
; dynamic - the number of child processes are set dynamically based on the ; dynamic - the number of child processes are set dynamically based on the
; following directives: ; following directives. With this process management, there will be
; always at least 1 children.
; pm.max_children - the maximum number of children that can ; pm.max_children - the maximum number of children that can
; be alive at the same time. ; be alive at the same time.
; pm.start_servers - the number of children created on startup. ; pm.start_servers - the number of children created on startup.
@ -69,33 +78,45 @@ group = www-data
; state (waiting to process). If the number ; state (waiting to process). If the number
; of 'idle' processes is greater than this ; of 'idle' processes is greater than this
; number then some children will be killed. ; number then some children will be killed.
; ondemand - no children are created at startup. Children will be forked when
; new requests will connect. The following parameter are used:
; pm.max_children - the maximum number of children that
; can be alive at the same time.
; pm.process_idle_timeout - The number of seconds after which
; an idle process will be killed.
; Note: This value is mandatory. ; Note: This value is mandatory.
pm = dynamic pm = dynamic
; The number of child processes to be created when pm is set to 'static' and the ; The number of child processes to be created when pm is set to 'static' and the
; maximum number of child processes to be created when pm is set to 'dynamic'. ; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'.
; This value sets the limit on the number of simultaneous requests that will be ; This value sets the limit on the number of simultaneous requests that will be
; served. Equivalent to the ApacheMaxClients directive with mpm_prefork. ; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP ; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
; CGI. ; CGI. The below defaults are based on a server without much resources. Don't
; Note: Used when pm is set to either 'static' or 'dynamic' ; forget to tweak pm.* to fit your needs.
; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand'
; Note: This value is mandatory. ; Note: This value is mandatory.
pm.max_children = 6 pm.max_children = 10
; The number of child processes created on startup. ; The number of child processes created on startup.
; Note: Used only when pm is set to 'dynamic' ; Note: Used only when pm is set to 'dynamic'
; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2 ; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2
pm.start_servers = 3 pm.start_servers = 2
; The desired minimum number of idle server processes. ; The desired minimum number of idle server processes.
; Note: Used only when pm is set to 'dynamic' ; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic' ; Note: Mandatory when pm is set to 'dynamic'
pm.min_spare_servers = 3 pm.min_spare_servers = 1
; The desired maximum number of idle server processes. ; The desired maximum number of idle server processes.
; Note: Used only when pm is set to 'dynamic' ; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic' ; Note: Mandatory when pm is set to 'dynamic'
pm.max_spare_servers = 5 pm.max_spare_servers = 3
; The number of seconds after which an idle process will be killed.
; Note: Used only when pm is set to 'ondemand'
; Default Value: 10s
;pm.process_idle_timeout = 10s;
; The number of requests each child process should execute before respawning. ; 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
@ -104,38 +125,103 @@ pm.max_spare_servers = 5
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. By default, the status page shows the following ; recognized as a status page. It shows the following informations:
; information:
; accepted conn - the number of request accepted by the pool;
; pool - the name of the pool; ; pool - the name of the pool;
; process manager - static or dynamic; ; process manager - static, dynamic or ondemand;
; start time - the date and time FPM has started;
; start since - number of seconds since FPM has started;
; accepted conn - the number of request accepted by the pool;
; listen queue - the number of request in the queue of pending
; connections (see backlog in listen(2));
; max listen queue - the maximum number of requests in the queue
; of pending connections since FPM has started;
; listen queue len - the size of the socket queue of pending connections;
; idle processes - the number of idle processes; ; idle processes - the number of idle processes;
; active processes - the number of active processes; ; active processes - the number of active processes;
; total processes - the number of idle + active processes. ; total processes - the number of idle + active processes;
; max active processes - the maximum number of active processes since FPM
; has started;
; max children reached - number of times, the process limit has been reached, ; max children reached - number of times, the process limit has been reached,
; when pm tries to start more children (works only for ; when pm tries to start more children (works only for
; pm 'dynamic') ; pm 'dynamic' and 'ondemand');
; The values of 'idle processes', 'active processes' and 'total processes' are ; Value are updated in real time.
; updated each second. The value of 'accepted conn' is updated in real time.
; Example output: ; Example output:
; accepted conn: 12073
; pool: www ; pool: www
; process manager: static ; process manager: static
; idle processes: 35 ; start time: 01/Jul/2011:17:53:49 +0200
; active processes: 65 ; start since: 62636
; total processes: 100 ; accepted conn: 190460
; max children reached: 1 ; listen queue: 0
; max listen queue: 1
; listen queue len: 42
; idle processes: 4
; active processes: 11
; total processes: 15
; max active processes: 12
; max children reached: 0
;
; By default the status page output is formatted as text/plain. Passing either ; By default the status page output is formatted as text/plain. Passing either
; 'html' or 'json' as a query string will return the corresponding output ; 'html', 'xml' or 'json' in the query string will return the corresponding
; syntax. Example: ; output syntax. Example:
; http://www.foo.bar/status ; http://www.foo.bar/status
; http://www.foo.bar/status?json ; http://www.foo.bar/status?json
; http://www.foo.bar/status?html ; http://www.foo.bar/status?html
; http://www.foo.bar/status?xml
;
; By default the status page only outputs short status. Passing 'full' in the
; query string will also return status for each pool process.
; Example:
; http://www.foo.bar/status?full
; http://www.foo.bar/status?json&full
; http://www.foo.bar/status?html&full
; http://www.foo.bar/status?xml&full
; The Full status returns for each process:
; pid - the PID of the process;
; state - the state of the process (Idle, Running, ...);
; start time - the date and time the process has started;
; start since - the number of seconds since the process has started;
; requests - the number of requests the process has served;
; request duration - the duration in µs of the requests;
; request method - the request method (GET, POST, ...);
; request URI - the request URI with the query string;
; content length - the content length of the request (only with POST);
; user - the user (PHP_AUTH_USER) (or '-' if not set);
; script - the main script called (or '-' if not set);
; last request cpu - the %cpu the last request consumed
; it's always 0 if the process is not in Idle state
; because CPU calculation is done when the request
; processing has terminated;
; last request memory - the max amount of memory the last request consumed
; it's always 0 if the process is not in Idle state
; because memory calculation is done when the request
; processing has terminated;
; If the process is in Idle state, then informations are related to the
; last request the process has served. Otherwise informations are related to
; the current request being served.
; Example output:
; ************************
; pid: 31330
; state: Running
; start time: 01/Jul/2011:17:53:49 +0200
; start since: 63087
; requests: 12808
; request duration: 1250261
; request method: GET
; request URI: /test_mem.php?N=10000
; content length: 0
; user: -
; script: /home/fat/web/docs/php/test_mem.php
; last request cpu: 0.00
; last request memory: 0
;
; Note: There is a real-time FPM status monitoring sample web page available
; It's available in: ${prefix}/share/fpm/status.html
;
; Note: The value must start with a leading slash (/). The value can be ; Note: The value must start with a leading slash (/). The value can be
; anything, but it may not be a good idea to use the .php extension or it ; anything, but it may not be a good idea to use the .php extension or it
; may conflict with a real PHP file. ; may conflict with a real PHP file.
; Default Value: not set ; Default Value: not set
pm.status_path = /fpm-status ;pm.status_path = /status
; The ping URI to call the monitoring page of FPM. If this value is not set, no ; The ping URI to call the monitoring page of FPM. If this value is not set, no
; URI will be recognized as a ping page. This could be used to test from outside ; URI will be recognized as a ping page. This could be used to test from outside
@ -147,19 +233,76 @@ pm.status_path = /fpm-status
; anything, but it may not be a good idea to use the .php extension or it ; anything, but it may not be a good idea to use the .php extension or it
; may conflict with a real PHP file. ; may conflict with a real PHP file.
; Default Value: not set ; Default Value: not set
ping.path = /ping ;ping.path = /ping
; This directive may be used to customize the response of a ping request. The ; This directive may be used to customize the response of a ping request. The
; response is formatted as text/plain with a 200 response code. ; response is formatted as text/plain with a 200 response code.
; Default Value: pong ; Default Value: pong
;ping.response = pong ;ping.response = pong
; The timeout for serving a single request after which the worker process will ; The access log file
; be killed. This option should be used when the 'max_execution_time' ini option ; Default: not set
; does not stop script execution for some reason. A value of '0' means 'off'. ;access.log = log/$pool.access.log
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
; Default Value: 0 ; The access log format.
request_terminate_timeout = 120s ; The following syntax is allowed
; %%: the '%' character
; %C: %CPU used by the request
; it can accept the following format:
; - %{user}C for user CPU only
; - %{system}C for system CPU only
; - %{total}C for user + system CPU (default)
; %d: time taken to serve the request
; it can accept the following format:
; - %{seconds}d (default)
; - %{miliseconds}d
; - %{mili}d
; - %{microseconds}d
; - %{micro}d
; %e: an environment variable (same as $_ENV or $_SERVER)
; it must be associated with embraces to specify the name of the env
; variable. Some exemples:
; - server specifics like: %{REQUEST_METHOD}e or %{SERVER_PROTOCOL}e
; - HTTP headers like: %{HTTP_HOST}e or %{HTTP_USER_AGENT}e
; %f: script filename
; %l: content-length of the request (for POST request only)
; %m: request method
; %M: peak of memory allocated by PHP
; it can accept the following format:
; - %{bytes}M (default)
; - %{kilobytes}M
; - %{kilo}M
; - %{megabytes}M
; - %{mega}M
; %n: pool name
; %o: ouput header
; it must be associated with embraces to specify the name of the header:
; - %{Content-Type}o
; - %{X-Powered-By}o
; - %{Transfert-Encoding}o
; - ....
; %p: PID of the child that serviced the request
; %P: PID of the parent of the child that serviced the request
; %q: the query string
; %Q: the '?' character if query string exists
; %r: the request URI (without the query string, see %q and %Q)
; %R: remote IP address
; %s: status (response code)
; %t: server time the request was received
; it can accept a strftime(3) format:
; %d/%b/%Y:%H:%M:%S %z (default)
; %T: time the log has been written (the request has finished)
; it can accept a strftime(3) format:
; %d/%b/%Y:%H:%M:%S %z (default)
; %u: remote user
;
; Default: "%R - %u %t \"%m %r\" %s"
;access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%"
; The log file for slow requests
; Default Value: not set
; Note: slowlog is mandatory if request_slowlog_timeout is set
slowlog = /var/log/nginx/__NAMETOCHANGE__.slow.log
; The timeout for serving a single request after which a PHP backtrace will be ; The timeout for serving a single request after which a PHP backtrace will be
; dumped to the 'slowlog' file. A value of '0s' means 'off'. ; dumped to the 'slowlog' file. A value of '0s' means 'off'.
@ -167,19 +310,21 @@ request_terminate_timeout = 120s
; Default Value: 0 ; Default Value: 0
request_slowlog_timeout = 5s request_slowlog_timeout = 5s
; The log file for slow requests ; The timeout for serving a single request after which the worker process will
; Default Value: not set ; be killed. This option should be used when the 'max_execution_time' ini option
; Note: slowlog is mandatory if request_slowlog_timeout is set ; does not stop script execution for some reason. A value of '0' means 'off'.
slowlog = /var/log/nginx/YNH_WWW_APP.slow.log ; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
; Default Value: 0
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 = 4096 ;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.
@ -195,7 +340,7 @@ rlimit_core = 0
; Chdir to this directory at the start. ; Chdir to this directory at the start.
; Note: relative path can be used. ; Note: relative path can be used.
; Default Value: current directory or / when chroot ; Default Value: current directory or / when chroot
chdir = /var/www/YNH_WWW_ALIAS chdir = __FINALPATH__
; Redirect worker stdout and stderr into main error log. If not set, stdout and ; Redirect worker stdout and stderr into main error log. If not set, stdout and
; stderr will be redirected to /dev/null according to FastCGI specs. ; stderr will be redirected to /dev/null according to FastCGI specs.
@ -204,6 +349,14 @@ chdir = /var/www/YNH_WWW_ALIAS
; Default Value: no ; Default Value: no
catch_workers_output = yes catch_workers_output = yes
; Limits the extensions of the main script FPM will allow to parse. This can
; prevent configuration mistakes on the web server side. You should only limit
; FPM to .php extensions to prevent malicious users to use other extensions to
; exectute php code.
; Note: set an empty value to allow all extensions.
; Default Value: .php
;security.limit_extensions = .php .php3 .php4 .php5
; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from ; 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
@ -237,15 +390,3 @@ catch_workers_output = yes
;php_admin_value[error_log] = /var/log/fpm-php.www.log ;php_admin_value[error_log] = /var/log/fpm-php.www.log
;php_admin_flag[log_errors] = on ;php_admin_flag[log_errors] = on
;php_admin_value[memory_limit] = 32M ;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
# Other common parameters
;php_value[max_execution_time] = 600
;php_value[max_input_time] = 300
;php_value[memory_limit] = 256M
;php_value[short_open_tag] = On

10
conf/php-fpm.ini Normal file
View file

@ -0,0 +1,10 @@
# Common values to change to increase file upload limit
; upload_max_filesize = 50M
; post_max_size = 50M
; mail.add_x_header = Off
# Other common parameters
; max_execution_time = 600
; max_input_time = 300
; memory_limit = 256M
; short_open_tag = On

View file

@ -14,7 +14,7 @@
"url": "http://example.com" "url": "http://example.com"
}, },
"requirements": { "requirements": {
"yunohost": ">> 2.4.0" "yunohost": ">= 2.6.4"
}, },
"multi_instance": true, "multi_instance": true,
"services": [ "services": [

112
scripts/_common.sh Normal file
View file

@ -0,0 +1,112 @@
#!/bin/bash
# =============================================================================
# YUNOHOST 2.7 FORTHCOMING HELPERS
# =============================================================================
# Create a dedicated nginx config
#
# usage: ynh_add_nginx_config
ynh_add_nginx_config () {
finalnginxconf="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_backup_if_checksum_is_different "$finalnginxconf"
sudo cp ../conf/nginx.conf "$finalnginxconf"
# To avoid a break by set -u, use a void substitution ${var:-}. If the variable is not set, it's simply set with an empty variable.
# Substitute in a nginx config file only if the variable is not empty
if test -n "${path_url:-}"; then
ynh_replace_string "__PATH__" "$path_url" "$finalnginxconf"
fi
if test -n "${domain:-}"; then
ynh_replace_string "__DOMAIN__" "$domain" "$finalnginxconf"
fi
if test -n "${port:-}"; then
ynh_replace_string "__PORT__" "$port" "$finalnginxconf"
fi
if test -n "${app:-}"; then
ynh_replace_string "__NAME__" "$app" "$finalnginxconf"
fi
if test -n "${final_path:-}"; then
ynh_replace_string "__FINALPATH__" "$final_path" "$finalnginxconf"
fi
ynh_store_file_checksum "$finalnginxconf"
sudo systemctl reload nginx
}
# Remove the dedicated nginx config
#
# usage: ynh_remove_nginx_config
ynh_remove_nginx_config () {
ynh_secure_remove "/etc/nginx/conf.d/$domain.d/$app.conf"
sudo systemctl reload nginx
}
# Create a dedicated php-fpm config
#
# usage: ynh_add_fpm_config
ynh_add_fpm_config () {
finalphpconf="/etc/php5/fpm/pool.d/$app.conf"
ynh_backup_if_checksum_is_different "$finalphpconf"
sudo cp ../conf/php-fpm.conf "$finalphpconf"
ynh_replace_string "__NAMETOCHANGE__" "$app" "$finalphpconf"
ynh_replace_string "__FINALPATH__" "$final_path" "$finalphpconf"
ynh_replace_string "__USER__" "$app" "$finalphpconf"
sudo chown root: "$finalphpconf"
ynh_store_file_checksum "$finalphpconf"
if [ -e "../conf/php-fpm.ini" ]
then
finalphpini="/etc/php5/fpm/conf.d/20-$app.ini"
ynh_backup_if_checksum_is_different "$finalphpini"
sudo cp ../conf/php-fpm.ini "$finalphpini"
sudo chown root: "$finalphpini"
ynh_store_file_checksum "$finalphpini"
fi
sudo systemctl reload php5-fpm
}
# Remove the dedicated php-fpm config
#
# usage: ynh_remove_fpm_config
ynh_remove_fpm_config () {
ynh_secure_remove "/etc/php5/fpm/pool.d/$app.conf"
ynh_secure_remove "/etc/php5/fpm/conf.d/20-$app.ini" 2>&1
sudo systemctl reload php5-fpm
}
# Create a dedicated systemd config
#
# usage: ynh_add_systemd_config
ynh_add_systemd_config () {
finalsystemdconf="/etc/systemd/system/$app.service"
ynh_backup_if_checksum_is_different "$finalsystemdconf"
sudo cp ../conf/systemd.service "$finalsystemdconf"
# To avoid a break by set -u, use a void substitution ${var:-}. If the variable is not set, it's simply set with an empty variable.
# Substitute in a nginx config file only if the variable is not empty
if test -n "${final_path:-}"; then
ynh_replace_string "__FINALPATH__" "$final_path" "$finalsystemdconf"
fi
if test -n "${app:-}"; then
ynh_replace_string "__APP__" "$app" "$finalsystemdconf"
fi
ynh_store_file_checksum "$finalsystemdconf"
sudo chown root: "$finalsystemdconf"
sudo systemctl enable $app
sudo systemctl daemon-reload
}
# Remove the dedicated systemd config
#
# usage: ynh_remove_systemd_config
ynh_remove_systemd_config () {
finalsystemdconf="/etc/systemd/system/$app.service"
if [ -e "$finalsystemdconf" ]; then
sudo systemctl stop $app
sudo systemctl disable $app
ynh_secure_remove "$finalsystemdconf"
fi
}

View file

@ -1,33 +1,81 @@
#!/bin/bash #!/bin/bash
# Exit on command errors and treat unset variables as an error #=================================================
# GENERIC START
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
# Exit on command errors and treat access to unset variables as an error
set -eu set -eu
# See comments in install script #=================================================
app=$YNH_APP_INSTANCE_NAME # IMPORT GENERIC HELPERS
#=================================================
# Source YunoHost helpers if [ ! -e _common.sh ]; then
# Get the _common.sh file if it's not in the current directory
cp ../settings/scripts/_common.sh ./_common.sh
chmod a+rx _common.sh
fi
source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
# Backup sources & data #=================================================
# Note: the last argument is where to save this path, see the restore script. # LOAD SETTINGS
ynh_backup "/var/www/${app}" "sources" #=================================================
### MySQL (remove if not used) ### app=$YNH_APP_INSTANCE_NAME
# If a MySQL database is used:
# # Dump the database
# dbname=$app
# dbuser=$app
# dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
# mysqldump -u "$dbuser" -p"$dbpass" --no-create-db "$dbname" > ./dump.sql
### MySQL end ###
# Copy NGINX configuration final_path=$(ynh_app_setting_get $app final_path)
domain=$(ynh_app_setting_get "$app" domain) domain=$(ynh_app_setting_get $app domain)
ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" "nginx.conf" db_name=$(ynh_app_setting_get $app db_name)
db_pwd=$(ynh_app_setting_get $app mysqlpwd)
### PHP (remove if not used) ### #=================================================
# If a dedicated php-fpm process is used: # STANDARD BACKUP STEPS
# # Copy PHP-FPM pool configuration #=================================================
# ynh_backup "/etc/php5/fpm/pool.d/${app}.conf" "php-fpm.conf" # BACKUP THE APP MAIN DIR
### PHP end ### #=================================================
ynh_backup "$final_path" "${backup_dir}$final_path"
#=================================================
# BACKUP THE NGINX CONFIGURATION
#=================================================
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" "${backup_dir}/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# BACKUP THE PHP-FPM CONFIGURATION
#=================================================
ynh_backup "/etc/php5/fpm/pool.d/$app.conf" "${backup_dir}/etc/php5/fpm/pool.d/$app.conf"
ynh_backup "/etc/php5/fpm/conf.d/20-$app.ini" "${backup_dir}/etc/php5/fpm/conf.d/20-$app.ini"
#=================================================
# BACKUP THE MYSQL DATABASE
#=================================================
ynh_mysql_dump_db "$db_name" > db.sql
ynh_backup "db.sql" "${backup_dir}/db.sql"
#=================================================
# SPECIFIC BACKUP
#=================================================
# BACKUP LOGROTATE
#=================================================
ynh_backup "/etc/logrotate.d/$app" "${backup_dir}/etc/logrotate.d/$app"
#=================================================
# BACKUP SYSTEMD
#=================================================
ynh_backup "/etc/systemd/system/$app.service" "${backup_dir}/etc/systemd/system/$app.service"
#=================================================
# BACKUP THE CRON FILE
#=================================================
ynh_backup "/etc/cron.d/$app" "${backup_dir}/etc/cron.d/$app"

View file

@ -1,7 +1,30 @@
#!/bin/bash #!/bin/bash
# Exit on command errors and treat unset variables as an error #=================================================
set -eu # GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH
admin=$YNH_APP_ARG_ADMIN
is_public=$YNH_APP_ARG_IS_PUBLIC
language=$YNH_APP_ARG_LANGUAGE
# This is a multi-instance app, meaning it can be installed several times independently # 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 id of the app as stated in the manifest is available as $YNH_APP_ID
@ -15,78 +38,165 @@ set -eu
# db names, ... # db names, ...
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
# Retrieve arguments #=================================================
domain=$YNH_APP_ARG_DOMAIN # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
path_url=$YNH_APP_ARG_PATH #=================================================
admin=$YNH_APP_ARG_ADMIN
is_public=$YNH_APP_ARG_IS_PUBLIC
language=$YNH_APP_ARG_LANGUAGE
# Source YunoHost helpers # Normalize the url path syntax
source /usr/share/yunohost/helpers path_url=$(ynh_normalize_url_path $path_url)
# Save app settings # Check web path availability
ynh_app_setting_set "$app" admin "$admin" ynh_webpath_available $domain $path_url
ynh_app_setting_set "$app" is_public "$is_public" # Register (book) web path
ynh_app_setting_set "$app" language "$language" ynh_webpath_register $app $domain $path_url
# Check domain/path availability final_path=/var/www/$app
sudo yunohost app checkurl "${domain}${path_url}" -a "$app" \ test ! -e "$final_path" || ynh_die "This path already contains a folder"
|| ynh_die "Path not available: ${domain}${path_url}"
# Copy source files #=================================================
src_path=/var/www/$app # STORE SETTINGS FROM MANIFEST
sudo mkdir -p $src_path #=================================================
sudo cp -a ../sources/. $src_path
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 is_public $is_public
ynh_app_setting_set $app language $language
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# FIND AND OPEN A PORT
#=================================================
# Find a free port
port=$(ynh_find_port 8095)
# Open this port
yunohost firewall allow --no-upnp TCP $port 2>&1
ynh_app_setting_set $app port $port
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_install_app_dependencies deb1 deb2
#=================================================
# CREATE A MYSQL DATABASE
#=================================================
# If your app uses a MySQL database, you can use these lines to bootstrap
# a database, an associated user and save the password in app settings
db_name=$(ynh_sanitize_dbid $app)
ynh_app_setting_set $app db_name $db_name
ynh_mysql_setup_db $db_name $db_name
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_app_setting_set $app final_path $final_path
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source "$final_path"
#=================================================
# NGINX CONFIGURATION
#=================================================
# Create a dedicated nginx config
ynh_add_nginx_config
#=================================================
# CREATE DEDICATED USER
#=================================================
# Create a system user
ynh_system_user_create $app
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
# Create a dedicated php-fpm config
ynh_fpm_config
#=================================================
# SPECIFIC SETUP
#=================================================
# ...
#=================================================
#=================================================
# SETUP SYSTEMD
#=================================================
# Create a dedicated systemd config
ynh_systemd_config
#=================================================
# SETUP APPLICATION WITH CURL
#=================================================
# Set right permissions for curl install
chown -R $app: $final_path
# Set the app as temporarily public for curl call
ynh_app_setting_set $app unprotected_uris "/"
# Reload SSOwat config
yunohost app ssowatconf
# Reload Nginx
systemctl reload nginx
# Installation with curl
ynh_local_curl "/INSTALL_PATH" "key1=value1" "key2=value2" "key3=value3"
#=================================================
# STORE THE CHECKSUM OF THE CONFIG FILE
#=================================================
# Calculate and store the config file checksum into the app settings
ynh_store_file_checksum "$final_path/CONFIG_FILE"
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
# Set permissions to app files # Set permissions to app files
# you may need to make some file and/or directory writeable by www-data (nginx user) chown -R root: $final_path
sudo chown -R root: $src_path
### MySQL (can be removed if not used) ### #=================================================
# If your app use a MySQL database you can use these lines to bootstrap # SETUP LOGROTATE
# a database, an associated user and save the password in app settings. #=================================================
#
# # Generate MySQL password and create database
# dbuser=$app
# dbname=$app
# dbpass=$(ynh_string_random 12)
# ynh_app_setting_set "$app" mysqlpwd "$dbpass"
# ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass"
#
# # Load initial SQL into the new database
# ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" \
# < "../sources/sql/mysql.init.sql"
### MySQL end ###
# Modify Nginx configuration file and copy it to Nginx conf directory # Use logrotate to manage application logfile(s)
nginx_conf=../conf/nginx.conf ynh_use_logrotate
sed -i "s@YNH_WWW_PATH@$path_url@g" $nginx_conf
sed -i "s@YNH_WWW_ALIAS@$src_path/@g" $nginx_conf
# If a dedicated php-fpm process is used:
# Don't forget to modify ../conf/nginx.conf accordingly or your app will not work!
# sed -i "s@YNH_WWW_APP@$app@g" $nginx_conf
sudo cp $nginx_conf /etc/nginx/conf.d/$domain.d/$app.conf
### PHP (can be removed if not used) ### #=================================================
# If a dedicated php-fpm process is used: # ADVERTISE SERVICE IN ADMIN PANEL
# Don't forget to modify ../conf/php-fpm.conf accordingly or your app will not work! #=================================================
#
# # Modify PHP-FPM pool configuration and copy it to the pool directory
# sed -i "s@YNH_WWW_APP@$app@g" ../conf/php-fpm.conf
# sed -i "s@YNH_WWW_ALIAS@$src_path/@g" ../conf/php-fpm.conf
# finalphpconf=/etc/php5/fpm/pool.d/$app.conf
# sudo cp ../conf/php-fpm.conf $finalphpconf
# sudo chown root: $finalphpconf
# sudo chmod 644 $finalphpconf
# sudo service php5-fpm reload
### PHP end ###
# If app is public, add url to SSOWat conf as skipped_uris yunohost service add NAME_INIT.D --log "/var/log/FILE.log"
if [[ $is_public -eq 1 ]]; then
# unprotected_uris allows SSO credentials to be passed anyway. #=================================================
ynh_app_setting_set "$app" unprotected_uris "/" # SETUP SSOWAT
#=================================================
if [ $is_public -eq 0 ]
then # Remove the public access
ynh_app_setting_delete $app skipped_uris
fi
# Make app public if necessary
if [ $is_public -eq 1 ]
then
# unprotected_uris allows SSO credentials to be passed anyway.
ynh_app_setting_set $app unprotected_uris "/"
fi fi
# Reload services #=================================================
sudo service nginx reload # RELOAD NGINX
#=================================================
systemctl reload nginx

View file

@ -1,34 +1,115 @@
#!/bin/bash #!/bin/bash
# See comments in install script #=================================================
app=$YNH_APP_INSTANCE_NAME # GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Source YunoHost helpers source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
# Retrieve app settings #=================================================
domain=$(ynh_app_setting_get "$app" domain) # LOAD SETTINGS
#=================================================
# Remove sources app=$YNH_APP_INSTANCE_NAME
sudo rm -rf /var/www/$app
# Remove nginx configuration file domain=$(ynh_app_setting_get $app domain)
sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf port=$(ynh_app_setting_get $app port)
db_name=$(ynh_app_setting_get $app db_name)
### PHP (remove if not used) ### #=================================================
# If a dedicated php-fpm process is used: # STANDARD REMOVE
# sudo rm -f /etc/php5/fpm/pool.d/$app.conf #=================================================
# sudo service php5-fpm reload # STOP AND REMOVE SERVICE
### PHP end ### #=================================================
### MySQL (remove if not used) ### # Remove the dedicated systemd config
# If a MySQL database is used: ynh_remove_systemd_config
# # Drop MySQL database and user
# dbname=$app
# dbuser=$app
# ynh_mysql_drop_db "$dbname" || true
# ynh_mysql_drop_user "$dbuser" || true
### MySQL end ###
# Reload nginx service #=================================================
sudo service nginx reload # REMOVE SERVICE FROM ADMIN PANEL
#=================================================
if yunohost service status | grep -q $app
then
echo "Remove $app service"
yunohost service remove $app
fi
#=================================================
# REMOVE DEPENDENCIES
#=================================================
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#=================================================
# REMOVE THE MYSQL DATABASE
#=================================================
# Remove a database if it exists, along with the associated user
ynh_mysql_remove_db $db_name $db_name
#=================================================
# REMOVE APP MAIN DIR
#=================================================
# Remove the app directory securely
ynh_secure_remove "/var/www/$app"
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
# Remove the dedicated nginx config
ynh_remove_nginx_config
#=================================================
# REMOVE PHP-FPM CONFIGURATION
#=================================================
# Remove the dedicated php-fpm config
ynh_remove_fpm_config
#=================================================
# REMOVE LOGROTATE CONFIGURATION
#=================================================
# Remove the app-specific logrotate config
ynh_remove_logrotate
#=================================================
# CLOSE A PORT
#=================================================
if yunohost firewall list | grep -q "\- $port$"
then
echo "Close port $port"
QUIET yunohost firewall disallow TCP $port
fi
#=================================================
# SPECIFIC REMOVE
#=================================================
# REMOVE THE CRON FILE
#=================================================
# Remove a cron file
ynh_secure_remove "/etc/cron.d/$app"
# Remove a directory securely
ynh_secure_remove "/etc/$app/"
# Remove the log files
ynh_secure_remove "/var/log/$app/"
#=================================================
# GENERIC FINALIZATION
#=================================================
# REMOVE DEDICATED USER
#=================================================
# Delete a system user
ynh_system_user_delete $app

View file

@ -1,52 +1,128 @@
#!/bin/bash #!/bin/bash
# Note: each files and directories you've saved using the ynh_backup helper #=================================================
# will be located in the current directory, regarding the last argument. # GENERIC START
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
# Exit on command errors and treat unset variables as an error # Exit on command errors and treat access to unset variables as an error
set -eu set -eu
# See comments in install script #=================================================
app=$YNH_APP_INSTANCE_NAME # IMPORT GENERIC HELPERS
#=================================================
# Source YunoHost helpers if [ ! -e _common.sh ]; then
# Get the _common.sh file if it's not in the current directory
cp ../settings/scripts/_common.sh ./_common.sh
chmod a+rx _common.sh
fi
source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
# Retrieve old app settings #=================================================
domain=$(ynh_app_setting_get "$app" domain) # LOAD SETTINGS
path_url=$(ynh_app_setting_get "$app" path_url) #=================================================
# Check domain/path availability app=$YNH_APP_INSTANCE_NAME
sudo yunohost app checkurl "${domain}${path_url}" -a "$app" \
|| ynh_die "Path not available: ${domain}${path_url}"
# Restore sources & data domain=$(ynh_app_setting_get $app domain)
src_path="/var/www/${app}" path_url=$(ynh_app_setting_get $app path)
sudo cp -a ./sources "$src_path" final_path=$(ynh_app_setting_get $app final_path)
db_name=$(ynh_app_setting_get $app db_name)
# Restore permissions to app files #=================================================
# you may need to make some file and/or directory writeable by www-data (nginx user) # CHECK IF THE APP CAN BE RESTORED
sudo chown -R root: "$src_path" #=================================================
### MySQL (remove if not used) ### yunohost app checkurl "${domain}${path_url}" -a "$app" \
# If a MySQL database is used: || ynh_die "Path not available: ${domain}${path_url}"
# # Create and restore the database test ! -d $final_path \
# dbname=$app || ynh_die "There is already a directory: $final_path "
# dbuser=$app
# dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
# ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass"
# ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < ./dump.sql
### MySQL end ###
# Restore NGINX configuration #=================================================
sudo cp -a ./nginx.conf "/etc/nginx/conf.d/${domain}.d/${app}.conf" # STANDARD RESTORATION STEPS
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
### PHP (remove if not used) ### ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
# If a dedicated php-fpm process is used:
# # Copy PHP-FPM pool configuration and reload the service
# sudo cp -a ./php-fpm.conf "/etc/php5/fpm/pool.d/${app}.conf"
# sudo service php5-fpm reload
### PHP end ###
# Restart webserver #=================================================
sudo service nginx reload # RESTORE THE APP MAIN DIR
#=================================================
ynh_restore_file "$final_path"
#=================================================
# RESTORE 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
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
# Create the dedicated user (if not existing)
ynh_system_user_create $app
#=================================================
# RESTORE USER RIGHTS
#=================================================
# Restore permissions on app files
chown -R root: $final_path
#=================================================
# RESTORE THE PHP-FPM CONFIGURATION
#=================================================
ynh_restore_file "/etc/php5/fpm/pool.d/$app.conf"
ynh_restore_file "/etc/php5/fpm/conf.d/20-$app.ini"
#=================================================
# SPECIFIC RESTORATION
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
# Define and install dependencies
ynh_install_app_dependencies deb1 deb2
#=================================================
# ADVERTISE SERVICE IN ADMIN PANEL
#=================================================
yunohost service add $app --log "/var/log/$app/APP.log"
#=================================================
# RESTORE SYSTEMD
#=================================================
ynh_restore_file "/etc/systemd/system/$app.service"
systemctl enable $app.service
#=================================================
# RESTORE THE CRON FILE
#=================================================
ynh_restore_file "/etc/cron.d/$app"
#=================================================
# BACKUP THE LOGROTATE CONFIGURATION
#=================================================
ynh_restore_file "/etc/logrotate.d/$app"
#=================================================
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX AND PHP-FPM
#=================================================
systemctl reload php5-fpm
systemctl reload nginx

View file

@ -1,59 +1,133 @@
#!/bin/bash #!/bin/bash
# Exit on command errors and treat unset variables as an error #=================================================
set -eu # GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# See comments in install script source _common.sh
app=$YNH_APP_INSTANCE_NAME
# Source YunoHost helpers
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
# Retrieve app settings #=================================================
domain=$(ynh_app_setting_get "$app" domain) # LOAD SETTINGS
path_url=$(ynh_app_setting_get "$app" path_url) #=================================================
admin=$(ynh_app_setting_get "$app" admin)
is_public=$(ynh_app_setting_get "$app" is_public)
language=$(ynh_app_setting_get "$app" language)
# Remove trailing "/" for next commands app=$YNH_APP_INSTANCE_NAME
path_url=${path_url%/}
# Copy source files domain=$(ynh_app_setting_get $app domain)
src_path=/var/www/$app path_url=$(ynh_app_setting_get $app path)
sudo mkdir -p $src_path admin=$(ynh_app_setting_get $app admin)
sudo cp -a ../sources/. $src_path is_public=$(ynh_app_setting_get $app is_public)
final_path=$(ynh_app_setting_get $app final_path)
port=$(ynh_app_setting_get $app port)
db_name=$(ynh_app_setting_get $app db_name)
# Set permissions to app files #=================================================
# you may need to make some file and/or directory writeable by www-data (nginx user) # ENSURE DOWNWARD COMPATIBILITY
sudo chown -R root: $src_path #=================================================
# Modify Nginx configuration file and copy it to Nginx conf directory if [ "$is_public" = "Yes" ]; then
nginx_conf=../conf/nginx.conf ynh_app_setting_set $app is_public 1 # Fix is_public as a boolean value
sed -i "s@YNH_WWW_PATH@$path_url@g" $nginx_conf is_public=1
sed -i "s@YNH_WWW_ALIAS@$src_path/@g" $nginx_conf elif [ "$is_public" = "No" ]; then
# If a dedicated php-fpm process is used: ynh_app_setting_set $app is_public 0
# is_public=0
# sed -i "s@YNH_WWW_APP@$app@g" $nginx_conf
sudo cp $nginx_conf /etc/nginx/conf.d/$domain.d/$app.conf
### PHP (remove if not used) ###
# If a dedicated php-fpm process is used:
# # Modify PHP-FPM pool configuration and copy it to the pool directory
# sed -i "s@YNH_WWW_APP@$app@g" ../conf/php-fpm.conf
# sed -i "s@YNH_WWW_ALIAS@$src_path/@g" ../conf/php-fpm.conf
# finalphpconf=/etc/php5/fpm/pool.d/$app.conf
# sudo cp ../conf/php-fpm.conf $finalphpconf
# sudo chown root: $finalphpconf
# sudo chmod 644 $finalphpconf
# sudo service php5-fpm restart
### PHP end ###
# If app is public, add url to SSOWat conf as skipped_uris
if [[ $is_public -eq 1 ]]; then
# See install script
ynh_app_setting_set "$app" unprotected_uris "/"
fi fi
# Reload nginx service if [ -z $db_name ]; then # If db_name doesn't exist, create it
sudo service nginx reload db_name=$(ynh_sanitize_dbid $app)
ynh_app_setting_set $app db_name $db_name
fi
#=================================================
# CHECK THE PATH
#=================================================
# Normalize the URL path syntax
path_url=$(ynh_normalize_url_path $path_url)
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source "$final_path"
#=================================================
# NGINX CONFIGURATION
#=================================================
# Create a dedicated nginx config
ynh_add_nginx_config
#=================================================
# CREATE DEDICATED USER
#=================================================
# Create a system user
ynh_system_user_create $app
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
# Create a dedicated php-fpm config
ynh_fpm_config
#=================================================
# SPECIFIC UPGRADE
#=================================================
# ...
#=================================================
# Verify the checksum and backup the file if it's different
ynh_backup_if_checksum_is_different "$final_path/CONFIG_FILE"
# Recalculate and store the config file checksum into the app settings
ynh_store_file_checksum "$final_path/CONFIG_FILE"
#=================================================
# SETUP LOGROTATE
#=================================================
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate
#=================================================
# SETUP SYSTEMD
#=================================================
# Create a dedicated systemd config
ynh_systemd_config
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
# Set right permissions for curl installation
chown -R root: $final_path
#=================================================
# SETUP SSOWAT
#=================================================
if [ $is_public -eq 0 ]
then # Remove the public access
ynh_app_setting_delete $app skipped_uris
fi
# Make app public if necessary
if [ $is_public -eq 1 ]
then
# unprotected_uris allows SSO credentials to be passed anyway
ynh_app_setting_set $app unprotected_uris "/"
fi
#=================================================
# RELOAD NGINX
#=================================================
systemctl reload nginx

2
sources/extra_files/app/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
*~
*.sw[op]

2
sources/patches/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
*~
*.sw[op]