From 4e3ea101dc89127e2979ecb1c475de4422cc1106 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Wed, 13 Feb 2019 21:13:59 +0100 Subject: [PATCH 1/5] Normalization from example_ynh --- README.md | 62 +++++++++++++++++++++++++++++++++++++++---- check_process | 1 - conf/config.local.php | 8 +++--- conf/nginx.conf | 8 ++++++ manifest.json | 2 +- scripts/_common.sh | 15 ----------- scripts/backup | 10 +++---- scripts/change_url | 21 +++++---------- scripts/install | 31 +++++++++------------- scripts/remove | 2 +- scripts/restore | 15 ++++------- scripts/upgrade | 50 +++++++++++++++++----------------- 12 files changed, 124 insertions(+), 101 deletions(-) diff --git a/README.md b/README.md index bfb292a..b65e24e 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,60 @@ -# 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://jirafeau.net/) + +## 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%28Official%29.svg)](https://ci-apps.yunohost.org/ci/apps/jirafeau/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/jirafeau%20%28Official%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%28Official%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 + * 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..8715c53 100644 --- a/check_process +++ b/check_process @@ -1,5 +1,4 @@ ;; Test complet - auto_remove=1 ; Manifest domain="domain.tld" (DOMAIN) path="/path" (PATH) 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..521cf79 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,12 +1,18 @@ #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; @@ -21,9 +27,11 @@ 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; diff --git a/manifest.json b/manifest.json index 947f5bd..fc4137a 100644 --- a/manifest.json +++ b/manifest.json @@ -9,8 +9,8 @@ "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" }, - "url": "https://gitlab.com/mojo42/Jirafeau", "version": "3.4.1~ynh2", + "url": "https://gitlab.com/mojo42/Jirafeau", "license": "AGPL-3.0-only", "maintainer": { "name": "julien", 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..6551277 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 #================================================= @@ -42,7 +37,8 @@ ynh_backup "$final_path" # 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 +# This argument has to be the third one. +ynh_backup "/home/yunohost.app/$app" "/home/yunohost.app/$app" 1 #================================================= # BACKUP OF THE NGINX CONFIGURATION diff --git a/scripts/change_url b/scripts/change_url index 7ae12c8..be7ed2e 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -25,7 +25,7 @@ app=$YNH_APP_INSTANCE_NAME # LOAD SETTINGS #================================================= -final_path=$(ynh_app_setting_get "$app" final_path) +final_path=$(ynh_app_setting_get $app final_path) #================================================= # CHECK PATHS SYNTAX @@ -63,30 +63,23 @@ 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 "$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 "$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 "/etc/nginx/conf.d/$new_domain.d/$app.conf" fi #================================================= diff --git a/scripts/install b/scripts/install index 1237815..42d0076 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,7 +29,7 @@ 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 #================================================= final_path=/var/www/$app @@ -37,8 +38,6 @@ 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 @@ -66,11 +65,6 @@ ynh_setup_source "$final_path" # Télécharge la source, décompresse et copie d # 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 @@ -98,10 +92,10 @@ 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_replace_string "__YNH_UPLOAD_PASSWORD__" "" "$jirafeauconfigfile" ynh_app_setting_set $app upload_password "" else - ynh_replace_string "YNH_UPLOAD_PASSWORD" "'$upload_password'" "$jirafeauconfigfile" + ynh_replace_string "__YNH_UPLOAD_PASSWORD__" "'$upload_password'" "$jirafeauconfigfile" ynh_app_setting_set $app upload_password "$upload_password" fi @@ -110,15 +104,16 @@ fi #================================================= var_root=/home/yunohost.app/$app -ynh_replace_string "YNH_DOMAIN" "$domain" "$jirafeauconfigfile" + +ynh_replace_string "__YNH_DOMAIN__" "$domain" "$jirafeauconfigfile" if [ "$path_url" = "/" ] then - ynh_replace_string "YNH_WWW_PATH" "" "$jirafeauconfigfile" + ynh_replace_string "__YNH_WWW_PATH__" "" "$jirafeauconfigfile" else - ynh_replace_string "YNH_WWW_PATH" "$path_url" "$jirafeauconfigfile" + ynh_replace_string "__YNH_WWW_PATH__" "$path_url" "$jirafeauconfigfile" fi -ynh_replace_string "YNH_VAR_ROOT" "$var_root" "$jirafeauconfigfile" -ynh_replace_string "YNH_ADMIN_USER" "$admin_user" "$jirafeauconfigfile" +ynh_replace_string "__YNH_VAR_ROOT__" "$var_root" "$jirafeauconfigfile" +ynh_replace_string "__YNH_ADMIN_USER__" "$admin_user" "$jirafeauconfigfile" # Calculate and store the config file checksum into the app settings ynh_store_file_checksum "$jirafeauconfigfile" diff --git a/scripts/remove b/scripts/remove index fe32306..2f100f9 100755 --- a/scripts/remove +++ b/scripts/remove @@ -6,7 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= -# source _common.sh +source _common.sh source /usr/share/yunohost/helpers #================================================= diff --git a/scripts/restore b/scripts/restore index ef045f4..425d1fa 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 #================================================= @@ -42,26 +37,26 @@ test ! -d $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" #================================================= -# RESTORE OF THE MAIN DIR OF THE APP +# RESTORE THE APP MAIN DIR #================================================= ynh_restore_file "$final_path" #================================================= -# RECREATE OF THE DEDICATED USER +# RECREATE THE DEDICATED USER #================================================= # Create the dedicated user (if not existing) ynh_system_user_create $app #================================================= -# RESTORE OF THE PHP-FPM CONFIGURATION +# RESTORE THE PHP-FPM CONFIGURATION #================================================= ynh_restore_file "/etc/php5/fpm/pool.d/$app.conf" diff --git a/scripts/upgrade b/scripts/upgrade index 12ae7fd..2cd717b 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -6,7 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= -# source _common.sh +source _common.sh source /usr/share/yunohost/helpers #================================================= @@ -45,11 +45,14 @@ fi # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -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 @@ -73,17 +76,12 @@ ynh_setup_source "$final_path" # 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 #================================================= -# Create a system user +# Create a dedicated user (if not existing) ynh_system_user_create $app #================================================= @@ -101,17 +99,17 @@ 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 "$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_replace_string "__YNH_UPLOAD_PASSWORD__" "" "$jirafeauconfigfile" ynh_app_setting_set $app upload_password "" else - ynh_replace_string "YNH_UPLOAD_PASSWORD" "'$upload_password'" "$jirafeauconfigfile" + ynh_replace_string "__YNH_UPLOAD_PASSWORD__" "'$upload_password'" "$jirafeauconfigfile" ynh_app_setting_set $app upload_password "$upload_password" fi @@ -120,17 +118,19 @@ fi #================================================= var_root=/home/yunohost.app/$app -ynh_replace_string "YNH_DOMAIN" "$domain" "$jirafeauconfigfile" + +ynh_replace_string "__YNH_DOMAIN__" "$domain" "$jirafeauconfigfile" if [ "$path_url" = "/" ] then - ynh_replace_string "YNH_WWW_PATH" "" "$jirafeauconfigfile" + ynh_replace_string "__YNH_WWW_PATH__" "" "$jirafeauconfigfile" else - ynh_replace_string "YNH_WWW_PATH" "$path_url" "$jirafeauconfigfile" + ynh_replace_string "__YNH_WWW_PATH__" "$path_url" "$jirafeauconfigfile" fi -ynh_replace_string "YNH_VAR_ROOT" "$var_root" "$jirafeauconfigfile" -ynh_replace_string "YNH_ADMIN_USER" "$admin_user" "$jirafeauconfigfile" +ynh_replace_string "__YNH_VAR_ROOT__" "$var_root" "$jirafeauconfigfile" +ynh_replace_string "__YNH_ADMIN_USER__" "$admin_user" "$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 "$jirafeauconfigfile" # Remove the install.php rm $final_path/install.php @@ -141,11 +141,11 @@ 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 @@ -163,4 +163,4 @@ fi # RELOAD NGINX #================================================= -sudo systemctl reload nginx +systemctl reload nginx From bd5ee25fe2d6fd4dc26f77a65149e5b194d3bf74 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Wed, 13 Feb 2019 21:20:35 +0100 Subject: [PATCH 2/5] Use php7 --- conf/nginx.conf | 4 +- conf/php-fpm.conf | 122 +++++++++++++++++++++++++++++++++------------- manifest.json | 8 +-- scripts/backup | 2 +- scripts/restore | 6 +-- 5 files changed, 98 insertions(+), 44 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 521cf79..4b8549c 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -18,7 +18,7 @@ location __PATH__/ { 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; @@ -34,7 +34,7 @@ location __PATH__/ { 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 fc4137a..f64b6bc 100644 --- a/manifest.json +++ b/manifest.json @@ -2,9 +2,6 @@ "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" @@ -16,10 +13,13 @@ "name": "julien", "email": "julien.malik@paraiso.me" }, + "requirements": { + "yunohost": ">= 3.0" + }, "multi_instance": false, "services": [ "nginx", - "php5-fpm" + "php7.0-fpm" ], "arguments": { "install" : [ diff --git a/scripts/backup b/scripts/backup index 6551277..abd437d 100644 --- a/scripts/backup +++ b/scripts/backup @@ -50,4 +50,4 @@ ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" # BACKUP OF THE PHP-FPM CONFIGURATION #================================================= -ynh_backup "/etc/php5/fpm/pool.d/$app.conf" +ynh_backup "/etc/php/7.0/fpm/pool.d/$app.conf" diff --git a/scripts/restore b/scripts/restore index 425d1fa..12ae02c 100644 --- a/scripts/restore +++ b/scripts/restore @@ -59,7 +59,7 @@ ynh_system_user_create $app # RESTORE THE PHP-FPM CONFIGURATION #================================================= -ynh_restore_file "/etc/php5/fpm/pool.d/$app.conf" +ynh_restore_file "/etc/php/7.0/fpm/pool.d/$app.conf" #================================================= # SPECIFIC RESTORE @@ -81,5 +81,5 @@ chown -R $app:root /home/yunohost.app/$app # RELOAD NGINX AND PHP-FPM #================================================= -sudo systemctl reload php5-fpm -sudo systemctl reload nginx +systemctl reload php7.0-fpm +systemctl reload nginx From c591f476f76108018fc9804c94aab45ac9f849af Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Sun, 17 Feb 2019 20:55:13 +0100 Subject: [PATCH 3/5] Add progression with ynh_print_info --- README.md | 2 +- manifest.json | 2 +- scripts/backup | 11 +++++++++++ scripts/change_url | 9 +++++++++ scripts/install | 15 +++++++++++++++ scripts/remove | 12 ++++++++++++ scripts/restore | 12 ++++++++++++ scripts/upgrade | 18 +++++++++++++++++- 8 files changed, 78 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b65e24e..88afe53 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Jirafeau is a web site permitting to upload a file in a simple way and give an u ## Demo -* [YunoHost demo](https://jirafeau.net/) +* [YunoHost demo](https://demo.yunohost.org/jirafeau/) ## Configuration diff --git a/manifest.json b/manifest.json index f64b6bc..a949633 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "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~ynh2", + "version": "3.4.1~ynh3", "url": "https://gitlab.com/mojo42/Jirafeau", "license": "AGPL-3.0-only", "maintainer": { diff --git a/scripts/backup b/scripts/backup index abd437d..77d8c0c 100644 --- a/scripts/backup +++ b/scripts/backup @@ -17,6 +17,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= +ynh_print_info "Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -28,12 +29,14 @@ domain=$(ynh_app_setting_get $app domain) #================================================= # BACKUP OF THE MAIN DIR OF THE APP #================================================= +ynh_print_info "Backing up the main app directory..." ynh_backup "$final_path" #================================================= # BACKUP OF THE DATA DIR #================================================= +ynh_print_info "Backing up data directory..." # The 1 parameter indicates the directory is "big", # so that it won't be backed up before upgrade @@ -43,11 +46,19 @@ ynh_backup "/home/yunohost.app/$app" "/home/yunohost.app/$app" 1 #================================================= # BACKUP OF THE NGINX CONFIGURATION #================================================= +ynh_print_info "Backing up nginx web server configuration..." ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # BACKUP OF THE PHP-FPM CONFIGURATION #================================================= +ynh_print_info "Backing up php-fpm configuration..." ynh_backup "/etc/php/7.0/fpm/pool.d/$app.conf" + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/change_url b/scripts/change_url index be7ed2e..5708ecc 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -24,6 +24,7 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # LOAD SETTINGS #================================================= +ynh_print_info "Loading installation settings..." final_path=$(ynh_app_setting_get $app final_path) @@ -57,6 +58,7 @@ fi #================================================= # MODIFY URL IN NGINX CONF #================================================= +ynh_print_info "Updating nginx web server configuration..." nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf @@ -94,5 +96,12 @@ ynh_replace_string "\$cfg['web_root'] = .*" "\$cfg['web_root'] = 'https://' . '$ #================================================= # RELOAD NGINX #================================================= +ynh_print_info "Reloading nginx web server..." systemctl reload nginx + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Change of url completed for $app" diff --git a/scripts/install b/scripts/install index 42d0076..9e2324a 100755 --- a/scripts/install +++ b/scripts/install @@ -31,6 +31,7 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= +ynh_print_info "Validating installation parameters..." final_path=/var/www/$app test ! -e "$final_path" || ynh_die "This path already contains a folder" @@ -44,6 +45,7 @@ ynh_webpath_register $app $domain $path_url #================================================= # STORE SETTINGS FROM MANIFEST #================================================= +ynh_print_info "Storing installation settings..." ynh_app_setting_set $app domain $domain ynh_app_setting_set $app path $path_url @@ -55,6 +57,7 @@ ynh_app_setting_set $app is_public $is_public #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= +ynh_print_info "Setting up source files..." 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 @@ -62,6 +65,7 @@ ynh_setup_source "$final_path" # Télécharge la source, décompresse et copie d #================================================= # NGINX CONFIGURATION #================================================= +ynh_print_info "Configuring nginx web server..." # Create a dedicated nginx config ynh_add_nginx_config @@ -69,6 +73,7 @@ ynh_add_nginx_config #================================================= # CREATE DEDICATED USER #================================================= +ynh_print_info "Configuring system user..." # Create a system user ynh_system_user_create $app @@ -76,6 +81,7 @@ ynh_system_user_create $app #================================================= # PHP-FPM CONFIGURATION #================================================= +ynh_print_info "Configuring php-fpm..." # Create a dedicated php-fpm config ynh_add_fpm_config @@ -102,6 +108,7 @@ fi #================================================= # CONFIGURE JIRAFEAU #================================================= +ynh_print_info "Configuring jirafeau..." var_root=/home/yunohost.app/$app @@ -136,6 +143,7 @@ chmod -R 700 $var_root #================================================= # SETUP SSOWAT #================================================= +ynh_print_info "Configuring SSOwat..." ynh_app_setting_set $app unprotected_uris "/" if [ $is_public -eq 0 ] @@ -148,5 +156,12 @@ fi #================================================= # RELOAD NGINX #================================================= +ynh_print_info "Reloading nginx web server..." systemctl reload nginx + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Installation of $app completed" diff --git a/scripts/remove b/scripts/remove index 2f100f9..b6c8ac2 100755 --- a/scripts/remove +++ b/scripts/remove @@ -12,6 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= +ynh_print_info "Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -23,6 +24,7 @@ final_path=$(ynh_app_setting_get $app final_path) #================================================= # REMOVE THE MAIN DIR OF THE APP #================================================= +ynh_print_info "Removing app main directory" # Remove the app directory securely ynh_secure_remove "$final_path" @@ -30,6 +32,7 @@ ynh_secure_remove "$final_path" #================================================= # REMOVE THE NGINX CONFIGURATION #================================================= +ynh_print_info "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_print_info "Removing php-fpm configuration" # Remove the dedicated php-fpm config ynh_remove_fpm_config @@ -46,6 +50,7 @@ ynh_remove_fpm_config #================================================= # REMOVE THE DATA DIRECTORY #================================================= +ynh_print_info "Removing data directory" ynh_secure_remove "/home/yunohost.app/$app" @@ -54,6 +59,13 @@ ynh_secure_remove "/home/yunohost.app/$app" #================================================= # REMOVE DEDICATED USER #================================================= +ynh_print_info "Removing the dedicated system user" # Delete a system user ynh_system_user_delete $app + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index 12ae02c..85088ee 100644 --- a/scripts/restore +++ b/scripts/restore @@ -17,6 +17,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= +ynh_print_info "Loading settings..." app=$YNH_APP_INSTANCE_NAME @@ -28,6 +29,7 @@ db_name=$(ynh_app_setting_get $app db_name) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= +ynh_print_info "Validating restoration parameters..." ynh_webpath_available $domain $path_url \ || ynh_die "Path not available: ${domain}${path_url}" @@ -45,12 +47,14 @@ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RESTORE THE APP MAIN DIR #================================================= +ynh_print_info "Restoring the app main directory..." ynh_restore_file "$final_path" #================================================= # RECREATE THE DEDICATED USER #================================================= +ynh_print_info "Recreating the dedicated system user..." # Create the dedicated user (if not existing) ynh_system_user_create $app @@ -66,6 +70,7 @@ ynh_restore_file "/etc/php/7.0/fpm/pool.d/$app.conf" #================================================= # RESTORE THE DATA OF JIRAFEAU #================================================= +ynh_print_info "Restoring the data directory..." ynh_restore_file "/home/yunohost.app/$app" @@ -80,6 +85,13 @@ chown -R $app:root /home/yunohost.app/$app #================================================= # RELOAD NGINX AND PHP-FPM #================================================= +ynh_print_info "Reloading nginx web server and php-fpm..." systemctl reload php7.0-fpm systemctl reload nginx + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Restoration completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index 2cd717b..00cdc9d 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -12,6 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= +ynh_print_info "Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -23,8 +24,9 @@ final_path=$(ynh_app_setting_get $app final_path) is_public=$(ynh_app_setting_get $app is_public) #================================================= -# FIX OLD THINGS +# ENSURE DOWNWARD COMPATIBILITY #================================================= +ynh_print_info "Ensuring downward compatibility..." # Fix is_public as a boolean value if [ "$is_public" = "Yes" ]; then @@ -44,6 +46,7 @@ fi #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= +ynh_print_info "Backing up the app before upgrading (may take a while)..." # Backup the current version of the app ynh_backup_before_upgrade @@ -66,6 +69,7 @@ path_url=$(ynh_normalize_url_path $path_url) #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= +ynh_print_info "Upgrading source files..." # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source "$final_path" @@ -73,6 +77,7 @@ ynh_setup_source "$final_path" #================================================= # NGINX CONFIGURATION #================================================= +ynh_print_info "Upgrading nginx web server configuration..." # Create a dedicated nginx config ynh_add_nginx_config @@ -80,6 +85,7 @@ ynh_add_nginx_config #================================================= # CREATE DEDICATED USER #================================================= +ynh_print_info "Making sure dedicated system user exists..." # Create a dedicated user (if not existing) ynh_system_user_create $app @@ -87,6 +93,7 @@ ynh_system_user_create $app #================================================= # PHP-FPM CONFIGURATION #================================================= +ynh_print_info "Upgrading php-fpm configuration..." # Create a dedicated php-fpm config ynh_add_fpm_config @@ -116,6 +123,7 @@ fi #================================================= # CONFIGURE JIRAFEAU #================================================= +ynh_print_info "Upgrading jirafeau configuration..." var_root=/home/yunohost.app/$app @@ -150,6 +158,7 @@ chmod -R 700 $var_root #================================================= # SETUP SSOWAT #================================================= +ynh_print_info "Upgrading SSOwat configuration..." ynh_app_setting_set $app unprotected_uris "/" if [ $is_public -eq 0 ] @@ -162,5 +171,12 @@ fi #================================================= # RELOAD NGINX #================================================= +ynh_print_info "Reloading nginx web server..." systemctl reload nginx + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Upgrade of $app completed" From 5270a05fc0690ac378edee33dcae5e502256100c Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Tue, 5 Mar 2019 16:48:34 +0100 Subject: [PATCH 4/5] Handle datadir not backup --- scripts/restore | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/scripts/restore b/scripts/restore index 85088ee..3811c56 100644 --- a/scripts/restore +++ b/scripts/restore @@ -72,7 +72,17 @@ ynh_restore_file "/etc/php/7.0/fpm/pool.d/$app.conf" #================================================= ynh_print_info "Restoring the data directory..." -ynh_restore_file "/home/yunohost.app/$app" +datadir="/home/yunohost.app/$app" + +# The data directory will be restored only if it exists in the backup archive +# So only if it was backup previously. +if [ -d "$YNH_BACKUP_DIR/apps/$app/backup$datadir" ] +then + ynh_restore_file "$datadir" +else + # Create app folders + mkdir -p "$datadir"/{files,links,async,block} +fi #================================================= # RESTORE USER RIGHTS From 6c4698417c6050df66a790e61de9f87b1eec8a9b Mon Sep 17 00:00:00 2001 From: Kayou Date: Tue, 2 Apr 2019 18:24:38 +0200 Subject: [PATCH 5/5] Bump --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index a949633..1a88d7a 100644 --- a/manifest.json +++ b/manifest.json @@ -14,7 +14,7 @@ "email": "julien.malik@paraiso.me" }, "requirements": { - "yunohost": ">= 3.0" + "yunohost": ">= 3.2.0" }, "multi_instance": false, "services": [