From 7d2d0cdbb150d186e807d7de004412ccff5d900c Mon Sep 17 00:00:00 2001 From: Gofannon <17145502+Gofannon@users.noreply.github.com> Date: Fri, 2 Nov 2018 20:43:56 +0100 Subject: [PATCH] [WIP] attempt to fix conflit with nextcloud --- scripts/_common.sh | 14 +++++++++++++- scripts/change_url | 11 +++++++++++ scripts/install | 14 ++++++++------ 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 3dfc879..ef72266 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -13,6 +13,18 @@ is_url_handled() { [[ ! ${output[0]} =~ \/yunohost\/sso\/ && ${output[1]} != 404 ]] } +is_url_handled_custom() { + local output=($(curl -k -s -o /dev/null \ + -w 'x%{redirect_url} %{http_code}' "$1")) + echo "¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤" + echo "contenu variable 'output' : $output" + echo "¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤" + # It's handled if it does not redirect to the SSO nor return 404 + [[ ! ${output[0]} =~ \/yunohost\/sso\/ && ${output[1]} != 404 ]] + #[[ ! ${output[0]} =~ \/yunohost\/sso\/ ]] && [[ ${output[1]} != 404 ]] + #[[ ! ${output[0]} =~ \/yunohost\/sso\/ ]] +} + # ============= FUTURE YUNOHOST HELPER ============= # Delete a file checksum from the app settings # @@ -23,4 +35,4 @@ is_url_handled() { ynh_delete_file_checksum () { local checksum_setting_name=checksum_${1//[\/ ]/_} # Replace all '/' and ' ' by '_' ynh_app_setting_delete $app $checksum_setting_name -} +} \ No newline at end of file diff --git a/scripts/change_url b/scripts/change_url index 5dfa38b..ccf2f32 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -41,6 +41,17 @@ test -n "$new_path" || new_path="/" new_path=$(ynh_normalize_url_path $new_path) old_path=$(ynh_normalize_url_path $old_path) +#================================================= +# CHECK IF THE APP CAN BE MOVED WITH THESE ARGS +#================================================= + +# FIXME Does not work as expected for now (See install script) +# Exits if another app serves "https://${domain}/.well-known/caldav" and display an error message for user +# Waiting for Yunohost to handles this kind of conflict https://github.com/YunoHost-Apps/baikal_ynh/issues/17 +if is_url_handled "https://${domain}/.well-known/caldav" ; then + ynh_die "Baikal cannot be installed because of a conflit with another application, Nextcloud usually. This app handles the location where you want to install Baikal (https://${domain}/.well-known/caldav). You can either install Baikal on another domain, subdomain or move Nextcloud to another location" +fi + #================================================= # CHECK WHICH PARTS SHOULD BE CHANGED #================================================= diff --git a/scripts/install b/scripts/install index a34abf5..2ac648a 100644 --- a/scripts/install +++ b/scripts/install @@ -6,7 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= -source ./_common.sh +source _common.sh source /usr/share/yunohost/helpers #================================================= @@ -70,10 +70,12 @@ ynh_setup_source "$final_path" # NGINX CONFIGURATION #================================================= -# Do not serve .well-known if it's already served on the domain -if https://github.com/YunoHost-Apps/nextcloud_ynh/blob/962cc61ec8ffb045d89dd460cf8b55778d862ffc/scripts/install "https://${domain}/.well-known/caldav" ; then - sed -ri '/^location = \/\.well\-known\/(caldav|carddav) \{/,/\}/d' \ - "../conf/nginx.conf" +# Exits if another app serves "https://${domain}/.well-known/caldav" and display an error message for user +# Waiting for Yunohost to handles this kind of conflict https://github.com/YunoHost-Apps/baikal_ynh/issues/17 +echo "je suis devant le if" +if is_url_handled_custom "https://${domain}/.well-known/caldav" ; then + echo "je passe dans le if" + ynh_die "Baikal cannot be installed because of a conflit with another application, Nextcloud usually. This app handles the location where you want to install Baikal (https://${domain}/.well-known/caldav). You can either install Baikal on another domain, subdomain or move Nextcloud to another location" fi # Taken from https://github.com/YunoHost-Apps/nextcloud_ynh/blob/962cc61ec8ffb045d89dd460cf8b55778d862ffc/scripts/install @@ -167,4 +169,4 @@ ynh_app_setting_set "$app" protected_uris "/admin/" # RELOAD NGINX #================================================= -systemctl reload nginx +systemctl reload nginx \ No newline at end of file