From 0bd857d7620310be09d70f2a7e48b10a7827be48 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Tue, 3 Nov 2020 18:13:11 +0100 Subject: [PATCH 1/3] Fix last warning in linter about sudo ? --- scripts/_common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 2b9a766..84a4b01 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -341,7 +341,7 @@ ynh_smart_mktemp () { ynh_die "Insufficient free space to continue..." fi - echo "$(sudo mktemp --directory --tmpdir="$tmpdir")" + echo "$(mktemp --directory --tmpdir="$tmpdir")" } #================================================= From d5f703f47a27676b3188d1914d5d9740f56d6a0f Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 19 Nov 2020 08:10:43 +0100 Subject: [PATCH 2/3] Update nginx.conf --- conf/nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 462d900..adc69c3 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -91,7 +91,7 @@ location ^~ __PATH__/ { fastcgi_param modHeadersAvailable true; # Enable pretty urls fastcgi_param front_controller_active true; - fastcgi_pass unix:/var/run/php/php__YNH_PHP_VERSION__-fpm-__NAME__.sock; + fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock; fastcgi_intercept_errors on; fastcgi_request_buffering off; } From a9559aeac4f75332c3fd12a603e45540f41beb57 Mon Sep 17 00:00:00 2001 From: Kay0u Date: Thu, 19 Nov 2020 11:39:57 +0100 Subject: [PATCH 3/3] use phpversion for nginx helper --- scripts/change_url | 5 +++-- scripts/install | 36 +++++++++++++++++++----------------- scripts/upgrade | 46 ++++++++++++++++++++++++---------------------- 3 files changed, 46 insertions(+), 41 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 2aa5f36..c779071 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -28,6 +28,7 @@ ynh_script_progression --message="Loading installation settings..." # Needed for helper "ynh_add_nginx_config" final_path=$(ynh_app_setting_get --app=$app --key=final_path) +phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # CHECK WHICH PARTS SHOULD BE CHANGED @@ -63,7 +64,7 @@ then domain="$old_domain" path_url="$new_path" # Create a dedicated NGINX config - ynh_add_nginx_config YNH_PHP_VERSION + ynh_add_nginx_config fi # Change the domain for NGINX @@ -84,7 +85,7 @@ ynh_script_progression --message="Applying Nextcloud specific modifications..." # Define a function to execute commands with `occ` exec_occ() { (cd "$final_path" && exec_as "$app" \ - php${YNH_PHP_VERSION} occ --no-interaction --no-ansi "$@") + php${phpversion} occ --no-interaction --no-ansi "$@") } if [ $change_domain -eq 1 ] diff --git a/scripts/install b/scripts/install index abcedb4..692f594 100755 --- a/scripts/install +++ b/scripts/install @@ -84,23 +84,6 @@ cp -a ../sources/patches_last_version/* ../sources/patches # 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..." --weight=2 - -# Check if .well-known is available for this domain -if is_url_handled --domain="$domain" --path="/.well-known/caldav" || is_url_handled --domain="$domain" --path="/.well-known/carddav" -then - ynh_print_warn --message="Another app already uses the domain $domain to serve a caldav/carddav feature. You may encounter issues when dealing with your calendar or address book." - - # Remove lines about .well-known/carddav and caldav with sed. - sed --in-place --regexp-extended '/^location = \/\.well\-known\/(caldav|carddav) \{/,/\}/d' "../conf/nginx.conf" -fi - -# Create a dedicated NGINX config -ynh_add_nginx_config YNH_PHP_VERSION - #================================================= # CREATE DEDICATED USER #================================================= @@ -116,6 +99,25 @@ ynh_script_progression --message="Configuring PHP-FPM..." --weight=50 # Create a dedicated php-fpm config ynh_add_fpm_config --usage=medium --footprint=high --phpversion=$YNH_PHP_VERSION --package="$extra_php_dependencies" +# Used by ynh_add_nginx_config +phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) + +#================================================= +# NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Configuring NGINX web server..." --weight=2 + +# Check if .well-known is available for this domain +if is_url_handled --domain="$domain" --path="/.well-known/caldav" || is_url_handled --domain="$domain" --path="/.well-known/carddav" +then + ynh_print_warn --message="Another app already uses the domain $domain to serve a caldav/carddav feature. You may encounter issues when dealing with your calendar or address book." + + # Remove lines about .well-known/carddav and caldav with sed. + sed --in-place --regexp-extended '/^location = \/\.well\-known\/(caldav|carddav) \{/,/\}/d' "../conf/nginx.conf" +fi + +# Create a dedicated NGINX config +ynh_add_nginx_config #================================================= # SPECIFIC SETUP diff --git a/scripts/upgrade b/scripts/upgrade index d3f647e..24fa8d3 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -140,6 +140,29 @@ ynh_install_app_dependencies $pkg_dependencies #================================================= # STANDARD UPGRADE STEPS +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Making sure dedicated system user exists..." + +# 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 + +# Recreate a dedicated PHP-FPM config +ynh_add_fpm_config --phpversion="$YNH_PHP_VERSION" --usage=$fpm_usage --footprint=$fpm_footprint --package="$extra_php_dependencies" + +# Delete existing ini configuration file (backward compatibility) +if [ -f /etc/php/$YNH_PHP_VERSION/fpm/conf.d/20-$app.ini ]; then + ynh_secure_remove --file=/etc/php/$YNH_PHP_VERSION/fpm/conf.d/20-$app.ini +fi +# Used by ynh_add_nginx_config +phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) + #================================================= # NGINX CONFIGURATION #================================================= @@ -164,28 +187,7 @@ then fi # Create a dedicated NGINX config -ynh_add_nginx_config YNH_PHP_VERSION - -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." - -# 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 - -# Recreate a dedicated PHP-FPM config -ynh_add_fpm_config --phpversion="$YNH_PHP_VERSION" --usage=$fpm_usage --footprint=$fpm_footprint --package="$extra_php_dependencies" - -# Delete existing ini configuration file (backward compatibility) -if [ -f /etc/php/$YNH_PHP_VERSION/fpm/conf.d/20-$app.ini ]; then - ynh_secure_remove --file=/etc/php/$YNH_PHP_VERSION/fpm/conf.d/20-$app.ini -fi +ynh_add_nginx_config #================================================= # SPECIFIC UPGRADE