Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "move to a new domain" + fixes #28

Closed
wants to merge 12 commits into from

Conversation

Gofannon
Copy link

@Gofannon Gofannon commented May 2, 2018

Problem

  • Baikal cannot be moved to a new domain + small fixes

Solution

Solution not perfect !
This is not perfect as for my use case, baikal does not work anymore after moving the app.

  1. on the new domain, nextcloud is already installed and provided the /.well-known/ path.
  2. while moving baikal, it detects that the /.well-known is not free and do not serve it
  3. baikal does no do anything anymore and nextcloud is expected to do all the work
  4. user is not warned about this and cannot know it

Some possible enhancements

Edit 1

PR Status

Obviously, you should really check these affirmations
Work finished. Package_linter & Package_check, basic tests and upgrade from last version OK.
Upgrade tested on a VM and allowed to realise the conflict with nextcloud (see #25)
Could be reviewed and tested.

Validation


Minor decision

  • Upgrade previous version :
  • Code review :
  • Approval (LGTM) :
  • Approval (LGTM) :
  • CI succeeded : Build Status
    When the PR is mark as ready to merge, you have to wait for 3 days before really merge it.

@Gofannon
Copy link
Author

Gofannon commented Sep 3, 2018

Possible to review this forgotten PR @YunoHost-Apps/apps-group ?

It might not me merge right now because of conflit for handling $DOMAIN/.well-known/carddav (See PR for details)

@@ -0,0 +1,130 @@
<?php

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the patch modifications are from an older PR, #24, this part can be ignored for this PR.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure I get it so to be sure, shall I delete these files then ?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's only that you took master instead of testing to work on this PR. So, there's so some commit from a previous PR.
I was just saying that we can ignore that part for this PR.

@@ -64,6 +64,20 @@ ynh_setup_source "$final_path"
# NGINX CONFIGURATION
#=================================================

# Delete current nginx configuration to be able to check if .well-known is already served.
ynh_remove_nginx_config
ynh_app_setting_delete $app "checksum__etc_nginx_conf.d_$domain.d_$app.conf" || true

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, could you please check if the config has been modified by the user before deleting it.
https://github.com/YunoHost/yunohost/blob/unstable/data/helpers.d/filesystem#L285

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took the code from here https://github.com/YunoHost-Apps/nextcloud_ynh/blob/master/scripts/upgrade#L109-L116 and do understand what and why it is needed

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know myself, but it would be good to use the helper ynh_backup_if_checksum_is_different file, in case the admin changed its config file.

scripts/upgrade Outdated
# Handle root path, avoid double slash.
# Temporary fix, in waiting for an upgrade of the helper. (#361)
#path_url_slash_less=${path_url%/}
#ynh_replace_string "__PATH__/" "$path_url_slash_less/" "../conf/nginx.conf"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you adding that ?
This PR, #361, has been merged on September 2017

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad /o, will correct that later

scripts/install Outdated
@@ -70,6 +70,20 @@ 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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess you would write is_url_handled ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well yes... copy pasta

# Replace path in "return" directives
ynh_replace_string "return \([[:digit:]]\{3\}\) $old_path" "return \1 $new_path" "$nginx_conf_path"
# Calculate and store the nginx config file checksum
ynh_store_file_checksum "$nginx_conf_path"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done (did not tried yet)

@maniackcrudelis
Copy link

instead of doing the migration, it might be usuful to deny it in the first place. (See #17)

Sounds like the best thing to do.
Trig an error and explain why it can't be moved to another domain or why it can't be installed.

@Gofannon
Copy link
Author

It was my first code PR, I will rework on it with new helpers and my experience when I will have time.

Thanks for the review and advices

@Gofannon
Copy link
Author

Gofannon commented Nov 2, 2018

Sounds like the best thing to do.
Trig an error and explain why it can't be moved to another domain or why it can't be installed.

In the last commit, I tried to use is_url_handled to verify if Nextcloud is already installed and then exits with an error message. I cannot make it run :/ package_check fails and Baikal cannot be installed. Am i using the helper in a wrong way ?

I do not understand how the helper runs so I created a is_url_handled_custom to dig but it is still unclear. So I committed anyway to be able to share the code and discuss. I might have missed something
helper code

cat package_check/Complete.log
[...]
2018-11-02 20:46:35,690 INFO     yunohost.hook <lambda> - [991.1] + echo 'je suis devant le if'
2018-11-02 20:46:35,690 INFO     yunohost.hook <lambda> - [991.1] je suis devant le if
2018-11-02 20:46:35,690 INFO     yunohost.hook <lambda> - [991.1] + is_url_handled_custom https://sous.domain.tld/.well-known/caldav
2018-11-02 20:46:35,690 INFO     yunohost.hook <lambda> - [991.1] + output=($(curl -k -s -o /dev/null       -w 'x%{redirect_url} %{http_code}' "$1"))
2018-11-02 20:46:35,690 INFO     yunohost.hook <lambda> - [991.1] ++ curl -k -s -o /dev/null -w 'x%{redirect_url} %{http_code}' https://sous.domain.tld/.well-known/caldav
2018-11-02 20:48:46,298 INFO     yunohost.hook <lambda> - [991.1] + local output
2018-11-02 20:48:46,299 INFO     yunohost.hook <lambda> - [991.1] + echo ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
2018-11-02 20:48:46,299 INFO     yunohost.hook <lambda> - [991.1] ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
2018-11-02 20:48:46,299 INFO     yunohost.hook <lambda> - [991.1] + echo 'contenu variable '\''output'\'' : x'
2018-11-02 20:48:46,300 INFO     yunohost.hook <lambda> - [991.1] contenu variable 'output' : x
2018-11-02 20:48:46,300 INFO     yunohost.hook <lambda> - [991.1] + echo ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
2018-11-02 20:48:46,300 INFO     yunohost.hook <lambda> - [991.1] ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
2018-11-02 20:48:46,300 WARNING  yunohost.hook <lambda> - [991.1] 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://sous.domain.tld/.well-known/caldav). You can either install Baikal on another domain, subdomain or move Nextcloud to another location
2018-11-02 20:48:46,300 INFO     yunohost.hook <lambda> - [991.1] + [[ ! x =~ /yunohost/sso/ ]]
2018-11-02 20:48:46,300 WARNING  yunohost.hook <lambda> - [991.1] !!
2018-11-02 20:48:46,301 INFO     yunohost.hook <lambda> - [991.1] + [[ 000 != 404 ]]
2018-11-02 20:48:46,301 WARNING  yunohost.hook <lambda> - [991.1]   baikal's script has encountered an error. Its execution was cancelled.
2018-11-02 20:48:46,301 INFO     yunohost.hook <lambda> - [991.1] + echo 'je passe dans le if'
2018-11-02 20:48:46,301 WARNING  yunohost.hook <lambda> - [991.1] !!
2018-11-02 20:48:46,301 INFO     yunohost.hook <lambda> - [991.1] je passe dans le if
2018-11-02 20:48:46,301 WARNING  yunohost.hook <lambda> - [991.1]
2018-11-02 20:48:46,301 INFO     yunohost.hook <lambda> - [991.1] + 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://sous.domain.tld/.well-known/caldav). You can either install Baikal on another domain, subdomain or move Nextcloud to another location'
2018-11-02 20:48:46,301 INFO     yunohost.hook <lambda> - [991.1] + echo '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://sous.domain.tld/.well-known/caldav). You can either install Baikal on another domain, subdomain or move Nextcloud to another location'
2018-11-02 20:48:46,301 INFO     yunohost.hook <lambda> - [991.1] + exit 1
2018-11-02 20:48:46,301 INFO     yunohost.hook <lambda> - [991.1] + ynh_exit_properly
2018-11-02 20:48:46,301 INFO     yunohost.hook <lambda> - [991.1] + local exit_code=1
2018-11-02 20:48:46,301 INFO     yunohost.hook <lambda> - [991.1] + '[' 1 -eq 0 ']'
2018-11-02 20:48:46,302 INFO     yunohost.hook <lambda> - [991.1] + trap '' EXIT
2018-11-02 20:48:46,302 INFO     yunohost.hook <lambda> - [991.1] + set +eu
2018-11-02 20:48:46,302 INFO     yunohost.hook <lambda> - [991.1] + echo -e '!!\n  baikal'\''s script has encountered an error. Its execution was cancelled.\n!!'
2018-11-02 20:48:46,302 INFO     yunohost.hook <lambda> - [991.1] + type -t ynh_clean_setup
2018-11-02 20:48:46,302 INFO     yunohost.hook <lambda> - [991.1] + ynh_die
[...]

@maniackcrudelis
Copy link

I'm not sure to understand the problem you have with this helper. I just tried it, it seems to work as expected.
Anyway, I'm going to rewrite it and commit as a third helper in this PR, in order to have a simpler version of the helper. More comprehensible...

A simpler version of the helper, without the array and with more comments.
@maniackcrudelis
Copy link

maniackcrudelis commented Dec 3, 2018

Please try with this new helper.
If it's easier for you to work with this one, please upgrade the helper in the experimental repository, or tell me to do so.

scripts/install Outdated
@@ -70,6 +70,22 @@ ynh_setup_source "$final_path"
# NGINX CONFIGURATION
#=================================================

# 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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might want to remove those debug messages :D

@alexAubin
Copy link
Member

Bump guys, just passing by to say that I'm interested in seeing this PR merged because an user had this issue today about trying to install Baikal while Nextcloud was installed 😅

@Gofannon
Copy link
Author

Gofannon commented Feb 6, 2019

Hello there,

I used the new helper provided by @maniackcrudelis and did some tests but could not totally test the PR. Package_check could not install baikal so I tested directly on a VM.

On the VM, if nextcloud is already installed, baikal cannot be installed so this part is okay. Issue is that baikal does not work on my VM... There is an nginx error about php in the logs but the config files are identical on my production server and on the VM. So I give up on this.

My VM could also be in a poor state as I have removed a lot of applications in order to test baikal / nextcloud.

@maniackcrudelis
Copy link

Looks good to me
But looks like the CI disagree with me...

@maniackcrudelis
Copy link

Ok, I investigated a little this strange helper. (I love when the code is clear and without ambiguities...)
So it appears that when you use package_check, trying to reach https://${domain}/.well-known/caldav gets you to https://${domain}/yunohost/admin, and when you're doing the same things from a raw YNH, you get https://${domain}/yunohost/sso.
From the original helper,

It's handled if it does not redirect to the SSO nor return 404

Which means probably that the new helper should return 0 instead of 1.
[...]
I'm not even sure now...
I've installed nextcloud, now I get https://${domain}/nextcloud/remote.php/dav and the install crashes.

Ok, let's recap:

  • Without nextcloud:
    • With package_check, .well-known redirect to https://${domain}/yunohost/admin
      • It fails both with is_url_handled_rewrited and is_url_handled.
        It shouldn't though...
    • Without package_check, .well-known redirect to https://${domain}/yunohost/sso
      • It fails with is_url_handled_rewrited
      • But it works with is_url_handled
        It should work here as well.
  • With nextcloud now:
    • Didn't try with package_check, but not relevant I think anyway.
    • Without package_check, .well-known redirect to https://${domain}/nextcloud/remote.php/dav and fails with both helpers.
      That's the expected behavior.

Currently, is_url_handled_rewrited return 1 only for a 404 or the sso. Is it logical ?
Shit... why do we have to handle that kind of shitty code without explanation...

So I think that, if we have the sso, the admin or 404 (do we really can expect a 404 !?) we should consider that's fine. If we have something else than that, that would means an app has answered the request.

@maniackcrudelis
Copy link

This PR is quite old.
I fixed the "well-known" issue with this PR #34
And added a change_url script by this other one, #35

This PR can be closed.

@Gofannon
Copy link
Author

Gofannon commented May 6, 2019

Alright !

@Gofannon Gofannon closed this May 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants