diff --git a/conf/nginx.conf b/conf/nginx.conf index f9ce2b6..f8ed873 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -4,29 +4,23 @@ location __PATH__/ { # Path to source alias __FINALPATH__/ ; - # Force usage of https + # Force usage of https if ($scheme = http) { rewrite ^ https://$server_name$request_uri? permanent; } - index index.php; - if (!-f $request_filename) { - rewrite ^ __PATH__/index.php last; - } + index index.html index.php; - # Common parameter to increase upload size limit in conjunction with dedicated php-fpm file - client_max_body_size 50M; - try_files $uri $uri/ index.php$is_args$args; + try_files $uri $uri/ /index.php?q=$uri&$args; location ~ [^/]\.php(/|$) { fastcgi_split_path_info ^(.+?\.php)(/.*)$; fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock; - fastcgi_index index.php; - include fastcgi_params; - fastcgi_param REMOTE_USER $remote_user; - fastcgi_param PATH_INFO $fastcgi_path_info; - fastcgi_param SCRIPT_FILENAME $request_filename; + fastcgi_index index.php; + fastcgi_param REMOTE_USER $remote_user; + fastcgi_param PATH_INFO $fastcgi_path_info; + include fastcgi_params; } # Include SSOWAT user panel. diff --git a/scripts/_common.sh b/scripts/_common.sh index 61ca47e..52200fa 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -20,6 +20,43 @@ extra_php_dependencies="php${YNH_PHP_VERSION}-cli php${YNH_PHP_VERSION}-gettext # EXPERIMENTAL HELPERS #================================================= +# Check available space before creating a temp directory. +# +# usage: ynh_smart_mktemp --min_size="Min size" +# +# | arg: -s, --min_size= - Minimal size needed for the temporary directory, in Mb +ynh_smart_mktemp () { + # Declare an array to define the options of this helper. + declare -Ar args_array=( [s]=min_size= ) + local min_size + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + + min_size="${min_size:-300}" + # Transform the minimum size from megabytes to kilobytes + min_size=$(( $min_size * 1024 )) + + # Check if there's enough free space in a directory + is_there_enough_space () { + local free_space=$(df --output=avail "$1" | sed 1d) + test $free_space -ge $min_size + } + + if is_there_enough_space /tmp; then + local tmpdir=/tmp + elif is_there_enough_space /var; then + local tmpdir=/var + elif is_there_enough_space /; then + local tmpdir=/ + elif is_there_enough_space /home; then + local tmpdir=/home + else + ynh_die "Insufficient free space to continue..." + fi + + echo "$(mktemp --directory --tmpdir="$tmpdir")" +} + #================================================= # FUTURE OFFICIAL HELPERS #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index c745b06..25bb381 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -21,6 +21,12 @@ path_url=$(ynh_app_setting_get --app=$app --key=path) is_public=$(ynh_app_setting_get --app=$app --key=is_public) final_path=$(ynh_app_setting_get --app=$app --key=final_path) +#================================================= +# CHECK VERSION +#================================================= + +upgrade_type=$(ynh_check_app_version_changed) + #================================================= # ENSURE DOWNWARD COMPATIBILITY #=================================================