From 5d0436199b1675b60d99d8d39ee2f1ac52f1df5f Mon Sep 17 00:00:00 2001 From: Kayou Date: Tue, 24 Mar 2020 20:56:04 +0100 Subject: [PATCH 1/4] fix caldav/carddav detection --- scripts/upgrade | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index bcc8182..0f0da06 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -151,9 +151,11 @@ ynh_script_progression --message="Upgrading nginx web server configuration..." - ynh_backup_if_checksum_is_different --file="/etc/nginx/conf.d/$domain.d/$app.conf" # Delete current nginx configuration to be able to check if .well-known is already served. -ynh_remove_nginx_config $YNH_PHP_VERSION +ynh_remove_nginx_config ynh_app_setting_delete --app=$app --key="checksum__etc_nginx_conf.d_$domain.d_$app.conf" +ynh_systemd_action --service_name=nginx --action=reload + # 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 From 02554f94e5065a9a8c7d4e50d366a5f8f7eb4242 Mon Sep 17 00:00:00 2001 From: Kayou Date: Tue, 24 Mar 2020 21:13:51 +0100 Subject: [PATCH 2/4] Update _common.sh --- scripts/_common.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/_common.sh b/scripts/_common.sh index 7b84705..47253f1 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -38,6 +38,9 @@ is_url_handled() { # Manage arguments with getopts ynh_handle_getopts_args "$@" + # Wait untils nginx has fully reloaded (avoid curl fail with http2) + sleep 2 + # Try to get the url with curl, and keep the http code and an eventual redirection url. local curl_output="$(curl --insecure --silent --output /dev/null \ --write-out '%{http_code};%{redirect_url}' https://127.0.0.1$path --header "Host: $domain" --resolve $domain:443:127.0.0.1)" From d1a2528c43d63760874256d57bca3670b789c39a Mon Sep 17 00:00:00 2001 From: Kay0u Date: Wed, 25 Mar 2020 01:22:21 +0100 Subject: [PATCH 3/4] Move sleep --- scripts/_common.sh | 3 --- scripts/upgrade | 5 ++++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 47253f1..7b84705 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -38,9 +38,6 @@ is_url_handled() { # Manage arguments with getopts ynh_handle_getopts_args "$@" - # Wait untils nginx has fully reloaded (avoid curl fail with http2) - sleep 2 - # Try to get the url with curl, and keep the http code and an eventual redirection url. local curl_output="$(curl --insecure --silent --output /dev/null \ --write-out '%{http_code};%{redirect_url}' https://127.0.0.1$path --header "Host: $domain" --resolve $domain:443:127.0.0.1)" diff --git a/scripts/upgrade b/scripts/upgrade index 0f0da06..9045c6f 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -146,7 +146,7 @@ ynh_install_php --phpversion="$YNH_PHP_VERSION" --package="$extra_pkg_dependenci #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading nginx web server configuration..." --weight=2 +ynh_script_progression --message="Upgrading nginx web server configuration..." --weight=3 ynh_backup_if_checksum_is_different --file="/etc/nginx/conf.d/$domain.d/$app.conf" @@ -156,6 +156,9 @@ ynh_app_setting_delete --app=$app --key="checksum__etc_nginx_conf.d_$domain.d_$a ynh_systemd_action --service_name=nginx --action=reload +# Wait untils nginx has fully reloaded +sleep 1 + # 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 From 2d1e0c0c44ba8aecee8a85e46db4bd27484c97bc Mon Sep 17 00:00:00 2001 From: Kay0u Date: Wed, 25 Mar 2020 13:59:01 +0100 Subject: [PATCH 4/4] wait nginx --- scripts/upgrade | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 9045c6f..95ba8fc 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -146,7 +146,7 @@ ynh_install_php --phpversion="$YNH_PHP_VERSION" --package="$extra_pkg_dependenci #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading nginx web server configuration..." --weight=3 +ynh_script_progression --message="Upgrading nginx web server configuration..." --weight=2 ynh_backup_if_checksum_is_different --file="/etc/nginx/conf.d/$domain.d/$app.conf" @@ -154,10 +154,8 @@ ynh_backup_if_checksum_is_different --file="/etc/nginx/conf.d/$domain.d/$app.con ynh_remove_nginx_config ynh_app_setting_delete --app=$app --key="checksum__etc_nginx_conf.d_$domain.d_$app.conf" -ynh_systemd_action --service_name=nginx --action=reload - # Wait untils nginx has fully reloaded -sleep 1 +ynh_systemd_action --service_name=nginx --action=reload --line_match="Reloaded" --log_path="systemd" # 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"