From 8ab06e7bd0af416da2b922a5d360e43c2577bb10 Mon Sep 17 00:00:00 2001 From: Kay0u Date: Wed, 11 Mar 2020 11:35:25 +0100 Subject: [PATCH 1/4] trying to fix ci --- scripts/_common.sh | 8 +++++--- scripts/change_url | 2 +- scripts/install | 2 +- scripts/restore | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 93323b9..a10ebe6 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -15,14 +15,16 @@ pkg_dependencies="php-xml php-mbstring php-mysql" # usage: is_url_handled URL is_url_handled() { # Declare an array to define the options of this helper. - declare -Ar args_array=( [u]=url= ) - local url + local legacy_args=dp + declare -Ar args_array=( [d]=domain= [p]=path= ) + local domain + local path # Manage arguments with getopts ynh_handle_getopts_args "$@" # 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}' "$url")" + --write-out '%{http_code};%{redirect_url}' https://127.0.0.1$path --header "Host: $domain")" # Cut the output and keep only the first part to keep the http code local http_code="${curl_output%%;*}" diff --git a/scripts/change_url b/scripts/change_url index 4cb7436..f163eed 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -52,7 +52,7 @@ fi if [ $change_domain -eq 1 ] then # Check if .well-known is available for the new domain. - if is_url_handled "https://$new_domain/.well-known/caldav" || is_url_handled "https://$new_domain/.well-known/carddav" + if is_url_handled "$new_domain" "/.well-known/caldav" || is_url_handled "$new_domain" "/.well-known/carddav" then ynh_die --message="Another app already uses the domain $new_domain to serve a caldav/carddav feature. Please use another domain." fi diff --git a/scripts/install b/scripts/install index 8b145ac..5ed3705 100644 --- a/scripts/install +++ b/scripts/install @@ -38,7 +38,7 @@ test ! -e "$final_path" || ynh_die "This path already contains a folder" ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url # Check if .well-known is available for this domain. -if is_url_handled "https://$domain/.well-known/caldav" || is_url_handled "https://$domain/.well-known/carddav" +if is_url_handled "$domain" "/.well-known/caldav" || is_url_handled "$domain" "/.well-known/carddav" then ynh_die --message="Another app already uses the domain $domain to serve a caldav/carddav feature. Please use another domain." fi diff --git a/scripts/restore b/scripts/restore index 9a07854..c289d06 100644 --- a/scripts/restore +++ b/scripts/restore @@ -39,7 +39,7 @@ test ! -d $final_path \ || ynh_die --message="There is already a directory: $final_path " # Check if .well-known is available for this domain. -if is_url_handled "https://$domain/.well-known/caldav" || is_url_handled "https://$domain/.well-known/carddav" +if is_url_handled "$domain" "/.well-known/caldav" || is_url_handled "$domain" "/.well-known/carddav" then ynh_die --message="Another app already uses the domain $domain to serve a caldav/carddav feature. Please use another domain." fi From 12a2e4ef63ecca51c50b4f493c7b6c1e91c4f33c Mon Sep 17 00:00:00 2001 From: Kay0u Date: Fri, 13 Mar 2020 23:01:26 +0100 Subject: [PATCH 2/4] add resolve parameter --- scripts/_common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index a10ebe6..903e79a 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -24,7 +24,7 @@ is_url_handled() { # 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")" + --write-out '%{http_code};%{redirect_url}' https://127.0.0.1$path --header "Host: $domain" --resolve $domain:443:127.0.0.1)" # Cut the output and keep only the first part to keep the http code local http_code="${curl_output%%;*}" From ca6db622eb08be3931b64ff728bafb78faa55a26 Mon Sep 17 00:00:00 2001 From: Kay0u Date: Sat, 14 Mar 2020 00:25:37 +0100 Subject: [PATCH 3/4] use getops --- scripts/change_url | 2 +- scripts/install | 2 +- scripts/restore | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index f163eed..e80ce8d 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -52,7 +52,7 @@ fi if [ $change_domain -eq 1 ] then # Check if .well-known is available for the new domain. - if is_url_handled "$new_domain" "/.well-known/caldav" || is_url_handled "$new_domain" "/.well-known/carddav" + if is_url_handled --domain="$new_domain" --path="/.well-known/caldav" || is_url_handled --domain="$new_domain" --path="/.well-known/carddav" then ynh_die --message="Another app already uses the domain $new_domain to serve a caldav/carddav feature. Please use another domain." fi diff --git a/scripts/install b/scripts/install index 5ed3705..d428307 100644 --- a/scripts/install +++ b/scripts/install @@ -38,7 +38,7 @@ test ! -e "$final_path" || ynh_die "This path already contains a folder" ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url # Check if .well-known is available for this domain. -if is_url_handled "$domain" "/.well-known/caldav" || is_url_handled "$domain" "/.well-known/carddav" +if is_url_handled --domain="$domain" --path="/.well-known/caldav" || is_url_handled --domain="$domain" --path="/.well-known/carddav" then ynh_die --message="Another app already uses the domain $domain to serve a caldav/carddav feature. Please use another domain." fi diff --git a/scripts/restore b/scripts/restore index c289d06..930c1b4 100644 --- a/scripts/restore +++ b/scripts/restore @@ -39,7 +39,7 @@ test ! -d $final_path \ || ynh_die --message="There is already a directory: $final_path " # Check if .well-known is available for this domain. -if is_url_handled "$domain" "/.well-known/caldav" || is_url_handled "$domain" "/.well-known/carddav" +if is_url_handled --domain="$domain" --path="/.well-known/caldav" || is_url_handled --domain="$domain" --path="/.well-known/carddav" then ynh_die --message="Another app already uses the domain $domain to serve a caldav/carddav feature. Please use another domain." fi From 61e002ad775469fe953ab3a18557f828fe32c4bb Mon Sep 17 00:00:00 2001 From: Kay0u Date: Sat, 14 Mar 2020 00:31:36 +0100 Subject: [PATCH 4/4] update comments --- scripts/_common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 903e79a..dfc713b 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -12,7 +12,7 @@ pkg_dependencies="php-xml php-mbstring php-mysql" #================================================= # Check if an URL is already handled -# usage: is_url_handled URL +# usage: is_url_handled --domain=DOMAIN --path=PATH_URI is_url_handled() { # Declare an array to define the options of this helper. local legacy_args=dp