mirror of
https://github.com/YunoHost-Apps/grav_ynh.git
synced 2024-09-03 19:16:01 +02:00
Upgrade to v1.6.26, YNH v3.7 permissions system, PHP version handling, fix CI badge (#39)
* Fix check_process (#34) * Upgrade to 1.6.26, YNH v3.7 permissions system and PHP version handling (#37) * [upg] grav 1.6.16 Makes the app agnostic regarding the needed PHP version. Includes experimental helpers to install various PHP versions, if needed. Includes Grav v1.6.16 with PHP 7.2. * [enh] adding LDAP login for designated admin It is a bit hacky, since YNH does not have yet LDAP groups support: groups=usernames. To add more users, manually edit the configuration file in the admin. * [enh] use the permissions system * [enh] setting permissions up * [enh] restore php before adding conf file * [enh] avoid adding repo if sury list already exists This prevents getting multiple warning messages about duplicated repos. * [fix] remove order * [fix] testing and setting permissions * [upg] app version and remove php7.0-fpm dependency * Fix check_process (#34) * [upg] permissions configuration for install and upgrade * [upg] grav v1.6.23 * [upg] new permissions system * [fix] check_process is_public * [fix] missing 1 more_set_headers in nginx.conf * [fix] upgrade: allow visitors if was public * [fix] experimental_helpers directory in remove * [fix] retrieve phpversion in remove * [fix] remove old php-fpm config if needed in upgrade * [fix] helpers in subdirectory * [enh] no default group needed * [enh] update all plugins during upgrade * [enh] adding progress messages * [fix] specify phpversion in change_url * [enh] to v3.7 standards * [upg] grav v1.6.26 * [rem] ynh_permission_has_user is now official * [upg] check_process * [fix] php-fpm upgrade * [fix] use YNH_PHP_VERSION instead of phpversion in restore * [fix] php and chown in upgrade * [fix] check_process * [fix] app-upgrade.src * [fix] php-fpm and [rem] progression --time * [fix] restart php-fpm instead of reloading * [fix] user home_dir and permissions * [fix] upgrade publicness * [fix] CI badge on README (#38) * Fix failing check_process (#35) * Fix check_process (#34) * Fix CI badge on README Co-authored-by: tituspijean <tituspijean@outlook.com> Co-authored-by: Kayou <pierre.moltess@gmail.com> Co-authored-by: Alexandre Aubin <alex.aubin@mailoo.org>
This commit is contained in:
parent
5e98c15e23
commit
2909df6045
15 changed files with 379 additions and 228 deletions
18
README.md
18
README.md
|
@ -1,4 +1,4 @@
|
|||
[![Integration level](https://ci-apps.yunohost.org/ci/logs/grav%20%28Community%29.svg)](https://ci-apps.yunohost.org/ci/)
|
||||
[![Integration level](https://dash.yunohost.org/integration/grav.svg)](https://ci-apps.yunohost.org/ci/apps/grav/)
|
||||
|
||||
[![Install Grav with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=grav)
|
||||
|
||||
|
@ -10,7 +10,7 @@ If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to
|
|||
* http://getgrav.org/
|
||||
* https://github.com/getgrav/grav
|
||||
|
||||
Provided version: **1.5.10**
|
||||
Provided version: **1.6.26**
|
||||
|
||||
## Installation
|
||||
|
||||
|
@ -25,18 +25,10 @@ For upgrading (replace `grav` by the actual instance ID if more instances are in
|
|||
sudo yunohost app upgrade grav -u https://github.com/YunoHost-Apps/grav_ynh
|
||||
```
|
||||
|
||||
# State of this package
|
||||
## Permissions
|
||||
|
||||
* works fine:
|
||||
* [x] install/remove/backup/remove/upgrade with x86_64
|
||||
|
||||
* to be confirmed:
|
||||
* [x] upgrade from old package to new package
|
||||
* [ ] impact of upgrade on content
|
||||
* [ ] ARM
|
||||
|
||||
* to be added:
|
||||
* [ ] send email to admin
|
||||
To make users administrators, give them the `grav.admin` permission.
|
||||
To allow users to log in, give them the `grav.user` permission.
|
||||
|
||||
## Links
|
||||
|
||||
|
|
|
@ -1,13 +1,23 @@
|
|||
# See here for more information
|
||||
# https://github.com/YunoHost/package_check#syntax-check_process-file
|
||||
|
||||
;; Test complet
|
||||
;; Test name
|
||||
# Comment ignored
|
||||
; pre-install
|
||||
#echo -n "Here your commands to execute in the container"
|
||||
#echo ", before each installation of the app."
|
||||
; Manifest
|
||||
domain="domain.tld" (DOMAIN)
|
||||
path="/path" (PATH)
|
||||
admin="john" (USER)
|
||||
domain="domain.tld" (DOMAIN)
|
||||
path="/path" (PATH)
|
||||
admin="john" (USER)
|
||||
language="fr_FR"
|
||||
is_public=1 (PUBLIC|public=1|private=0)
|
||||
is_public=1 (PUBLIC|public=1|private=0)
|
||||
; Actions
|
||||
action_argument=arg1|arg2
|
||||
is_public=1|0
|
||||
; Config_panel
|
||||
main.categorie.config_example=arg1|arg2
|
||||
main.overwrite_files.overwrite_phpfpm=1|0
|
||||
main.php_fpm_config.footprint=low|medium|high|specific
|
||||
main.php_fpm_config.free_footprint=20
|
||||
main.php_fpm_config.usage=low|medium|high
|
||||
; Checks
|
||||
pkg_linter=1
|
||||
setup_sub_dir=1
|
||||
|
@ -16,33 +26,20 @@
|
|||
setup_private=1
|
||||
setup_public=1
|
||||
upgrade=1
|
||||
upgrade=1 from_commit=ec151614e4c41f2012bb983d08faf6eda233d5be
|
||||
upgrade=1 from_commit=22290f672847342fd187a56d39b68393b1e0fd5a
|
||||
upgrade=1 from_commit=5e98c15e231931d07b5b98701af01a778a8fe448
|
||||
backup_restore=1
|
||||
multi_instance=1
|
||||
incorrect_path=0
|
||||
port_already_use=0
|
||||
port_already_use=0 (66)
|
||||
change_url=1
|
||||
actions=0
|
||||
config_panel=0
|
||||
;;; Levels
|
||||
Level 1=auto
|
||||
Level 2=auto
|
||||
Level 3=auto
|
||||
# doable, but there is no group in YunoHost's LDAP
|
||||
# https://github.com/trilbymedia/grav-plugin-login-ldap
|
||||
Level 4=1
|
||||
# If the level 5 (Package linter) is forced to 1. Please add justifications here.
|
||||
Level 5=auto
|
||||
Level 6=auto
|
||||
Level 7=auto
|
||||
Level 8=0
|
||||
Level 9=0
|
||||
Level 10=0
|
||||
;;; Options
|
||||
Email=jean-baptiste@holcroft.fr
|
||||
Notification=all
|
||||
Email=tituspijean@outlook.com
|
||||
Notification=none
|
||||
;;; Upgrade options
|
||||
; commit=ec151614e4c41f2012bb983d08faf6eda233d5be
|
||||
name=Version 1.3.1
|
||||
manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr_FR&is_public=1&
|
||||
; commit=22290f672847342fd187a56d39b68393b1e0fd5a
|
||||
name=Version 1.5.3
|
||||
manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr_FR&is_public=1&
|
||||
; commit=5e98c15e231931d07b5b98701af01a778a8fe448
|
||||
name=Version 1.5.10
|
||||
manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr_FR&is_public=1&
|
|
@ -1,5 +1,5 @@
|
|||
SOURCE_URL=https://github.com/getgrav/grav/releases/download/1.5.10/grav-update-v1.5.10.zip
|
||||
SOURCE_SUM=1A2AE5D8613BD6B6EA4FF2C1897A435D3E14C59AADCC148B0F5959FC4BBBF349
|
||||
SOURCE_URL=https://github.com/getgrav/grav/releases/download/1.6.26/grav-update-v1.6.26.zip
|
||||
SOURCE_SUM=3086CFA18AA816F5C5F7573EC920FB4BBAD8E863DEBBB9AC200D54490C61CAA7
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FORMAT=zip
|
||||
SOURCE_IN_SUBDIR=true
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
SOURCE_URL=https://github.com/getgrav/grav/releases/download/1.5.10/grav-admin-v1.5.10.zip
|
||||
SOURCE_SUM=FACA5369326EB1577A5EBEA3A81C46E77B3CD8565C404261E819256A8A5E0293
|
||||
SOURCE_URL=https://github.com/getgrav/grav/releases/download/1.6.26/grav-admin-v1.6.26.zip
|
||||
SOURCE_SUM=F43F26D83B94ACD0D3719B6227D3044397B0303D92BA8F956CFAA01A940AF9CE
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FORMAT=zip
|
||||
SOURCE_IN_SUBDIR=true
|
||||
|
|
23
conf/login-ldap.yaml
Normal file
23
conf/login-ldap.yaml
Normal file
|
@ -0,0 +1,23 @@
|
|||
enabled: true
|
||||
host: localhost
|
||||
port: 389
|
||||
version: 3
|
||||
ssl: false
|
||||
start_tls: false
|
||||
opt_referrals: false
|
||||
user_dn: 'uid=[username],ou=users,dc=yunohost,dc=org'
|
||||
search_dn: 'ou=users,dc=yunohost,dc=org'
|
||||
group_dn: 'ou=permission,dc=yunohost,dc=org'
|
||||
group_query: '(&(cn=*)(memberUid=[username]))'
|
||||
group_indentifier: cn
|
||||
map_username: uid
|
||||
map_fullname: givenName lastName
|
||||
map_email: mail
|
||||
map_dn: displayName
|
||||
|
||||
save_grav_user: false
|
||||
store_ldap_data: false
|
||||
default_access_levels:
|
||||
access:
|
||||
groups: "__APP__.admin:\r\n admin:\r\n login: true\r\n super: true\r\n site:\r\n login: true\r\n__APP__.user:\r\n admin:\r\n login: true\r\n site:\r\n login: true"
|
||||
|
|
@ -25,12 +25,12 @@ location __PATH__/ {
|
|||
# à garder en cache une semaine. Si il y a un proxy sur la
|
||||
# route, celui-ci est autorisé à faire une copie et à la
|
||||
# cacher.
|
||||
expires 1w;
|
||||
add_header Cache-Control public;
|
||||
expires 1w;
|
||||
more_set_headers "Cache-Control: public";
|
||||
}
|
||||
location ~ [^/]\.php(/|$) {
|
||||
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
|
||||
fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock;
|
||||
fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock;
|
||||
fastcgi_index index.php;
|
||||
include fastcgi_params;
|
||||
# https://learn.getgrav.org/webservers-hosting/servers/nginx#fix-against-httpoxy-vulnerability
|
||||
|
@ -40,16 +40,16 @@ location __PATH__/ {
|
|||
fastcgi_param SCRIPT_FILENAME $request_filename;
|
||||
}
|
||||
|
||||
## Begin - Security
|
||||
# deny all direct access for these folders
|
||||
location ~* /(.git|cache|bin|logs|backups)/.*$ { return 403; }
|
||||
# deny running scripts inside core system folders
|
||||
location ~* /(system|vendor)/.*\.(txt|xml|md|html|yaml|php|pl|py|cgi|twig|sh|bat)$ { return 403; }
|
||||
# deny running scripts inside user folder
|
||||
location ~* /user/.*\.(txt|md|yaml|php|pl|py|cgi|twig|sh|bat)$ { return 403; }
|
||||
# deny access to specific files in the root folder
|
||||
location ~ /(LICENSE|composer.lock|composer.json|nginx.conf|web.config|htaccess.txt|\.htaccess) { return 403; }
|
||||
## End - Security
|
||||
## Begin - Security
|
||||
# deny all direct access for these folders
|
||||
location ~* /(.git|cache|bin|logs|backups)/.*$ { return 403; }
|
||||
# deny running scripts inside core system folders
|
||||
location ~* /(system|vendor)/.*\.(txt|xml|md|html|yaml|php|pl|py|cgi|twig|sh|bat)$ { return 403; }
|
||||
# deny running scripts inside user folder
|
||||
location ~* /user/.*\.(txt|md|yaml|php|pl|py|cgi|twig|sh|bat)$ { return 403; }
|
||||
# deny access to specific files in the root folder
|
||||
location ~ /(LICENSE|composer.lock|composer.json|nginx.conf|web.config|htaccess.txt|\.htaccess) { return 403; }
|
||||
## End - Security
|
||||
|
||||
#--PRIVATE--# Include SSOWAT user panel.
|
||||
#--PRIVATE--include conf.d/yunohost_panel.conf.inc;
|
||||
|
|
|
@ -30,7 +30,7 @@ group = __USER__
|
|||
; specific port;
|
||||
; '/path/to/unix/socket' - to listen on a unix socket.
|
||||
; Note: This value is mandatory.
|
||||
listen = /var/run/php/php7.0-fpm-__NAMETOCHANGE__.sock
|
||||
listen = /var/run/php/php__PHPVERSION__-fpm-__NAMETOCHANGE__.sock
|
||||
|
||||
; Set listen(2) backlog.
|
||||
; Default Value: 128 (-1 on FreeBSD and OpenBSD)
|
||||
|
@ -38,13 +38,13 @@ listen = /var/run/php/php7.0-fpm-__NAMETOCHANGE__.sock
|
|||
|
||||
; 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.
|
||||
; 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
|
||||
|
@ -117,7 +117,7 @@ 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.
|
||||
|
@ -170,7 +170,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
|
||||
|
@ -220,9 +220,9 @@ pm.max_requests = 500
|
|||
; Note: The value must start with a leading slash (/). The value can be
|
||||
; anything, but it may not be a good idea to use the .php extension or it
|
||||
; may conflict with a real PHP file.
|
||||
; Default Value: not set
|
||||
; Default Value: not set
|
||||
;pm.status_path = /status
|
||||
|
||||
|
||||
; The ping URI to call the monitoring page of FPM. If this value is not set, no
|
||||
; URI will be recognized as a ping page. This could be used to test from outside
|
||||
; that FPM is alive and responding, or to
|
||||
|
@ -283,7 +283,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
|
||||
|
@ -298,50 +298,50 @@ pm.max_requests = 500
|
|||
;
|
||||
; Default: "%R - %u %t \"%m %r\" %s"
|
||||
;access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%"
|
||||
|
||||
|
||||
; The log file for slow requests
|
||||
; Default Value: not set
|
||||
; Note: slowlog is mandatory if request_slowlog_timeout is set
|
||||
slowlog = /var/log/nginx/__NAMETOCHANGE__.slow.log
|
||||
|
||||
|
||||
; The timeout for serving a single request after which a PHP backtrace will be
|
||||
; dumped to the 'slowlog' file. A value of '0s' means 'off'.
|
||||
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
|
||||
; Default Value: 0
|
||||
request_slowlog_timeout = 5s
|
||||
|
||||
|
||||
; The 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
|
||||
;chroot =
|
||||
|
||||
;chroot =
|
||||
|
||||
; Chdir to this directory at the start.
|
||||
; Note: relative path can be used.
|
||||
; Default Value: current directory or / when chroot
|
||||
chdir = __FINALPATH__
|
||||
|
||||
|
||||
; Redirect worker stdout and stderr into main error log. If not set, stdout and
|
||||
; stderr will be redirected to /dev/null according to FastCGI specs.
|
||||
; Note: on highloaded environement, this can cause some delay in the page
|
||||
|
@ -356,7 +356,7 @@ catch_workers_output = yes
|
|||
; Note: set an empty value to allow all extensions.
|
||||
; Default Value: .php
|
||||
;security.limit_extensions = .php .php3 .php4 .php5
|
||||
|
||||
|
||||
; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from
|
||||
; the current environment.
|
||||
; Default Value: clean env
|
||||
|
@ -370,7 +370,7 @@ catch_workers_output = yes
|
|||
; overwrite the values previously defined in the php.ini. The directives are the
|
||||
; same as the PHP SAPI:
|
||||
; php_value/php_flag - you can set classic ini defines which can
|
||||
; be overwritten from PHP call 'ini_set'.
|
||||
; be overwritten from PHP call 'ini_set'.
|
||||
; php_admin_value/php_admin_flag - these directives won't be overwritten by
|
||||
; PHP call 'ini_set'
|
||||
; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no.
|
||||
|
@ -392,4 +392,4 @@ catch_workers_output = yes
|
|||
;php_admin_value[memory_limit] = 32M
|
||||
|
||||
;php_admin_value[upload_max_filesize] =30M
|
||||
;php_admin_value[post_max_size] =30M
|
||||
;php_admin_value[post_max_size] =30M
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"en": "A modern open source flat-file CMS",
|
||||
"fr": "Un CMS moderne basé sur des fichiers plats"
|
||||
},
|
||||
"version": "1.5.10~ynh2",
|
||||
"version": "1.6.26~ynh1",
|
||||
"url": "https://www.getgrav.org/",
|
||||
"license": "MIT-0",
|
||||
"maintainer": [
|
||||
|
@ -27,12 +27,11 @@
|
|||
"email": "lithrel@randomdomainname.net"
|
||||
}],
|
||||
"requirements": {
|
||||
"yunohost": ">= 3.5.0"
|
||||
"yunohost": ">= 3.7.1"
|
||||
},
|
||||
"multi_instance": true,
|
||||
"services": [
|
||||
"nginx",
|
||||
"php7.0-fpm"
|
||||
"nginx"
|
||||
],
|
||||
"arguments": {
|
||||
"install" : [
|
||||
|
|
|
@ -1,5 +1,19 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# COMMON VARIABLES
|
||||
#=================================================
|
||||
|
||||
# Version numbers
|
||||
YNH_PHP_VERSION="7.3"
|
||||
|
||||
# dependencies used by the app
|
||||
extra_php_dependencies="php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-dom php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-ldap"
|
||||
|
||||
#=================================================
|
||||
# EXPERIMENTAL HELPERS
|
||||
#=================================================
|
||||
|
||||
# Execute a command as another user
|
||||
# usage: exec_as USER COMMAND [ARG ...]
|
||||
exec_as() {
|
||||
|
|
|
@ -19,41 +19,47 @@ ynh_abort_if_errors
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..." --time --weight=1
|
||||
ynh_print_info --message="Loading installation settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
final_path=$(ynh_app_setting_get "$app" final_path)
|
||||
domain=$(ynh_app_setting_get "$app" domain)
|
||||
db_name=$(ynh_app_setting_get "$app" db_name)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||
|
||||
#=================================================
|
||||
# DECLARE DATA AND CONF FILES TO BACKUP
|
||||
#=================================================
|
||||
ynh_print_info --message="Declaring files to be backed up..."
|
||||
|
||||
### N.B. : the following 'ynh_backup' calls are only a *declaration* of what needs
|
||||
### to be backuped and not an actual copy of any file. The actual backup that
|
||||
### creates and fill the archive with the files happens in the core after this
|
||||
### script is called. Hence ynh_backups calls takes basically 0 seconds to run.
|
||||
|
||||
#=================================================
|
||||
# STANDARD BACKUP STEPS
|
||||
#=================================================
|
||||
# BACKUP THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up the main app directory..." --time --weight=1
|
||||
|
||||
ynh_backup "$final_path"
|
||||
ynh_backup --src_path="$final_path"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up nginx web server configuration..." --time --weight=1
|
||||
|
||||
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up php-fpm configuration..." --time --weight=1
|
||||
|
||||
ynh_backup "/etc/php/7.0/fpm/pool.d/$app.conf"
|
||||
|
||||
ynh_backup "/etc/php/${phpversion}/fpm/pool.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --time --last
|
||||
|
||||
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|
||||
|
|
|
@ -24,18 +24,27 @@ app=$YNH_APP_INSTANCE_NAME
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..." --time --weight=1
|
||||
|
||||
# Needed for helper "ynh_add_nginx_config"
|
||||
final_path=$(ynh_app_setting_get "$app" final_path)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
|
||||
#=================================================
|
||||
# CHECK THE SYNTAX OF THE PATHS
|
||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up the app before changing its url (may take a while)..." --time --weight=1
|
||||
|
||||
test -n "$old_path" || old_path="/"
|
||||
test -n "$new_path" || new_path="/"
|
||||
new_path=$(ynh_normalize_url_path "$new_path")
|
||||
old_path=$(ynh_normalize_url_path "$old_path")
|
||||
# Backup the current version of the app
|
||||
ynh_backup_before_upgrade
|
||||
ynh_clean_setup () {
|
||||
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
|
||||
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||
|
||||
# restore it if the upgrade fails
|
||||
ynh_restore_upgradebackup
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# CHECK WHICH PARTS SHOULD BE CHANGED
|
||||
|
@ -58,14 +67,15 @@ fi
|
|||
#=================================================
|
||||
# MODIFY URL IN NGINX CONF
|
||||
#=================================================
|
||||
ynh_script_progression --message="Updating nginx web server configuration..." --time --weight=1
|
||||
|
||||
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
||||
|
||||
# Change the path in the nginx config file
|
||||
if [ "$change_path" -eq 1 ]
|
||||
if [ $change_path -eq 1 ]
|
||||
then
|
||||
# Make a backup of the original nginx config file if modified
|
||||
ynh_backup_if_checksum_is_different "$nginx_conf_path"
|
||||
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
|
||||
# Set global variables for nginx helper
|
||||
domain="$old_domain"
|
||||
path_url="$new_path"
|
||||
|
@ -77,10 +87,10 @@ fi
|
|||
if [ $change_domain -eq 1 ]
|
||||
then
|
||||
# Delete file checksum for the old conf file location
|
||||
ynh_delete_file_checksum "$nginx_conf_path"
|
||||
mv "$nginx_conf_path" "/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||
ynh_delete_file_checksum --file="$nginx_conf_path"
|
||||
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
||||
# Store file checksum for the new config file location
|
||||
ynh_store_file_checksum "/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
@ -94,5 +104,12 @@ fi
|
|||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading nginx web server..." --time --weight=1
|
||||
|
||||
systemctl reload nginx
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Change of URL completed for $app" --time --last
|
||||
|
|
|
@ -22,7 +22,7 @@ ynh_abort_if_errors
|
|||
|
||||
domain=$YNH_APP_ARG_DOMAIN
|
||||
path_url=$YNH_APP_ARG_PATH
|
||||
admin_grav=$YNH_APP_ARG_ADMIN
|
||||
admin=$YNH_APP_ARG_ADMIN
|
||||
language=$YNH_APP_ARG_LANGUAGE
|
||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||
|
||||
|
@ -31,7 +31,7 @@ app=$YNH_APP_INSTANCE_NAME
|
|||
#=================================================
|
||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Validating installation parameters..." --time --weight=1
|
||||
ynh_script_progression --message="Validating installation parameters..." --weight=1
|
||||
|
||||
### If the app uses nginx as web server (written in HTML/PHP in most cases), the final path should be "/var/www/$app".
|
||||
### If the app provides an internal web server (or uses another application server such as uwsgi), the final path should be "/opt/yunohost/$app"
|
||||
|
@ -42,88 +42,108 @@ test ! -e "$final_path" || ynh_die "This path already contains a folder"
|
|||
path_url=$(ynh_normalize_url_path "$path_url")
|
||||
|
||||
# Check web path availability
|
||||
ynh_webpath_available "$domain" "$path_url"
|
||||
ynh_webpath_available --domain=$domain --path_url=$path_url
|
||||
# Register (book) web path
|
||||
ynh_webpath_register "$app" "$domain" "$path_url"
|
||||
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
|
||||
|
||||
#=================================================
|
||||
# STORE SETTINGS FROM MANIFEST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Storing installation settings..." --time --weight=1
|
||||
ynh_script_progression --message="Storing installation settings..." --weight=1
|
||||
|
||||
ynh_app_setting_set "$app" domain "$domain"
|
||||
ynh_app_setting_set "$app" path "$path_url"
|
||||
ynh_app_setting_set "$app" admin "$admin_grav"
|
||||
ynh_app_setting_set "$app" is_public "$is_public"
|
||||
ynh_app_setting_set "$app" language "$language"
|
||||
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
||||
ynh_app_setting_set --app=$app --key=path --value=$path_url
|
||||
ynh_app_setting_set --app=$app --key=admin --value=$admin
|
||||
ynh_app_setting_set --app=$app --key=language --value=$language
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing dependencies..." --time --weight=1
|
||||
|
||||
ynh_install_app_dependencies php7.0-zip
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Setting up source files..." --time --weight=1
|
||||
ynh_script_progression --message="Setting up source files..." --weight=2
|
||||
|
||||
ynh_app_setting_set "$app" final_path "$final_path"
|
||||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source "$final_path"
|
||||
ynh_setup_source --dest_dir=$final_path
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring nginx web server..." --time --weight=1
|
||||
ynh_script_progression --message="Configuring nginx web server..." --weight=1
|
||||
|
||||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config
|
||||
ynh_add_nginx_config YNH_PHP_VERSION
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring system user..." --time --weight=1
|
||||
ynh_script_progression --message="Configuring system user..." --weight=1
|
||||
|
||||
# Create a system user
|
||||
ynh_system_user_create "$app"
|
||||
ynh_system_user_create --username=$app --home_dir=$final_path
|
||||
|
||||
#=================================================
|
||||
# PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring php-fpm..." --time --weight=1
|
||||
ynh_script_progression --message="Configuring php-fpm..." --weight=3
|
||||
|
||||
# Create a dedicated php-fpm config
|
||||
ynh_add_fpm_config
|
||||
ynh_add_fpm_config --usage=medium --footprint=medium --phpversion=$YNH_PHP_VERSION --package="$extra_php_dependencies"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# SECURE FILES AND DIRECTORIES
|
||||
#=================================================
|
||||
chown -R "$app": "$final_path"
|
||||
|
||||
# Set permissions on app files
|
||||
chown -R $app:www-data $final_path
|
||||
find $final_path -type f -exec chmod 664 {} \;
|
||||
find $final_path/bin -type f -exec chmod 775 {} \;
|
||||
find $final_path -type d -exec chmod 775 {} \;
|
||||
find $final_path -type d -exec chmod +s {} \;
|
||||
|
||||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
# INSTALL LDAP PLUGIN
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring SSOwat..." --time --weight=1
|
||||
ynh_script_progression --message="Installing and configuring LDAP plugin..." --weight=1
|
||||
|
||||
pushd "$final_path"
|
||||
exec_as $app php${YNH_PHP_VERSION} bin/gpm install login-ldap -y
|
||||
exec_as $app mkdir -p user/config/plugins/login-ldap
|
||||
exec_as $app touch user/accounts/admin.yaml
|
||||
popd
|
||||
|
||||
ynh_secure_remove "$final_path/user/plugins/login-ldap/login-ldap.yaml"
|
||||
exec_as $app cp ../conf/login-ldap.yaml "$final_path/user/plugins/login-ldap/login-ldap.yaml"
|
||||
ynh_replace_string "__ADMIN__" "$admin" "$final_path/user/plugins/login-ldap/login-ldap.yaml"
|
||||
ynh_replace_string "__APP__" "$app" "$final_path/user/plugins/login-ldap/login-ldap.yaml"
|
||||
exec_as $app cp "$final_path/user/plugins/login-ldap/login-ldap.yaml" "$final_path/user/config/plugins/login-ldap.yaml"
|
||||
|
||||
#=================================================
|
||||
# SETUP PERMISSIONS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring permissions..." --weight=1
|
||||
|
||||
# Giving admin permission to the specified used
|
||||
ynh_permission_create --permission "admin" --allowed $admin
|
||||
|
||||
# Creating user permission
|
||||
ynh_permission_create --permission "user"
|
||||
|
||||
# Make app public if necessary
|
||||
if [ "$is_public" -eq "1" ]
|
||||
if [ $is_public -eq 1 ]
|
||||
then
|
||||
# unprotected_uris allows SSO credentials to be passed anyway.
|
||||
ynh_app_setting_set "$app" unprotected_uris "/"
|
||||
else
|
||||
ynh_replace_string "#--PRIVATE--" "" "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
# Everyone can access the app.
|
||||
# The "main" permission is automatically created before the install script.
|
||||
ynh_permission_update --permission "main" --add "visitors"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading nginx web server..." --time --weight=1
|
||||
ynh_script_progression --message="Reloading nginx web server..." --weight=1
|
||||
|
||||
systemctl reload nginx
|
||||
|
||||
|
@ -131,4 +151,4 @@ systemctl reload nginx
|
|||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Installation of $app completed" --time --last
|
||||
ynh_script_progression --message="Installation of $app completed" --last
|
||||
|
|
|
@ -12,21 +12,21 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..." --time --weight=1
|
||||
ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||
|
||||
# Get multi-instances specific variables
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
# Retrieve app settings
|
||||
domain=$(ynh_app_setting_get "$app" domain)
|
||||
final_path=$(ynh_app_setting_get "$app" final_path)
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
|
||||
#=================================================
|
||||
# STANDARD REMOVE
|
||||
#=================================================
|
||||
# REMOVE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing dependencies..." --time --weight=1
|
||||
ynh_script_progression --message="Removing dependencies..." --weight=2
|
||||
|
||||
# Remove metapackage and its dependencies
|
||||
ynh_remove_app_dependencies
|
||||
|
@ -34,15 +34,15 @@ ynh_remove_app_dependencies
|
|||
#=================================================
|
||||
# REMOVE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing app main directory..." --time --weight=1
|
||||
ynh_script_progression --message="Removing app main directory..." --weight=1
|
||||
|
||||
# Remove the app directory securely
|
||||
ynh_secure_remove "$final_path"
|
||||
ynh_secure_remove --file="$final_path"
|
||||
|
||||
#=================================================
|
||||
# REMOVE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing nginx web server configuration..." --time --weight=1
|
||||
ynh_script_progression --message="Removing nginx web server configuration..." --weight=1
|
||||
|
||||
# Remove the dedicated nginx config
|
||||
ynh_remove_nginx_config
|
||||
|
@ -50,7 +50,7 @@ ynh_remove_nginx_config
|
|||
#=================================================
|
||||
# REMOVE PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing php-fpm configuration..." --time --weight=1
|
||||
ynh_script_progression --message="Removing php-fpm configuration..." --weight=2
|
||||
|
||||
# Remove the dedicated php-fpm config
|
||||
ynh_remove_fpm_config
|
||||
|
@ -60,14 +60,13 @@ ynh_remove_fpm_config
|
|||
#=================================================
|
||||
# REMOVE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing the dedicated system user..." --time --weight=1
|
||||
ynh_script_progression --message="Removing the dedicated system user..." --weight=1
|
||||
|
||||
# Delete a system user
|
||||
ynh_system_user_delete "$app"
|
||||
|
||||
ynh_system_user_delete --username=$app
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Removal of $app completed" --time --last
|
||||
ynh_script_progression --message="Removal of $app completed" --last
|
||||
|
|
|
@ -28,20 +28,22 @@ ynh_script_progression --message="Loading settings..." --time --weight=1
|
|||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$(ynh_app_setting_get "$app" domain)
|
||||
path_url=$(ynh_app_setting_get "$app" path)
|
||||
final_path=$(ynh_app_setting_get "$app" final_path)
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
|
||||
fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint)
|
||||
fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage)
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE RESTORED
|
||||
#=================================================
|
||||
ynh_script_progression --message="Validating restoration parameters..." --time --weight=1
|
||||
|
||||
ynh_webpath_available "$domain" "$path_url" \
|
||||
|| ynh_die "Path not available: ${domain}${path_url}"
|
||||
test ! -d "$final_path" \
|
||||
|| ynh_die "There is already a directory: $final_path "
|
||||
|
||||
ynh_webpath_available --domain=$domain --path_url=$path_url \
|
||||
|| ynh_die --message="Path not available: ${domain}${path_url}"
|
||||
test ! -d $final_path \
|
||||
|| ynh_die --message="There is already a directory: $final_path "
|
||||
|
||||
#=================================================
|
||||
# STANDARD RESTORATION STEPS
|
||||
|
@ -49,14 +51,14 @@ test ! -d "$final_path" \
|
|||
# RESTORE THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the app main directory..." --time --weight=1
|
||||
|
||||
ynh_restore_file "$final_path"
|
||||
ynh_restore_file --origin_path="$final_path"
|
||||
|
||||
#=================================================
|
||||
# RECREATE THE DEDICATED USER
|
||||
|
@ -64,29 +66,28 @@ ynh_restore_file "$final_path"
|
|||
ynh_script_progression --message="Recreating the dedicated system user..." --time --weight=1
|
||||
|
||||
# Create the dedicated user (if not existing)
|
||||
ynh_system_user_create "$app"
|
||||
ynh_system_user_create --username=$app --home_dir=$final_path
|
||||
|
||||
#=================================================
|
||||
# RESTORE USER RIGHTS
|
||||
#=================================================
|
||||
|
||||
chown -R "$app": "$final_path"
|
||||
# Restore permissions on app files
|
||||
chown -R $app:www-data $final_path
|
||||
find $final_path -type f -exec chmod 664 {} \;
|
||||
find $final_path/bin -type f -exec chmod 775 {} \;
|
||||
find $final_path -type d -exec chmod 775 {} \;
|
||||
find $final_path -type d -exec chmod +s {} \;
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_restore_file "/etc/php/7.0/fpm/pool.d/$app.conf"
|
||||
# Restore the file first, so it can have a backup if different
|
||||
ynh_restore_file --origin_path="/etc/php/$YNH_PHP_VERSION/fpm/pool.d/$app.conf"
|
||||
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC RESTORATION
|
||||
#=================================================
|
||||
# REINSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reinstalling dependencies..." --time --weight=1
|
||||
|
||||
ynh_install_app_dependencies php7.0-zip
|
||||
# Recreate a dedicated php-fpm config
|
||||
ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint --phpversion=$YNH_PHP_VERSION --package="$extra_php_dependencies"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
|
@ -95,10 +96,8 @@ ynh_install_app_dependencies php7.0-zip
|
|||
#=================================================
|
||||
ynh_script_progression --message="Reloading nginx web server and php-fpm..." --time --weight=1
|
||||
|
||||
# Reload services
|
||||
systemctl reload php7.0-fpm
|
||||
systemctl reload nginx
|
||||
|
||||
ynh_systemd_action --service_name=php${YNH_PHP_VERSION}-fpm --action=restart
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
|
|
173
scripts/upgrade
173
scripts/upgrade
|
@ -16,37 +16,81 @@ ynh_script_progression --message="Loading installation settings..." --time --wei
|
|||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$(ynh_app_setting_get "$app" domain)
|
||||
path_url=$(ynh_app_setting_get "$app" path)
|
||||
admin=$(ynh_app_setting_get "$app" admin)
|
||||
is_public=$(ynh_app_setting_get "$app" is_public)
|
||||
final_path=$(ynh_app_setting_get "$app" final_path)
|
||||
language=$(ynh_app_setting_get "$app" language)
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||
admin=$(ynh_app_setting_get --app=$app --key=admin)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
language=$(ynh_app_setting_get --app=$app --key=language)
|
||||
|
||||
fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint)
|
||||
fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage)
|
||||
|
||||
#=================================================
|
||||
# CHECK VERSION
|
||||
#=================================================
|
||||
|
||||
### This helper will compare the version of the currently installed app and the version of the upstream package.
|
||||
### $upgrade_type can have 2 different values
|
||||
### - UPGRADE_APP if the upstream app version has changed
|
||||
### - UPGRADE_PACKAGE if only the YunoHost package has changed
|
||||
### ynh_check_app_version_changed will stop the upgrade if the app is up to date.
|
||||
### UPGRADE_APP should be used to upgrade the core app only if there's an upgrade to do.
|
||||
upgrade_type=$(ynh_check_app_version_changed)
|
||||
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Ensuring downward compatibility..." --time --weight=1
|
||||
|
||||
# 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
|
||||
|
||||
# If db_name doesn't exist, create it
|
||||
if [ -z "$db_name" ]; then
|
||||
db_name=$(ynh_sanitize_dbid "$app")
|
||||
ynh_app_setting_set "$app" db_name "$db_name"
|
||||
db_name=$(ynh_sanitize_dbid --db_name=$app)
|
||||
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
||||
fi
|
||||
|
||||
# If final_path doesn't exist, create it
|
||||
if [ -z "$final_path" ]; then
|
||||
final_path="/var/www/$app"
|
||||
ynh_app_setting_set "$app" final_path "$final_path"
|
||||
final_path=/var/www/$app
|
||||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||
fi
|
||||
|
||||
# Cleaning legacy permissions
|
||||
is_public=$(ynh_app_setting_get --app=$app --key=is_public)
|
||||
|
||||
if [ -n "$is_public" ]; then
|
||||
# Removing skipped/unprotected_uris under certain conditions, remove the visitors group added during the migration process of 3.7
|
||||
# Remove skipped_uris. If the app was public, add visitors again to the main permission
|
||||
if ynh_permission_has_user --permission=main --user=visitors
|
||||
then
|
||||
# Remove unprotected_uris
|
||||
ynh_app_setting_delete --app=$app --key=unprotected_uris
|
||||
# Remove protected_uris
|
||||
ynh_app_setting_delete --app=$app --key=protected_uris
|
||||
# Remove skipped_uris
|
||||
ynh_app_setting_delete --app=$app --key=skipped_uris
|
||||
# Give visitors main permission
|
||||
ynh_permission_update --permission "main" --add "visitors"
|
||||
else
|
||||
# Remove unprotected_uris
|
||||
ynh_app_setting_delete --app=$app --key=unprotected_uris
|
||||
# Remove protected_uris
|
||||
ynh_app_setting_delete --app=$app --key=protected_uris
|
||||
# Remove skipped_uris
|
||||
ynh_app_setting_delete --app=$app --key=skipped_uris
|
||||
fi
|
||||
ynh_app_setting_delete --app=$app --key=is_public
|
||||
fi
|
||||
|
||||
# If fpm_footprint doesn't exist, create it
|
||||
if [ -z "$fpm_footprint" ]; then
|
||||
fpm_footprint=medium
|
||||
ynh_app_setting_set --app=$app --key=fpm_footprint --value=$fpm_footprint
|
||||
fi
|
||||
|
||||
# If fpm_usage doesn't exist, create it
|
||||
if [ -z "$fpm_usage" ]; then
|
||||
fpm_usage=medium
|
||||
ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
@ -68,17 +112,21 @@ ynh_abort_if_errors
|
|||
#=================================================
|
||||
|
||||
# Normalize the URL path syntax
|
||||
path_url=$(ynh_normalize_url_path "$path_url")
|
||||
path_url=$(ynh_normalize_url_path --path_url=$path_url)
|
||||
|
||||
#=================================================
|
||||
# STANDARD UPGRADE STEPS
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading source files..." --time --weight=1
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app-upgrade.src
|
||||
ynh_setup_source "$final_path" "app-upgrade"
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
ynh_script_progression --message="Upgrading source files..." --time --weight=1
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir="$final_path" --source_id="app-upgrade"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
|
@ -86,14 +134,7 @@ ynh_setup_source "$final_path" "app-upgrade"
|
|||
ynh_script_progression --message="Upgrading nginx web server configuration..." --time --weight=1
|
||||
|
||||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config
|
||||
|
||||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading dependencies..." --time --weight=1
|
||||
|
||||
ynh_install_app_dependencies php7.0-zip
|
||||
ynh_add_nginx_config YNH_PHP_VERSION
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
|
@ -101,7 +142,7 @@ ynh_install_app_dependencies php7.0-zip
|
|||
ynh_script_progression --message="Making sure dedicated system user exists..." --time --weight=1
|
||||
|
||||
# Create a dedicated user (if not existing)
|
||||
ynh_system_user_create "$app"
|
||||
ynh_system_user_create --username=$app --home_dir=$final_path
|
||||
|
||||
#=================================================
|
||||
# PHP-FPM CONFIGURATION
|
||||
|
@ -109,34 +150,78 @@ ynh_system_user_create "$app"
|
|||
ynh_script_progression --message="Upgrading php-fpm configuration..." --time --weight=1
|
||||
|
||||
# Create a dedicated php-fpm config
|
||||
ynh_add_fpm_config
|
||||
ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint --phpversion=$YNH_PHP_VERSION --package="$extra_php_dependencies"
|
||||
|
||||
# Delete existing ini configuration file (backward compatibility)
|
||||
if [ -f /etc/php/$YNH_PHP_VERSION/fpm/conf.d/20-$app.ini ]; then
|
||||
ynh_secure_remove --file=/etc/php/$YNH_PHP_VERSION/fpm/conf.d/20-$app.ini
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# SECURE FILES AND DIRECTORIES
|
||||
#=================================================
|
||||
|
||||
chown -R "$app": "$final_path"
|
||||
# Set permissions on app files
|
||||
chown -R $app:www-data $final_path
|
||||
find $final_path -type f -exec chmod 664 {} \;
|
||||
find $final_path/bin -type f -exec chmod 775 {} \;
|
||||
find $final_path -type d -exec chmod 775 {} \;
|
||||
find $final_path -type d -exec chmod +s {} \;
|
||||
|
||||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
# SPECIFIC UPGRADE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading SSOwat configuration..." --time --weight=1
|
||||
# UPGRADE PLUGINS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Updating all plugins..." --time --weight=1
|
||||
|
||||
# Make app public if necessary
|
||||
if [ "$is_public" -eq "1" ]
|
||||
pushd "$final_path"
|
||||
exec_as $app php${YNH_PHP_VERSION} bin/gpm update -y
|
||||
popd
|
||||
|
||||
#=================================================
|
||||
# INSTALL LDAP PLUGIN
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing and configuring LDAP plugin..." --time --weight=1
|
||||
|
||||
pushd "$final_path"
|
||||
exec_as $app php${YNH_PHP_VERSION} bin/gpm install login-ldap -y
|
||||
exec_as $app mkdir -p user/config/plugins/login-ldap
|
||||
exec_as $app touch user/accounts/admin.yaml
|
||||
popd
|
||||
|
||||
ynh_secure_remove "$final_path/user/plugins/login-ldap/login-ldap.yaml"
|
||||
exec_as $app cp ../conf/login-ldap.yaml "$final_path/user/plugins/login-ldap/login-ldap.yaml"
|
||||
ynh_replace_string "__ADMIN__" "$admin" "$final_path/user/plugins/login-ldap/login-ldap.yaml"
|
||||
ynh_replace_string "__APP__" "$app" "$final_path/user/plugins/login-ldap/login-ldap.yaml"
|
||||
exec_as $app cp "$final_path/user/plugins/login-ldap/login-ldap.yaml" "$final_path/user/config/plugins/login-ldap.yaml"
|
||||
|
||||
#=================================================
|
||||
# SETUP PERMISSIONS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring permissions..." --time --weight=1
|
||||
|
||||
# Giving admin permission to the specified used
|
||||
if ! ynh_permission_exists --permission "admin"
|
||||
then
|
||||
# unprotected_uris allows SSO credentials to be passed anyway.
|
||||
ynh_app_setting_set "$app" unprotected_uris "/"
|
||||
ynh_permission_create --permission "admin" --allowed "$admin"
|
||||
else
|
||||
ynh_replace_string "#--PRIVATE--" "" "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
ynh_permission_update --permission "admin" --add "$admin"
|
||||
fi
|
||||
|
||||
# Creating user permission
|
||||
if ! ynh_permission_exists --permission "user"
|
||||
then
|
||||
ynh_permission_create --permission "user"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
# RELOAD NGINX AND PHP-FPM
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading nginx web server..." --time --weight=1
|
||||
ynh_script_progression --message="Reloading nginx web server and php-fpm..." --time --weight=1
|
||||
|
||||
systemctl reload nginx
|
||||
ynh_systemd_action --service_name=php${YNH_PHP_VERSION}-fpm --action=restart
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
|
|
Loading…
Reference in a new issue