mirror of
https://github.com/YunoHost-Apps/my_webapp_ynh.git
synced 2024-09-03 19:46:26 +02:00
Merge pull request #34 from YunoHost-Apps/package_upgrade
Package upgrade
This commit is contained in:
commit
c0f51d42d7
11 changed files with 227 additions and 109 deletions
56
README.md
56
README.md
|
@ -1,10 +1,10 @@
|
|||
# Custom Webapp
|
||||
# Custom Webapp for YunoHost
|
||||
|
||||
[](https://dash.yunohost.org/appci/app/my_webapp)
|
||||
[](https://install-app.yunohost.org/?app=my_webapp)
|
||||
[](https://install-app.yunohost.org/?app=my_webapp)
|
||||
|
||||
|
||||
Empty application with SFTP access to the Web directory.
|
||||
> *This package allow you to install Custom Webapp quickly and simply on a YunoHost server.
|
||||
If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.*
|
||||
|
||||
## Overview
|
||||
|
||||
|
@ -20,12 +20,54 @@ during the installation. Under the Web directory, you will see a `www` folder
|
|||
which contains the public files served by this app. You can put all the files
|
||||
of your custom Web application inside.
|
||||
|
||||
### SFTP port
|
||||
**Shipped version:** 1.0
|
||||
|
||||
## Screenshots
|
||||
|
||||
## Demo
|
||||
|
||||
## Configuration
|
||||
|
||||
## Documentation
|
||||
|
||||
* YunoHost documentation: https://github.com/YunoHost/doc/blob/master/app_my_webapp.md
|
||||
|
||||
## YunoHost specific features
|
||||
|
||||
#### Multi-users support
|
||||
|
||||
#### Supported architectures
|
||||
|
||||
* x86-64b - [](https://ci-apps.yunohost.org/ci/apps/my_webapp/)
|
||||
* ARMv8-A - [](https://ci-apps-arm.yunohost.org/ci/apps/my_webapp/)
|
||||
* Jessie x86-64b - [](https://ci-stretch.nohost.me/ci/apps/my_webapp/)
|
||||
|
||||
## Limitations
|
||||
|
||||
## Additional information
|
||||
|
||||
#### SFTP port
|
||||
|
||||
You may have change the SSH port as described
|
||||
[here (section "Modifier le port SSH"](https://yunohost.org/#/security_fr) ;
|
||||
then you should use this port to update your website with SFTP.
|
||||
|
||||
## Links
|
||||
## Links
|
||||
|
||||
**YunoHost**: https://yunohost.org/
|
||||
* Report a bug: https://github.com/YunoHost-Apps/my_webapp_ynh/issues
|
||||
* YunoHost website: https://yunohost.org/
|
||||
|
||||
---
|
||||
|
||||
Developers info
|
||||
----------------
|
||||
|
||||
**Only if you want to use a testing branch for coding, instead of merging directly into master.**
|
||||
Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/my_webapp_ynh/tree/testing).
|
||||
|
||||
To try the testing branch, please proceed like that.
|
||||
```
|
||||
sudo yunohost app install https://github.com/YunoHost-Apps/my_webapp_ynh/tree/testing --debug
|
||||
or
|
||||
sudo yunohost app upgrade my_webapp -u https://github.com/YunoHost-Apps/my_webapp_ynh/tree/testing --debug
|
||||
```
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
|
||||
location __PATH__/ {
|
||||
|
||||
# Path to source
|
||||
alias __FINALPATH__/www/ ;
|
||||
# Path to source
|
||||
alias __FINALPATH__/www/;
|
||||
|
||||
# Force usage of https
|
||||
# Force usage of https
|
||||
if ($scheme = http) {
|
||||
rewrite ^ https://$server_name$request_uri? permanent;
|
||||
}
|
||||
|
@ -32,8 +32,7 @@ location __PATH__/ {
|
|||
# Execute and serve PHP files
|
||||
location ~ [^/]\.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;
|
||||
include fastcgi_params;
|
||||
fastcgi_param REMOTE_USER $remote_user;
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
; Start a new pool named 'www'.
|
||||
; the variable $pool can we used in any directive and will be replaced by the
|
||||
; the variable $pool can be used in any directive and will be replaced by the
|
||||
; pool name ('www' here)
|
||||
[__NAMETOCHANGE__]
|
||||
|
||||
; Per pool prefix
|
||||
; It only applies on the following directives:
|
||||
; - 'access.log'
|
||||
; - 'slowlog'
|
||||
; - 'listen' (unixsocket)
|
||||
; - 'chroot'
|
||||
|
@ -24,28 +25,35 @@ group = __USER__
|
|||
|
||||
; The address on which to accept FastCGI requests.
|
||||
; Valid syntaxes are:
|
||||
; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific address on
|
||||
; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on
|
||||
; a specific port;
|
||||
; 'port' - to listen on a TCP socket to all addresses on a
|
||||
; specific port;
|
||||
; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
|
||||
; a specific port;
|
||||
; 'port' - to listen on a TCP socket to all addresses
|
||||
; (IPv6 and IPv4-mapped) on a specific port;
|
||||
; '/path/to/unix/socket' - to listen on a unix socket.
|
||||
; Note: This value is mandatory.
|
||||
listen = /var/run/php5-fpm-__NAMETOCHANGE__.sock
|
||||
listen = /var/run/php/php7.0-fpm-__NAMETOCHANGE__.sock
|
||||
|
||||
; Set listen(2) backlog. A value of '-1' means unlimited.
|
||||
; Default Value: 128 (-1 on FreeBSD and OpenBSD)
|
||||
;listen.backlog = 128
|
||||
; Set listen(2) backlog.
|
||||
; Default Value: 511 (-1 on FreeBSD and OpenBSD)
|
||||
;listen.backlog = 511
|
||||
|
||||
; 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.
|
||||
; 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.
|
||||
; When POSIX Access Control Lists are supported you can set them using
|
||||
; these options, value is a comma separated list of user/group names.
|
||||
; When set, listen.owner and listen.group are ignored
|
||||
;listen.acl_users =
|
||||
;listen.acl_groups =
|
||||
|
||||
; List of addresses (IPv4/IPv6) of FastCGI clients which are allowed to connect.
|
||||
; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original
|
||||
; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address
|
||||
; must be separated by a comma. If this value is left blank, connections will be
|
||||
|
@ -59,7 +67,13 @@ listen.group = www-data
|
|||
; - The pool processes will inherit the master process priority
|
||||
; unless it specified otherwise
|
||||
; 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.
|
||||
; Possible Values:
|
||||
|
@ -96,7 +110,7 @@ pm = 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.
|
||||
pm.max_children = 10
|
||||
pm.max_children = 5
|
||||
|
||||
; The number of child processes created on startup.
|
||||
; Note: Used only when pm is set to 'dynamic'
|
||||
|
@ -117,12 +131,12 @@ pm.max_spare_servers = 3
|
|||
; Note: Used only when pm is set to 'ondemand'
|
||||
; Default Value: 10s
|
||||
;pm.process_idle_timeout = 10s;
|
||||
|
||||
|
||||
; The number of requests each child process should execute before respawning.
|
||||
; This can be useful to work around memory leaks in 3rd party libraries. For
|
||||
; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
|
||||
; 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
|
||||
; recognized as a status page. It shows the following informations:
|
||||
|
@ -170,7 +184,7 @@ pm.max_requests = 500
|
|||
;
|
||||
; By default the status page only outputs short status. Passing 'full' in the
|
||||
; query string will also return status for each pool process.
|
||||
; Example:
|
||||
; Example:
|
||||
; http://www.foo.bar/status?full
|
||||
; http://www.foo.bar/status?json&full
|
||||
; http://www.foo.bar/status?html&full
|
||||
|
@ -215,7 +229,7 @@ pm.max_requests = 500
|
|||
; 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
|
||||
; It's available in: /usr/share/php/7.0/fpm/status.html
|
||||
;
|
||||
; Note: The value must start with a leading slash (/). The value can be
|
||||
; anything, but it may not be a good idea to use the .php extension or it
|
||||
|
@ -275,7 +289,7 @@ pm.max_requests = 500
|
|||
; - %{megabytes}M
|
||||
; - %{mega}M
|
||||
; %n: pool name
|
||||
; %o: ouput header
|
||||
; %o: output header
|
||||
; it must be associated with embraces to specify the name of the header:
|
||||
; - %{Content-Type}o
|
||||
; - %{X-Powered-By}o
|
||||
|
@ -283,7 +297,7 @@ pm.max_requests = 500
|
|||
; - ....
|
||||
; %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 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
|
||||
|
@ -291,47 +305,51 @@ pm.max_requests = 500
|
|||
; %t: server time the request was received
|
||||
; it can accept a strftime(3) format:
|
||||
; %d/%b/%Y:%H:%M:%S %z (default)
|
||||
; The strftime(3) format must be encapsuled in a %{<strftime_format>}t tag
|
||||
; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t
|
||||
; %T: time the log has been written (the request has finished)
|
||||
; it can accept a strftime(3) format:
|
||||
; %d/%b/%Y:%H:%M:%S %z (default)
|
||||
; The strftime(3) format must be encapsuled in a %{<strftime_format>}t tag
|
||||
; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t
|
||||
; %u: remote user
|
||||
;
|
||||
; Default: "%R - %u %t \"%m %r\" %s"
|
||||
;access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%"
|
||||
|
||||
|
||||
; The log file for slow requests
|
||||
; Default Value: not set
|
||||
; Note: slowlog is mandatory if request_slowlog_timeout is set
|
||||
slowlog = /var/log/nginx/__NAMETOCHANGE__.slow.log
|
||||
|
||||
;slowlog = log/$pool.log.slow
|
||||
|
||||
; The timeout for serving a single request after which a PHP backtrace will be
|
||||
; dumped to the 'slowlog' file. A value of '0s' means 'off'.
|
||||
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
|
||||
; Default Value: 0
|
||||
request_slowlog_timeout = 5s
|
||||
|
||||
;request_slowlog_timeout = 0
|
||||
|
||||
; The timeout for serving a single request after which the worker process will
|
||||
; be killed. This option should be used when the 'max_execution_time' ini option
|
||||
; does not stop script execution for some reason. A value of '0' means 'off'.
|
||||
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
|
||||
; Default Value: 0
|
||||
request_terminate_timeout = 1d
|
||||
|
||||
|
||||
; Set open file descriptor rlimit.
|
||||
; Default Value: system defined value
|
||||
;rlimit_files = 1024
|
||||
|
||||
|
||||
; Set max core size rlimit.
|
||||
; Possible Values: 'unlimited' or an integer greater or equal to 0
|
||||
; Default Value: system defined value
|
||||
;rlimit_core = 0
|
||||
|
||||
|
||||
; Chroot to this directory at the start. This value must be defined as an
|
||||
; absolute path. When this value is not set, chroot is not used.
|
||||
; Note: you can prefix with '$prefix' to chroot to the pool prefix or one
|
||||
; of its subdirectories. If the pool prefix is not set, the global prefix
|
||||
; will be used instead.
|
||||
; Note: chrooting is a great security feature and should be used whenever
|
||||
; Note: chrooting is a great security feature and should be used whenever
|
||||
; possible. However, all PHP paths will be relative to the chroot
|
||||
; (error_log, sessions.save_path, ...).
|
||||
; Default Value: not set
|
||||
|
@ -347,16 +365,25 @@ chdir = __FINALPATH__
|
|||
; Note: on highloaded environement, this can cause some delay in the page
|
||||
; process time (several ms).
|
||||
; 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
|
||||
; 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.
|
||||
; execute php code.
|
||||
; Note: set an empty value to allow all extensions.
|
||||
; 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
|
||||
; the current environment.
|
||||
; Default Value: clean env
|
||||
|
@ -370,7 +397,7 @@ catch_workers_output = yes
|
|||
; overwrite the values previously defined in the php.ini. The directives are the
|
||||
; same as the PHP SAPI:
|
||||
; php_value/php_flag - you can set classic ini defines which can
|
||||
; be overwritten from PHP call 'ini_set'.
|
||||
; be overwritten from PHP call 'ini_set'.
|
||||
; php_admin_value/php_admin_flag - these directives won't be overwritten by
|
||||
; PHP call 'ini_set'
|
||||
; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no.
|
||||
|
@ -391,6 +418,17 @@ catch_workers_output = yes
|
|||
;php_admin_flag[log_errors] = on
|
||||
;php_admin_value[memory_limit] = 32M
|
||||
|
||||
; Common values to change to increase file upload limit
|
||||
; php_admin_value[upload_max_filesize] = 50M
|
||||
; php_admin_value[post_max_size] = 50M
|
||||
; php_admin_flag[mail.add_x_header] = Off
|
||||
|
||||
; Other common parameters
|
||||
; php_admin_value[max_execution_time] = 600
|
||||
; php_admin_value[max_input_time] = 300
|
||||
; php_admin_value[memory_limit] = 256M
|
||||
; php_admin_flag[short_open_tag] = On
|
||||
|
||||
; Additional php.ini defines, specific to this pool of workers.
|
||||
php_value[upload_max_filesize] = 1G
|
||||
php_value[post_max_size] = 1G
|
||||
|
|
|
@ -6,20 +6,20 @@
|
|||
"en": "Custom Web app with SFTP access",
|
||||
"fr": "Application Web personnalisée avec accès SFTP"
|
||||
},
|
||||
"version": "1.0",
|
||||
"version": "1.0~ynh1",
|
||||
"url": "https://github.com/YunoHost-Apps/my_webapp_ynh",
|
||||
"license": "free",
|
||||
"license": "GPL-3.0-only",
|
||||
"maintainer": {
|
||||
"name": "YunoHost Contributors",
|
||||
"email": "apps@yunohost.org"
|
||||
},
|
||||
"requirements": {
|
||||
"yunohost": ">= 2.7.2"
|
||||
"yunohost": ">= 3.2.0"
|
||||
},
|
||||
"multi_instance": true,
|
||||
"services": [
|
||||
"nginx",
|
||||
"php5-fpm"
|
||||
"php7.0-fpm"
|
||||
],
|
||||
"arguments": {
|
||||
"install" : [
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source ../settings/scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
|
@ -19,6 +18,7 @@ ynh_abort_if_errors
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_print_info "Loading installation settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
|
@ -32,25 +32,35 @@ with_mysql=$(ynh_app_setting_get $app with_mysql)
|
|||
#=================================================
|
||||
# BACKUP THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_print_info "Backing up the main app directory..."
|
||||
|
||||
ynh_backup "$final_path"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_print_info "Backing up nginx web server configuration..."
|
||||
|
||||
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
ynh_print_info "Backing up php-fpm configuration..."
|
||||
|
||||
ynh_backup "/etc/php5/fpm/pool.d/$app.conf"
|
||||
ynh_backup "/etc/php/7.0/fpm/pool.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE MYSQL DATABASE
|
||||
#=================================================
|
||||
|
||||
if [ $with_mysql -eq 1 ]; then
|
||||
ynh_print_info "Backing up the MySQL database..."
|
||||
ynh_mysql_dump_db "$db_name" > db.sql
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|
||||
|
|
|
@ -28,10 +28,6 @@ app=$YNH_APP_INSTANCE_NAME
|
|||
# Needed for helper "ynh_add_nginx_config"
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
|
||||
# Add settings here as needed by your application
|
||||
#db_name=$(ynh_app_setting_get "$app" db_name)
|
||||
#db_pwd=$(ynh_app_setting_get $app db_pwd)
|
||||
|
||||
#=================================================
|
||||
# CHECK THE SYNTAX OF THE PATHS
|
||||
#=================================================
|
||||
|
@ -87,12 +83,6 @@ then
|
|||
ynh_store_file_checksum "/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC MODIFICATIONS
|
||||
#=================================================
|
||||
# ...
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALISATION
|
||||
#=================================================
|
||||
|
|
|
@ -33,6 +33,7 @@ app_nb=$YNH_APP_INSTANCE_NUMBER
|
|||
#=================================================
|
||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||
#=================================================
|
||||
ynh_print_info "Validating installation parameters..."
|
||||
|
||||
final_path=/var/www/$app
|
||||
test ! -e "$final_path" || ynh_die "This path already contains a folder"
|
||||
|
@ -50,6 +51,7 @@ ynh_webpath_register $app $domain $path_url
|
|||
#=================================================
|
||||
# STORE SETTINGS FROM MANIFEST
|
||||
#=================================================
|
||||
ynh_print_info "Storing installation settings..."
|
||||
|
||||
user=webapp${app_nb}
|
||||
ynh_app_setting_set $app domain $domain
|
||||
|
@ -67,6 +69,7 @@ ynh_app_setting_set $app final_path $final_path
|
|||
#=================================================
|
||||
|
||||
if [ $with_mysql -eq 1 ]; then
|
||||
ynh_print_info "Creating a MySQL database..."
|
||||
db_name=$(ynh_sanitize_dbid $app)
|
||||
ynh_app_setting_set $app db_name $db_name
|
||||
ynh_mysql_setup_db $db_name $db_name
|
||||
|
@ -75,6 +78,7 @@ fi
|
|||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_print_info "Configuring nginx web server..."
|
||||
|
||||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config
|
||||
|
@ -82,6 +86,7 @@ ynh_add_nginx_config
|
|||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_print_info "Configuring system user..."
|
||||
|
||||
# Create a standard user (not a system user for sftp)
|
||||
ynh_system_user_exists "$user" || \
|
||||
|
@ -89,19 +94,12 @@ ynh_system_user_exists "$user" || \
|
|||
# Add the password to this user
|
||||
chpasswd <<< "${user}:${password}"
|
||||
|
||||
#=================================================
|
||||
# PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
# Create a dedicated php-fpm config
|
||||
ynh_replace_string "__USER__" "$user" "../conf/php-fpm.conf"
|
||||
ynh_add_fpm_config
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC SETUP
|
||||
#=================================================
|
||||
# CONFIGURE SSH
|
||||
#=================================================
|
||||
ynh_print_info "Configuring ssh..."
|
||||
|
||||
# Harden SSH connection for the user
|
||||
echo "##-> ${app}
|
||||
|
@ -120,8 +118,8 @@ systemctl reload ssh
|
|||
# MODIFY A CONFIG FILE
|
||||
#=================================================
|
||||
|
||||
ynh_replace_string "{DOMAIN}" "$domain" ../sources/www/index.html
|
||||
ynh_replace_string "{USER}" "$user" ../sources/www/index.html
|
||||
ynh_replace_string "__DOMAIN__" "$domain" ../sources/www/index.html
|
||||
ynh_replace_string "__USER__" "$user" ../sources/www/index.html
|
||||
|
||||
if [ $with_mysql -eq 1 ]; then
|
||||
# Store the database access
|
||||
|
@ -132,6 +130,15 @@ fi
|
|||
# Copy files to the right place
|
||||
cp -r ../sources "$final_path"
|
||||
|
||||
#=================================================
|
||||
# PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
ynh_print_info "Configuring php-fpm..."
|
||||
|
||||
# Create a dedicated php-fpm config
|
||||
ynh_replace_string "__USER__" "$user" "../conf/php-fpm.conf"
|
||||
ynh_add_fpm_config
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
|
@ -146,6 +153,7 @@ chown root: "$final_path"
|
|||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
#=================================================
|
||||
ynh_print_info "Configuring SSOwat..."
|
||||
|
||||
# Make app public if necessary
|
||||
if [ $is_public -eq 1 ]
|
||||
|
@ -156,5 +164,12 @@ fi
|
|||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_print_info "Reloading nginx web server..."
|
||||
|
||||
systemctl reload nginx
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info "Installation of $app completed"
|
||||
|
|
|
@ -12,6 +12,7 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_print_info "Loading installation settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
|
@ -30,6 +31,7 @@ final_path=$(ynh_app_setting_get $app final_path)
|
|||
#=================================================
|
||||
|
||||
if [ $with_mysql -eq 1 ]; then
|
||||
ynh_print_info "Removing the MySQL database"
|
||||
# Remove a database if it exists, along with the associated user
|
||||
ynh_mysql_remove_db $db_user $db_name
|
||||
fi
|
||||
|
@ -37,6 +39,7 @@ fi
|
|||
#=================================================
|
||||
# REMOVE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_print_info "Removing app main directory"
|
||||
|
||||
# Remove the app directory securely
|
||||
ynh_secure_remove "$final_path"
|
||||
|
@ -44,6 +47,8 @@ ynh_secure_remove "$final_path"
|
|||
#=================================================
|
||||
# REMOVE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_print_info "Removing nginx web server configuration"
|
||||
|
||||
|
||||
# Remove the dedicated nginx config
|
||||
ynh_remove_nginx_config
|
||||
|
@ -51,6 +56,7 @@ ynh_remove_nginx_config
|
|||
#=================================================
|
||||
# REMOVE PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
ynh_print_info "Removing php-fpm configuration"
|
||||
|
||||
# Remove the dedicated php-fpm config
|
||||
ynh_remove_fpm_config
|
||||
|
@ -60,6 +66,7 @@ ynh_remove_fpm_config
|
|||
#=================================================
|
||||
# REMOVE THE CUSTOM SSH CONFIG
|
||||
#=================================================
|
||||
ynh_print_info "Removing the custom ssh config"
|
||||
|
||||
sed -i "/##-> ${app}/,/##<- ${app}/d" /etc/ssh/sshd_config
|
||||
systemctl reload ssh
|
||||
|
@ -69,6 +76,13 @@ systemctl reload ssh
|
|||
#=================================================
|
||||
# REMOVE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_print_info "Removing the dedicated system user"
|
||||
|
||||
# Delete an user
|
||||
ynh_system_user_delete $user
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info "Removal of $app completed"
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source ../settings/scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
|
@ -19,6 +18,7 @@ ynh_abort_if_errors
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_print_info "Loading settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
|
@ -33,6 +33,7 @@ user=$(ynh_app_setting_get $app user)
|
|||
#=================================================
|
||||
# CHECK IF THE APP CAN BE RESTORED
|
||||
#=================================================
|
||||
ynh_print_info "Validating restoration parameters..."
|
||||
|
||||
ynh_webpath_available $domain $path_url \
|
||||
|| ynh_die "Path not available: ${domain}${path_url}"
|
||||
|
@ -50,6 +51,7 @@ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
|
|||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_print_info "Restoring the app main directory..."
|
||||
|
||||
ynh_restore_file "$final_path"
|
||||
|
||||
|
@ -58,6 +60,7 @@ ynh_restore_file "$final_path"
|
|||
#=================================================
|
||||
|
||||
if [ $with_mysql -eq 1 ]; then
|
||||
ynh_print_info "Restoring the mysql database..."
|
||||
db_pwd=$(ynh_app_setting_get $app mysqlpwd)
|
||||
ynh_mysql_setup_db $db_name $db_name $db_pwd
|
||||
ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql
|
||||
|
@ -66,6 +69,7 @@ fi
|
|||
#=================================================
|
||||
# RECREATE THE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_print_info "Recreating the dedicated system user..."
|
||||
|
||||
# Create a standard user (not a system user for sftp)
|
||||
ynh_system_user_exists "$user" || \
|
||||
|
@ -87,13 +91,14 @@ chown root: "$final_path"
|
|||
# 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"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC RESTORATION
|
||||
#=================================================
|
||||
# CONFIGURE SSH
|
||||
#=================================================
|
||||
ynh_print_info "Configuring ssh..."
|
||||
|
||||
# Harden SSH connection for the user
|
||||
echo "##-> ${app}
|
||||
|
@ -113,6 +118,13 @@ systemctl reload ssh
|
|||
#=================================================
|
||||
# RELOAD NGINX AND PHP-FPM
|
||||
#=================================================
|
||||
ynh_print_info "Reloading nginx web server and php-fpm..."
|
||||
|
||||
systemctl reload php5-fpm
|
||||
systemctl reload php7.0-fpm
|
||||
systemctl reload nginx
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info "Restoration completed for $app"
|
||||
|
|
|
@ -12,6 +12,7 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_print_info "Loading installation settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
|
@ -24,18 +25,19 @@ with_mysql=$(ynh_app_setting_get $app with_mysql)
|
|||
password=$(ynh_app_setting_get $app password)
|
||||
user=$(ynh_app_setting_get $app user)
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE UPGRADE CAN BE AUTOMATED
|
||||
#=================================================
|
||||
|
||||
([[ -n "$with_mysql" ]] && [[ -n "$password" ]] && [[ -n "$user" ]]) \
|
||||
|| ynh_die "The app changed and can not be automatically upgraded. \
|
||||
You will have to manually upgrade it following these instructions: \
|
||||
https://github.com/YunoHost-Apps/my_webapp_ynh#upgrade"
|
||||
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
ynh_print_info "Ensuring downward compatibility..."
|
||||
|
||||
# Fix is_public as a boolean value
|
||||
if [ "$is_public" = "Yes" ]; then
|
||||
ynh_app_setting_set $app is_public 1
|
||||
is_public=1
|
||||
elif [ "$is_public" = "No" ]; then
|
||||
ynh_app_setting_set $app is_public 0
|
||||
is_public=0
|
||||
fi
|
||||
|
||||
# Fix is_public as a boolean value
|
||||
if [ "$is_public" = "Yes" ]; then
|
||||
|
@ -61,6 +63,7 @@ fi
|
|||
#=================================================
|
||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
ynh_print_info "Backing up the app before upgrading (may take a while)..."
|
||||
|
||||
# Backup the current version of the app
|
||||
ynh_backup_before_upgrade
|
||||
|
@ -80,33 +83,15 @@ path_url=$(ynh_normalize_url_path $path_url)
|
|||
|
||||
#=================================================
|
||||
# STANDARD UPGRADE STEPS
|
||||
#=================================================
|
||||
|
||||
# Check if a config file was modified
|
||||
is_checksum_different () {
|
||||
local file=$1
|
||||
local checksum_setting_name=checksum_${file//[\/ ]/_} # Replace all '/' and ' ' by '_'
|
||||
local checksum_value=$(ynh_app_setting_get $app $checksum_setting_name)
|
||||
if [ -n "$checksum_value" ]
|
||||
then # Proceed only if a value was stored into the app settings
|
||||
if ! echo "$checksum_value $file" | sudo md5sum -c --status
|
||||
then # If the checksum is now different
|
||||
echo "File $file has been manually modified since the installation or last upgrade. So it will not be replaced." >&2
|
||||
echo "1"
|
||||
else
|
||||
echo "0"
|
||||
fi
|
||||
else
|
||||
echo "0"
|
||||
fi
|
||||
}
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
if [ $(is_checksum_different "/etc/nginx/conf.d/$domain.d/$app.conf") -eq 0 ]
|
||||
modified_config=$(ynh_backup_if_checksum_is_different "/etc/nginx/conf.d/$domain.d/$app.conf")
|
||||
# Replace nginx config only if it wasn't modified.
|
||||
if [ -z "$modified_config" ]
|
||||
then
|
||||
ynh_print_info "Upgrading nginx web server configuration..."
|
||||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config
|
||||
fi
|
||||
|
@ -114,6 +99,7 @@ fi
|
|||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_print_info "Making sure dedicated system user exists..."
|
||||
|
||||
# Create a standard user (not a system user for sftp)
|
||||
ynh_system_user_exists "$user" || \
|
||||
|
@ -129,8 +115,11 @@ usermod -g "$user" "$user"
|
|||
# PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
if [ $(is_checksum_different "/etc/php5/fpm/pool.d/$app.conf") -eq 0 ]
|
||||
modified_config=$(ynh_backup_if_checksum_is_different "/etc/php5/fpm/pool.d/$app.conf")
|
||||
# Replace nginx config only if it wasn't modified.
|
||||
if [ -z "$modified_config" ]
|
||||
then
|
||||
ynh_print_info "Upgrading php-fpm configuration..."
|
||||
# Create a dedicated php-fpm config
|
||||
ynh_replace_string "__USER__" "$user" "../conf/php-fpm.conf"
|
||||
ynh_add_fpm_config
|
||||
|
@ -141,9 +130,10 @@ fi
|
|||
#=================================================
|
||||
# CONFIGURE SSH
|
||||
#=================================================
|
||||
ynh_print_info "Configuring ssh..."
|
||||
|
||||
# Remove the previous config for upgrading it
|
||||
sudo sed -i "/##-> ${app}/,/##<- ${app}/d" /etc/ssh/sshd_config
|
||||
sed -i "/##-> ${app}/,/##<- ${app}/d" /etc/ssh/sshd_config
|
||||
# Harden SSH connection for the user
|
||||
echo "##-> ${app}
|
||||
# Hardening user connection
|
||||
|
@ -170,6 +160,7 @@ chown root: "$final_path"
|
|||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
#=================================================
|
||||
ynh_print_info "Upgrading SSOwat configuration..."
|
||||
|
||||
# Make app public if necessary
|
||||
if [ $is_public -eq 1 ]
|
||||
|
@ -180,5 +171,12 @@ fi
|
|||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_print_info "Reloading nginx web server..."
|
||||
|
||||
systemctl reload nginx
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info "Upgrade of $app completed"
|
||||
|
|
|
@ -16,11 +16,11 @@
|
|||
</p>
|
||||
<dl>
|
||||
<dt>Domain</dt>
|
||||
<dd>{DOMAIN}</dd>
|
||||
<dd>__DOMAIN__</dd>
|
||||
<dt>Port</dt>
|
||||
<dd>22 (or the port you defined <a href="https://yunohost.org/#/security_fr">if you change the ssh port</a>)</dd>
|
||||
<dt>User</dt>
|
||||
<dd>{USER}</dd>
|
||||
<dd>__USER__</dd>
|
||||
<dt>Password</dt>
|
||||
<dd><i>the one you set at installation</i></dd>
|
||||
</dl>
|
||||
|
|
Loading…
Add table
Reference in a new issue