diff --git a/README.md b/README.md index bfb292a..39f7165 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,61 @@ -# Jirafeau package for YunoHost - -Easy drag&Drop file sharing. +# Jirafeau for YunoHost +[![Integration level](https://dash.yunohost.org/integration/jirafeau.svg)](https://dash.yunohost.org/appci/app/jirafeau) [![Install Jirafeau with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=jirafeau) -* [Jirafeau website](https://gitlab.com/mojo42/Jirafeau) -* [YunoHost website](https://yunohost.org/) +> *This package allow you to install Jirafeau 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 + +Jirafeau is a web site permitting to upload a file in a simple way and give an unique link to it. + +**Shipped version:** 3.4.1 + +## Screenshots + +![](http://i.imgur.com/TPjh48P.png) + +## Demo + +* [YunoHost demo](https://demo.yunohost.org/jirafeau/) + +## Configuration + +## Documentation + + * Official documentation: + * YunoHost documentation: If specific documentation is needed, feel free to contribute. + +## YunoHost specific features + +#### Supported architectures + +* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/jirafeau%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/jirafeau/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/jirafeau%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/jirafeau/) +* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/jirafeau%20%28Apps%29.svg)](https://ci-stretch.nohost.me/ci/apps/jirafeau/) + +## Limitations + +## Additional information + +## Links + + * Report a bug: https://github.com/YunoHost-Apps/jirafeau_ynh/issues + * Jirafeau website: https://gitlab.com/mojo42/Jirafeau + * Upstream app repository: https://gitlab.com/mojo42/Jirafeau + * YunoHost website: https://yunohost.org/ + +--- + +Developers info +---------------- + +Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/jirafeau_ynh/tree/testing). + +To try the testing branch, please proceed like that. +``` +sudo yunohost app install https://github.com/YunoHost-Apps/jirafeau_ynh/tree/testing --debug +or +sudo yunohost app upgrade jirafeau -u https://github.com/YunoHost-Apps/jirafeau_ynh/tree/testing --debug +``` diff --git a/check_process b/check_process index f3b0810..c67ae70 100644 --- a/check_process +++ b/check_process @@ -1,5 +1,4 @@ ;; Test complet - auto_remove=1 ; Manifest domain="domain.tld" (DOMAIN) path="/path" (PATH) @@ -21,16 +20,7 @@ port_already_use=0 change_url=1 ;;; Levels - Level 1=auto - Level 2=auto - Level 3=auto - Level 4=na Level 5=auto - Level 6=auto - Level 7=auto - Level 8=0 - Level 9=0 - Level 10=0 ;;; Options Email= Notification=none diff --git a/conf/config.local.php b/conf/config.local.php index da1a040..44d4f11 100644 --- a/conf/config.local.php +++ b/conf/config.local.php @@ -27,11 +27,11 @@ /* URL of installation, with traling slash (eg. »https://exmaple.com/jirafeau/«) */ -$cfg['web_root'] = 'https://' . 'YNH_DOMAIN' . 'YNH_WWW_PATH' . '/'; +$cfg['web_root'] = 'https://' . '__YNH_DOMAIN__' . '__YNH_WWW_PATH__' . '/'; /* Path to data directory, with trailing slash (eg. »/var/www/data/var_314159265358979323846264« */ -$cfg['var_root'] = 'YNH_VAR_ROOT' . '/'; +$cfg['var_root'] = '__YNH_VAR_ROOT__' . '/'; /* Language - choice between 'auto' or any language located in the /lib/locales/ folder. * The mode »auto« will cause the script to detect the user's browser information @@ -74,7 +74,7 @@ $cfg['link_name_length'] = 8; * $cfg['upload_password'] = array('psw1'); // One password * $cfg['upload_password'] = array('psw1', 'psw2'); // Two passwords */ -$cfg['upload_password'] = array(YNH_UPLOAD_PASSWORD); +$cfg['upload_password'] = array(__YNH_UPLOAD_PASSWORD__); /* List of IP allowed to upload a file. * If the list is empty, then there is no upload restriction based on IP. @@ -96,7 +96,7 @@ $cfg['admin_password'] = ''; * that the provided user is logged in. * If »admin_password« parameter is set, then the »admin_password« is ignored. */ -$cfg['admin_http_auth_user'] = 'YNH_ADMIN_USER'; +$cfg['admin_http_auth_user'] = '__YNH_ADMIN_USER__'; /* Allow user to select different options for file expiration time. * Possible values in array: diff --git a/conf/nginx.conf b/conf/nginx.conf index 47f2a36..4b8549c 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,18 +1,24 @@ #sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; location __PATH__/ { + + # Path to source alias __FINALPATH__/ ; + + # Force usage of https if ($scheme = http) { rewrite ^ https://$server_name$request_uri? permanent; } + client_max_body_size 10G; client_body_timeout 30m; proxy_read_timeout 30m; + index index.php; try_files $uri $uri/ index.php; location ~ ^__PATH__/lib/functions.js.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; @@ -21,12 +27,14 @@ location __PATH__/ { fastcgi_read_timeout 30m; fastcgi_send_timeout 30m; } + location ~ ^__PATH__/lib/.*\.php { deny all; } + 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; diff --git a/conf/php-fpm.conf b/conf/php-fpm.conf index 0fb9f64..b7b1cb5 100644 --- a/conf/php-fpm.conf +++ b/conf/php-fpm.conf @@ -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. -; Default Value: 128 (-1 on FreeBSD and OpenBSD) -;listen.backlog = 128 +; 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 = 0600 - -; List of ipv4 addresses of FastCGI clients which are allowed to connect. +;listen.mode = 0660 +; When POSIX Access Control Lists are supported you can set them using +; these options, value is a comma separated list of user/group names. +; When set, listen.owner and listen.group are ignored +;listen.acl_users = +;listen.acl_groups = + +; List of addresses (IPv4/IPv6) of FastCGI clients which are allowed to connect. ; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original ; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address ; must be separated by a comma. If this value is left blank, connections will be @@ -59,7 +67,13 @@ listen.mode = 0600 ; - 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: @@ -122,7 +136,7 @@ pm.max_spare_servers = 5 ; 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,13 +229,30 @@ 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 ; may conflict with a real PHP file. ; 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 +; URI will be recognized as a ping page. This could be used to test from outside +; that FPM is alive and responding, or to +; - create a graph of FPM availability (rrd or such); +; - remove a server from a group if it is not responding (load balancing); +; - trigger alerts for the operating team (24/7). +; 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 +;ping.path = /ping + +; 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. +; Default Value: pong +;ping.response = pong ; The access log file ; Default: not set @@ -258,7 +289,7 @@ pm.status_path = /fpm-status ; - %{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 @@ -266,7 +297,7 @@ pm.status_path = /fpm-status ; - .... ; %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 @@ -274,40 +305,44 @@ pm.status_path = /fpm-status ; %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 %{}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 %{}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 = 4096 - +;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 +;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. @@ -319,27 +354,36 @@ rlimit_core = 0 ; (error_log, sessions.save_path, ...). ; Default Value: not set ;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 ; 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 @@ -353,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. @@ -374,5 +418,15 @@ 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 php_admin_value[upload_max_filesize] = 10G php_admin_value[post_max_size] = 10G diff --git a/manifest.json b/manifest.json index 947f5bd..2a347ff 100644 --- a/manifest.json +++ b/manifest.json @@ -2,24 +2,24 @@ "name": "Jirafeau", "id": "jirafeau", "packaging_format": 1, - "requirements": { - "yunohost": ">= 2.7.12" - }, "description": { "en": "Upload a file in a simple way and give a unique link to it", "fr": "Hébergez simplement un fichier et partagez-le avec un lien unique" }, + "version": "3.4.1~ynh3", "url": "https://gitlab.com/mojo42/Jirafeau", - "version": "3.4.1~ynh2", "license": "AGPL-3.0-only", "maintainer": { "name": "julien", "email": "julien.malik@paraiso.me" }, + "requirements": { + "yunohost": ">= 3.5.0" + }, "multi_instance": false, "services": [ "nginx", - "php5-fpm" + "php7.0-fpm" ], "arguments": { "install" : [ @@ -54,7 +54,7 @@ { "name": "upload_password", "type": "password", - "optional": "true", + "optional": true, "ask": { "en": "Set the password granting upload permissions (leave empty to allow anybody to upload)", "fr": "Définissez le mot de passe permettant l'accès à l'envoi de fichiers (laissez vide pour autoriser tout le monde)" diff --git a/pull_request_template.md b/pull_request_template.md index 5f5db75..c651d32 100644 --- a/pull_request_template.md +++ b/pull_request_template.md @@ -19,7 +19,6 @@ - [ ] **Approval (LGTM)** : - [ ] **Approval (LGTM)** : - **CI succeeded** : -[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/jirafeau_ynh%20-BRANCH-%20(Official)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/jirafeau_ynh%20-BRANCH-%20(Official)/) *Please replace '-BRANCH-' in this link for a PR from a local branch.* -or -[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/jirafeau_ynh%20PR-NUM-%20(Official_fork)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/jirafeau_ynh%20PR-NUM-%20(Official_fork)/) *Replace '-NUM-' by the PR number in this link for a PR from a forked repository.* +[![Build Status](https://ci-apps-hq.yunohost.org/jenkins/job/jirafeau_ynh%20PR-NUM-/badge/icon)](https://ci-apps-hq.yunohost.org/jenkins/job/jirafeau_ynh%20PR-NUM-/) +*Please replace '-NUM-' in this link by the PR number.* When the PR is marked as ready to merge, you have to wait for 3 days before really merging it. diff --git a/scripts/_common.sh b/scripts/_common.sh index d92d1ad..a9bf588 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,16 +1 @@ #!/bin/bash - -#================================================= -# EXPERIMENTAL HELPERS -#================================================= - -# Delete a file checksum from the app settings -# -# $app should be defined when calling this helper -# -# usage: ynh_remove_file_checksum file -# | arg: file - The file for which the checksum will be deleted -ynh_delete_file_checksum () { - local checksum_setting_name=checksum_${1//[\/ ]/_} # Replace all '/' and ' ' by '_' - ynh_app_setting_delete $app $checksum_setting_name -} diff --git a/scripts/backup b/scripts/backup index 3189d25..5873ab2 100644 --- a/scripts/backup +++ b/scripts/backup @@ -4,12 +4,7 @@ # IMPORT GENERIC HELPERS #================================================= -if [ ! -e _common.sh ]; then - # Rapatrie le fichier de fonctions si il n'est pas dans le dossier courant - sudo cp ../settings/scripts/_common.sh ./_common.sh - sudo chmod a+rx _common.sh -fi -source _common.sh +source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers #================================================= @@ -22,36 +17,45 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= +ynh_script_progression --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) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) +domain=$(ynh_app_setting_get --app=$app --key=domain) #================================================= # STANDARD BACKUP STEPS #================================================= # BACKUP OF THE MAIN DIR OF THE APP #================================================= +ynh_script_progression --message="Backing up the main app directory..." -ynh_backup "$final_path" +ynh_backup --src_path="$final_path" #================================================= # BACKUP OF THE DATA DIR #================================================= +ynh_script_progression --message="Backing up data directory..." -# The 1 parameter indicates the directory is "big", -# so that it won't be backed up before upgrade -ynh_backup "/home/yunohost.app/$app" 1 +ynh_backup --src_path="/home/yunohost.app/$app" --is_big #================================================= # BACKUP OF THE NGINX CONFIGURATION #================================================= +ynh_script_progression --message="Backing up nginx web server configuration..." -ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # BACKUP OF THE PHP-FPM CONFIGURATION #================================================= +ynh_script_progression --message="Backing up php-fpm configuration..." -ynh_backup "/etc/php5/fpm/pool.d/$app.conf" +ynh_backup --src_path="/etc/php/7.0/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)." --last diff --git a/scripts/change_url b/scripts/change_url index 7ae12c8..4e4774f 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -24,17 +24,9 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # LOAD SETTINGS #================================================= +ynh_script_progression --message="Loading installation settings..." -final_path=$(ynh_app_setting_get "$app" final_path) - -#================================================= -# CHECK PATHS SYNTAX -#================================================= - -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) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= # CHECK WHICH PARTS SHOULD BE CHANGED @@ -57,36 +49,30 @@ fi #================================================= # MODIFY URL IN NGINX CONF #================================================= +ynh_script_progression --message="Updating nginx web server configuration..." --weight=2 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 ] then - # Make a backup of the original nginx config file if modified - ynh_backup_if_checksum_is_different "$nginx_conf_path" + # Make a backup of the original nginx config file if modified + ynh_backup_if_checksum_is_different --file="$nginx_conf_path" # Set global variables for nginx helper domain="$old_domain" path_url="$new_path" - # Store path_url setting - ynh_app_setting_set $app path_url "$path_url" # Create a dedicated nginx config ynh_add_nginx_config - if [ "$path_url" != "/" ] - then - ynh_replace_string "^#sub_path_only" "" "$nginx_conf_path" - fi - ynh_store_file_checksum "$nginx_conf_path" fi # Change the domain for nginx if [ $change_domain -eq 1 ] then - # Delete file checksum for the old conf file location - ynh_delete_file_checksum "$nginx_conf_path" + # Delete file checksum for the old conf file location + 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" + # Store file checksum for the new config file location + ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" fi #================================================= @@ -94,12 +80,19 @@ fi #================================================= # Change domain name in parameters.yml -ynh_replace_string "\$cfg['web_root'] = .*" "\$cfg['web_root'] = 'https://' . '$new_domain' . '${new_path%/}' . '/';" "$final_path/lib/config.local.php" +ynh_replace_string --match_string="\$cfg['web_root'] = .*" --replace_string="\$cfg['web_root'] = 'https://' . '$new_domain' . '${new_path%/}' . '/';" --target_file="$final_path/lib/config.local.php" #================================================= # GENERIC FINALISATION #================================================= # RELOAD NGINX #================================================= +ynh_script_progression --message="Reloading nginx web server..." -systemctl reload nginx +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Change of URL completed for $app" --last diff --git a/scripts/install b/scripts/install index 1237815..ad18600 100755 --- a/scripts/install +++ b/scripts/install @@ -6,14 +6,15 @@ # IMPORT GENERIC HELPERS #================================================= -# source _common.sh +source _common.sh source /usr/share/yunohost/helpers #================================================= -# MANAGE FAILURE OF THE SCRIPT +# MANAGE SCRIPT FAILURE #================================================= -ynh_abort_if_errors # Active trap pour arrêter le script si une erreur est détectée. +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST @@ -28,60 +29,57 @@ is_public=$YNH_APP_ARG_IS_PUBLIC app=$YNH_APP_INSTANCE_NAME #================================================= -# CHECK IF THE APP CAN BE INSTALLED WITH THIS ARGS +# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= +ynh_script_progression --message="Validating installation parameters..." final_path=/var/www/$app test ! -e "$final_path" || ynh_die "This path already contains a folder" -# Normalize the url path syntax -path_url=$(ynh_normalize_url_path $path_url) - -# Check web path availability -ynh_webpath_available $domain $path_url # 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..." -ynh_app_setting_set $app domain $domain -ynh_app_setting_set $app path $path_url -ynh_app_setting_set $app admin $admin_user -ynh_app_setting_set $app is_public $is_public +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_user +ynh_app_setting_set --app=$app --key=is_public --value=$is_public #================================================= # STANDARD MODIFICATIONS #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= +ynh_script_progression --message="Setting up source files..." --weight=3 -ynh_app_setting_set $app final_path $final_path -ynh_setup_source "$final_path" # Télécharge la source, décompresse et copie dans $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 --dest_dir="$final_path" #================================================= # NGINX CONFIGURATION #================================================= +ynh_script_progression --message="Configuring nginx web server..." # Create a dedicated nginx config ynh_add_nginx_config -if [ "$path_url" != "/" ] -then - ynh_replace_string "^#sub_path_only" "" "/etc/nginx/conf.d/$domain.d/$app.conf" -fi -ynh_store_file_checksum "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # CREATE DEDICATED USER #================================================= +ynh_script_progression --message="Configuring system user..." --weight=2 # Create a system user -ynh_system_user_create $app +ynh_system_user_create --username=$app #================================================= # PHP-FPM CONFIGURATION #================================================= +ynh_script_progression --message="Configuring php-fpm..." --weight=2 # Create a dedicated php-fpm config ynh_add_fpm_config @@ -98,30 +96,32 @@ cp "../conf/config.local.php" "$jirafeauconfigfile" # Set and save upload password, allowing an empty one if [ -z "$upload_password" ] then - ynh_replace_string "YNH_UPLOAD_PASSWORD" "" "$jirafeauconfigfile" - ynh_app_setting_set $app upload_password "" + ynh_replace_string --match_string="__YNH_UPLOAD_PASSWORD__" --replace_string="" --target_file="$jirafeauconfigfile" + ynh_app_setting_set --app=$app --key=upload_password --value="" else - ynh_replace_string "YNH_UPLOAD_PASSWORD" "'$upload_password'" "$jirafeauconfigfile" - ynh_app_setting_set $app upload_password "$upload_password" + ynh_replace_string --match_string="__YNH_UPLOAD_PASSWORD__" --replace_string="'$upload_password'" --target_file="$jirafeauconfigfile" + ynh_app_setting_set --app=$app --key=upload_password --value="$upload_password" fi #================================================= # CONFIGURE JIRAFEAU #================================================= +ynh_script_progression --message="Configuring jirafeau..." var_root=/home/yunohost.app/$app -ynh_replace_string "YNH_DOMAIN" "$domain" "$jirafeauconfigfile" + +ynh_replace_string --match_string="__YNH_DOMAIN__" --replace_string="$domain" --target_file="$jirafeauconfigfile" if [ "$path_url" = "/" ] then - ynh_replace_string "YNH_WWW_PATH" "" "$jirafeauconfigfile" + ynh_replace_string --match_string="__YNH_WWW_PATH__" --replace_string="" --target_file="$jirafeauconfigfile" else - ynh_replace_string "YNH_WWW_PATH" "$path_url" "$jirafeauconfigfile" + ynh_replace_string --match_string="__YNH_WWW_PATH__" --replace_string="$path_url" --target_file="$jirafeauconfigfile" fi -ynh_replace_string "YNH_VAR_ROOT" "$var_root" "$jirafeauconfigfile" -ynh_replace_string "YNH_ADMIN_USER" "$admin_user" "$jirafeauconfigfile" +ynh_replace_string --match_string="__YNH_VAR_ROOT__" --replace_string="$var_root" --target_file="$jirafeauconfigfile" +ynh_replace_string --match_string="__YNH_ADMIN_USER__" --replace_string="$admin_user" --target_file="$jirafeauconfigfile" # Calculate and store the config file checksum into the app settings -ynh_store_file_checksum "$jirafeauconfigfile" +ynh_store_file_checksum --file="$jirafeauconfigfile" # Remove the install.php rm $final_path/install.php @@ -141,17 +141,25 @@ chmod -R 700 $var_root #================================================= # SETUP SSOWAT #================================================= +ynh_script_progression --message="Configuring SSOwat..." -ynh_app_setting_set $app unprotected_uris "/" +ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" if [ $is_public -eq 0 ] then domain_regex=$(echo "$domain" | sed 's@-@.@g') [ "$path_url" = "/" ] && path_url="" - ynh_app_setting_set $app protected_regex "$domain_regex$path_url/$","$domain_regex$path_url/admin.php.*$" + ynh_app_setting_set --app=$app --key=protected_regex --value="$domain_regex$path_url/$","$domain_regex$path_url/admin.php.*$" fi #================================================= # RELOAD NGINX #================================================= +ynh_script_progression --message="Reloading nginx web server..." -systemctl reload nginx +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Installation of $app completed" --last diff --git a/scripts/remove b/scripts/remove index fe32306..ade82c6 100755 --- a/scripts/remove +++ b/scripts/remove @@ -6,30 +6,33 @@ # IMPORT GENERIC HELPERS #================================================= -# source _common.sh +source _common.sh source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME -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 THE MAIN DIR OF THE APP #================================================= +ynh_script_progression --message="Removing app main directory..." # Remove the app directory securely -ynh_secure_remove "$final_path" +ynh_secure_remove --file="$final_path" #================================================= # REMOVE THE NGINX CONFIGURATION #================================================= +ynh_script_progression --message="Removing nginx web server configuration..." # Remove the dedicated nginx config ynh_remove_nginx_config @@ -37,6 +40,7 @@ ynh_remove_nginx_config #================================================= # REMOVE THE PHP-FPM CONFIGURATION #================================================= +ynh_script_progression --message="Removing php-fpm configuration..." --weight=2 # Remove the dedicated php-fpm config ynh_remove_fpm_config @@ -46,14 +50,22 @@ ynh_remove_fpm_config #================================================= # REMOVE THE DATA DIRECTORY #================================================= +ynh_script_progression --message="Removing data directory..." -ynh_secure_remove "/home/yunohost.app/$app" +ynh_secure_remove --file="/home/yunohost.app/$app" #================================================= # GENERIC FINALISATION #================================================= # REMOVE DEDICATED USER #================================================= +ynh_script_progression --message="Removing the dedicated system user..." # 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" --last diff --git a/scripts/restore b/scripts/restore index ef045f4..a94399e 100644 --- a/scripts/restore +++ b/scripts/restore @@ -4,12 +4,7 @@ # IMPORT GENERIC HELPERS #================================================= -# if [ ! -e _common.sh ]; then -# # Rapatrie le fichier de fonctions si il n'est pas dans le dossier courant -# sudo cp ../settings/scripts/_common.sh ./_common.sh -# sudo chmod a+rx _common.sh -# fi -# source _common.sh +source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers #================================================= @@ -22,62 +17,72 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= +ynh_script_progression --message="Loading settings..." --weight=2 app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get $app domain) -path_url=$(ynh_app_setting_get $app path) -final_path=$(ynh_app_setting_get $app final_path) -db_name=$(ynh_app_setting_get $app db_name) +domain=$(ynh_app_setting_get --app=$app --key=domain) +path_url=$(ynh_app_setting_get --app=$app --key=path) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) +db_name=$(ynh_app_setting_get --app=$app --key=db_name) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= +ynh_script_progression --message="Validating restoration parameters..." -ynh_webpath_available $domain $path_url \ - || ynh_die "Path not available: ${domain}${path_url}" +ynh_webpath_available --domain=$domain --path_url=$path_url \ + || ynh_die --message="Path not available: ${domain}${path_url}" test ! -d $final_path \ - || ynh_die "There is already a directory: $final_path " + || ynh_die --message="There is already a directory: $final_path " #================================================= # STANDARD RESTORE STEPS #================================================= -# RESTORE OF THE NGINX CONFIGURATION +# 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 OF THE MAIN DIR OF THE APP +# RESTORE THE APP MAIN DIR #================================================= +ynh_script_progression --message="Restoring the app main directory..." -ynh_restore_file "$final_path" +ynh_restore_file --origin_path="$final_path" #================================================= -# RECREATE OF THE DEDICATED USER +# RECREATE THE DEDICATED USER #================================================= +ynh_script_progression --message="Recreating the dedicated system user..." --weight=2 # Create the dedicated user (if not existing) -ynh_system_user_create $app +ynh_system_user_create --username=$app #================================================= -# RESTORE OF THE PHP-FPM CONFIGURATION +# RESTORE THE PHP-FPM CONFIGURATION #================================================= -ynh_restore_file "/etc/php5/fpm/pool.d/$app.conf" +ynh_restore_file --origin_path="/etc/php/7.0/fpm/pool.d/$app.conf" #================================================= # SPECIFIC RESTORE #================================================= # RESTORE THE DATA OF JIRAFEAU #================================================= +ynh_script_progression --message="Restoring the data directory..." --weight=2 -ynh_restore_file "/home/yunohost.app/$app" +datadir="/home/yunohost.app/$app" + +# Use --not_mandatory for the data directory, because if the backup has been made with BACKUP_CORE_ONLY, there's no data into the backup. +ynh_restore_file --origin_path="$datadir" --not_mandatory #================================================= # RESTORE USER RIGHTS #================================================= +# Create app folders +mkdir -p "$datadir"/{files,links,async,block} chown -R $app:root /home/yunohost.app/$app #================================================= @@ -85,6 +90,13 @@ chown -R $app:root /home/yunohost.app/$app #================================================= # RELOAD NGINX AND PHP-FPM #================================================= +ynh_script_progression --message="Reloading nginx web server and php-fpm..." -sudo systemctl reload php5-fpm -sudo systemctl reload nginx +ynh_systemd_action --service_name=php7.0-fpm --action=reload +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Restoration completed for $app" --last diff --git a/scripts/upgrade b/scripts/upgrade index 12ae7fd..cae86d6 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -6,57 +6,69 @@ # IMPORT GENERIC HELPERS #================================================= -# source _common.sh +source _common.sh source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= +ynh_script_progression --message="Loading installation settings..." --weight=2 app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get $app domain) -path_url=$(ynh_app_setting_get $app path) -admin_user=$(ynh_app_setting_get $app admin_user) -upload_password=$(ynh_app_setting_get $app upload_password) -final_path=$(ynh_app_setting_get $app final_path) -is_public=$(ynh_app_setting_get $app is_public) +domain=$(ynh_app_setting_get --app=$app --key=domain) +path_url=$(ynh_app_setting_get --app=$app --key=path) +admin_user=$(ynh_app_setting_get --app=$app --key=admin_user) +is_public=$(ynh_app_setting_get --app=$app --key=is_public) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) +upload_password=$(ynh_app_setting_get --app=$app --key=upload_password) #================================================= -# FIX OLD THINGS +# CHECK VERSION #================================================= +upgrade_type=$(ynh_check_app_version_changed) + +#================================================= +# ENSURE DOWNWARD COMPATIBILITY +#================================================= +ynh_script_progression --message="Ensuring downward compatibility..." + # Fix is_public as a boolean value if [ "$is_public" = "Yes" ]; then - ynh_app_setting_set $app is_public 1 + ynh_app_setting_set --app=$app --key=is_public --value=1 is_public=1 elif [ "$is_public" = "No" ]; then - ynh_app_setting_set $app is_public 0 + ynh_app_setting_set --app=$app --key=is_public --value=0 is_public=0 fi # If final_path doesn't exist, create it -if [ -z $final_path ]; then +if [ -z "$final_path" ]; then final_path=/var/www/$app - ynh_app_setting_set $app final_path $final_path + ynh_app_setting_set --app=$app --key=final_path --value=$final_path fi #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= +ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=3 -ynh_backup_before_upgrade # Backup the current version of the app +# Backup the current version of the app +ynh_backup_before_upgrade ynh_clean_setup () { - ynh_restore_upgradebackup # restore it if the upgrade fails + # restore it if the upgrade fails + ynh_restore_upgradebackup } -ynh_abort_if_errors # Exit if an error occurs during the execution of the script +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors #================================================= # CHECK THE PATH #================================================= # 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 @@ -64,31 +76,34 @@ path_url=$(ynh_normalize_url_path $path_url) # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -# Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source "$final_path" +if [ "$upgrade_type" == "UPGRADE_APP" ] +then + ynh_script_progression --message="Upgrading source files..." --weight=2 + + # Download, check integrity, uncompress and patch the source from app.src + ynh_setup_source --dest_dir="$final_path" +fi #================================================= # NGINX CONFIGURATION #================================================= +ynh_script_progression --message="Upgrading nginx web server configuration..." --weight=2 # Create a dedicated nginx config ynh_add_nginx_config -if [ "$path_url" != "/" ] -then - ynh_replace_string "^#sub_path_only" "" "/etc/nginx/conf.d/$domain.d/$app.conf" -fi -ynh_store_file_checksum "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # CREATE DEDICATED USER #================================================= +ynh_script_progression --message="Making sure dedicated system user exists..." -# Create a system user -ynh_system_user_create $app +# Create a dedicated user (if not existing) +ynh_system_user_create --username=$app #================================================= # PHP-FPM CONFIGURATION #================================================= +ynh_script_progression --message="Upgrading php-fpm configuration..." --weight=2 # Create a dedicated php-fpm config ynh_add_fpm_config @@ -101,36 +116,39 @@ ynh_add_fpm_config jirafeauconfigfile="$final_path/lib/config.local.php" -ynh_backup_if_checksum_is_different "$final_path/lib/config.local.php" # Créé un backup du fichier de config si il a été modifié. +ynh_backup_if_checksum_is_different --file="$final_path/lib/config.local.php" -sudo cp "../conf/config.local.php" "$final_path/lib/config.local.php" +cp "../conf/config.local.php" "$final_path/lib/config.local.php" # Set and save upload password, allowing an empty one if [ -z "$upload_password" ] then - ynh_replace_string "YNH_UPLOAD_PASSWORD" "" "$jirafeauconfigfile" - ynh_app_setting_set $app upload_password "" + ynh_replace_string --match_string="__YNH_UPLOAD_PASSWORD__" --replace_string="" --target_file="$jirafeauconfigfile" + ynh_app_setting_set --app=$app --key=upload_password --value="" else - ynh_replace_string "YNH_UPLOAD_PASSWORD" "'$upload_password'" "$jirafeauconfigfile" - ynh_app_setting_set $app upload_password "$upload_password" + ynh_replace_string --match_string="__YNH_UPLOAD_PASSWORD__" --replace_string="'$upload_password'" --target_file="$jirafeauconfigfile" + ynh_app_setting_set --app=$app --key=upload_password --value="$upload_password" fi #================================================= # CONFIGURE JIRAFEAU #================================================= +ynh_script_progression --message="Upgrading jirafeau configuration..." var_root=/home/yunohost.app/$app -ynh_replace_string "YNH_DOMAIN" "$domain" "$jirafeauconfigfile" + +ynh_replace_string --match_string="__YNH_DOMAIN__" --replace_string="$domain" --target_file="$jirafeauconfigfile" if [ "$path_url" = "/" ] then - ynh_replace_string "YNH_WWW_PATH" "" "$jirafeauconfigfile" + ynh_replace_string --match_string="__YNH_WWW_PATH__" --replace_string="" --target_file="$jirafeauconfigfile" else - ynh_replace_string "YNH_WWW_PATH" "$path_url" "$jirafeauconfigfile" + ynh_replace_string --match_string="__YNH_WWW_PATH__" --replace_string="$path_url" --target_file="$jirafeauconfigfile" fi -ynh_replace_string "YNH_VAR_ROOT" "$var_root" "$jirafeauconfigfile" -ynh_replace_string "YNH_ADMIN_USER" "$admin_user" "$jirafeauconfigfile" +ynh_replace_string --match_string="__YNH_VAR_ROOT__" --replace_string="$var_root" --target_file="$jirafeauconfigfile" +ynh_replace_string --match_string="__YNH_ADMIN_USER__" --replace_string="$admin_user" --target_file="$jirafeauconfigfile" -ynh_store_file_checksum "$jirafeauconfigfile" # Enregistre la somme de contrôle du fichier de config +# Recalculate and store the checksum of the file for the next upgrade. +ynh_store_file_checksum --file="$jirafeauconfigfile" # Remove the install.php rm $final_path/install.php @@ -141,26 +159,34 @@ rm $final_path/install.php # SECURING FILES AND DIRECTORIES #================================================= -sudo chown -R root: $final_path +chown -R root: $final_path -sudo mkdir -p $var_root/{files,links,async,block} -sudo chown -R $app:root $var_root -sudo chmod -R 700 $var_root +mkdir -p $var_root/{files,links,async,block} +chown -R $app:root $var_root +chmod -R 700 $var_root #================================================= # SETUP SSOWAT #================================================= +ynh_script_progression --message="Upgrading SSOwat configuration..." --weight=2 -ynh_app_setting_set $app unprotected_uris "/" +ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" if [ $is_public -eq 0 ] then domain_regex=$(echo "$domain" | sed 's@-@.@g') [ "$path_url" = "/" ] && path_url="" - ynh_app_setting_set $app protected_regex "$domain_regex$path_url/$","$domain_regex$path_url/admin.php.*$" + ynh_app_setting_set --app=$app --key=protected_regex --value="$domain_regex$path_url/$","$domain_regex$path_url/admin.php.*$" fi #================================================= # RELOAD NGINX #================================================= +ynh_script_progression --message="Reloading nginx web server..." -sudo systemctl reload nginx +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Upgrade of $app completed" --last