From e5788a2fd3b963e19c5c5bc16a95db52a5f92acd Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sat, 10 Sep 2022 21:05:59 +0200 Subject: [PATCH] Add max_body_size --- conf/config.php | 21 +++++++++++++++++++++ conf/nginx.conf | 9 +-------- conf/php-fpm.conf | 4 ++-- manifest.json | 5 ++--- scripts/_common.sh | 2 +- scripts/install | 28 ++++++++++++++++++---------- scripts/remove | 19 ------------------- scripts/restore | 14 ++++++++------ scripts/upgrade | 9 +-------- 9 files changed, 54 insertions(+), 57 deletions(-) create mode 100644 conf/config.php diff --git a/conf/config.php b/conf/config.php new file mode 100644 index 0000000..6343277 --- /dev/null +++ b/conf/config.php @@ -0,0 +1,21 @@ + diff --git a/conf/nginx.conf b/conf/nginx.conf index 37de41d..b26a6dc 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -4,16 +4,10 @@ location __PATH__/ { # Path to source alias __FINALPATH__/ ; - # Force usage of https - if ($scheme = http) { - rewrite ^ https://$server_name$request_uri? permanent; - } - -### Example PHP configuration (remove it if not used) index index.php; # Common parameter to increase upload size limit in conjunction with dedicated php-fpm file - #client_max_body_size 50M; + client_max_body_size 50M; try_files $uri $uri/ index.php; location ~ [^/]\.php(/|$) { @@ -26,7 +20,6 @@ location __PATH__/ { fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param SCRIPT_FILENAME $request_filename; } -### End of PHP configuration part # Include SSOWAT user panel. include conf.d/yunohost_panel.conf.inc; diff --git a/conf/php-fpm.conf b/conf/php-fpm.conf index ab1a471..b4c2372 100644 --- a/conf/php-fpm.conf +++ b/conf/php-fpm.conf @@ -419,8 +419,8 @@ chdir = __FINALPATH__ ;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_value[upload_max_filesize] = 50M +php_admin_value[post_max_size] = 50M ; php_admin_flag[mail.add_x_header] = Off ; Other common parameters diff --git a/manifest.json b/manifest.json index 40bbf75..854d6dd 100644 --- a/manifest.json +++ b/manifest.json @@ -19,7 +19,7 @@ "email": "antoine@miaou.org" }, "requirements": { - "yunohost": ">= 4.2.4" + "yunohost": ">= 4.3.0" }, "multi_instance": true, "services": [ @@ -31,8 +31,7 @@ "install" : [ { "name": "domain", - "type": "domain", - "example": "example.com" + "type": "domain" }, { "name": "path", diff --git a/scripts/_common.sh b/scripts/_common.sh index d7614e9..4f582df 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,7 +4,7 @@ # COMMON VARIABLES #================================================= -YNH_PHP_VERSION="7.3" +YNH_PHP_VERSION="7.4" #================================================= # PERSONAL HELPERS diff --git a/scripts/install b/scripts/install index d93c61a..69b9a07 100755 --- a/scripts/install +++ b/scripts/install @@ -79,6 +79,14 @@ chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path" +#================================================= +# PHP-FPM CONFIGURATION +#================================================= +ynh_script_progression --message="Configuring PHP-FPM..." --weight=1 + +# Create a dedicated php-fpm config +ynh_add_fpm_config + #================================================= # NGINX CONFIGURATION #================================================= @@ -88,12 +96,14 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=1 ynh_add_nginx_config #================================================= -# PHP-FPM CONFIGURATION +# ADD A CONFIGURATION #================================================= -ynh_script_progression --message="Configuring PHP-FPM..." --weight=1 +ynh_script_progression --message="Adding a configuration file..." --weight=1 -# Create a dedicated php-fpm config -ynh_add_fpm_config +ynh_add_config --template="../conf/config.php" --destination="$final_path/conf/config.php" + +chmod 400 "$final_path/conf/config.php" +chown $app:$app "$final_path/conf/config.php" #================================================= # SETUP APPLICATION WITH CURL @@ -107,10 +117,6 @@ ynh_systemd_action --service_name=nginx --action=reload # Installation with curl ynh_script_progression --message="Finalizing installation..." --weight=1 -ynh_replace_string --match_string="votre_nom_de_bdd" --replace_string=$db_name --target_file="$final_path/conf/config.php" -ynh_replace_string --match_string="votre_utilisateur_de_bdd" --replace_string=$db_user --target_file="$final_path/conf/config.php" -ynh_replace_string --match_string="votre_mdp_de_bdd" --replace_string=$db_pwd --target_file="$final_path/conf/config.php" - ynh_local_curl "/install.php" # Supprimer install.php @@ -122,9 +128,11 @@ ynh_secure_remove --file=$final_path/install.php ynh_script_progression --message="Configuring permissions..." --weight=1 # Make app public if necessary -if [ $is_public -eq 0 ] +if [ $is_public -eq 1 ] then - ynh_permission_update --permission="main" --remove="visitors" + # Everyone can access the app. + # The "main" permission is automatically created before the install script. + ynh_permission_update --permission="main" --add="visitors" fi #================================================= diff --git a/scripts/remove b/scripts/remove index 7618fe2..46932d9 100755 --- a/scripts/remove +++ b/scripts/remove @@ -23,17 +23,6 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= # STANDARD REMOVE -#================================================= -# REMOVE SERVICE INTEGRATION IN YUNOHOST -#================================================= - -# Remove the service from the list of services known by Yunohost (added from `yunohost service add`) -if ynh_exec_warn_less yunohost service status $app >/dev/null -then - ynh_script_progression --message="Removing $app service..." --weight=1 - #yunohost service remove $app -fi - #================================================= # REMOVE THE MYSQL DATABASE #================================================= @@ -66,14 +55,6 @@ ynh_script_progression --message="Removing PHP-FPM configuration..." --weight=1 # Remove the dedicated php-fpm config ynh_remove_fpm_config -#================================================= -# REMOVE LOGROTATE CONFIGURATION -#================================================= -ynh_script_progression --message="Removing logrotate configuration..." --weight=1 - -# Remove the app-specific logrotate config -ynh_remove_logrotate - #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/restore b/scripts/restore index d6b56cb..5569de7 100755 --- a/scripts/restore +++ b/scripts/restore @@ -47,12 +47,6 @@ test ! -d $final_path \ #================================================= # STANDARD RESTORATION STEPS -#================================================= -# RESTORE THE NGINX CONFIGURATION -#================================================= - -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" - #================================================= # RECREATE THE DEDICATED USER #================================================= @@ -75,9 +69,17 @@ chown -R $app:www-data "$final_path" #================================================= # RESTORE THE PHP-FPM CONFIGURATION #================================================= +ynh_script_progression --message="Restoring the PHP-FPM configuration..." --weight=1 ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" +#================================================= +# RESTORE THE NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1 + +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" + #================================================= # RESTORE THE MYSQL DATABASE #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 1f7fff9..50f5591 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -77,7 +77,7 @@ then ynh_script_progression --message="Upgrading source files..." --weight=1 # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$final_path" + ynh_setup_source --dest_dir="$final_path" --keep="conf/config.php" fi chmod 750 "$final_path" @@ -106,13 +106,6 @@ ynh_add_fpm_config # Supprimer install.php ynh_secure_remove --file="$final_path/install.php" -# Restaurer config.php -# ynh_restore_file $final_path/conf/config.php # pas autorisé dans upgrade - -# autre piste -ynh_replace_string --match_string="votre_nom_de_bdd" --replace_string=$db_name --target_file="$final_path/conf/config.php" -ynh_replace_string --match_string="votre_utilisateur_de_bdd" --replace_string=$db_user --target_file="$final_path/conf/config.php" -ynh_replace_string --match_string="votre_mdp_de_bdd" --replace_string=$db_pwd --target_file="$final_path/conf/config.php" #================================================= # RELOAD NGINX