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

Clean / improve install script #46

Merged
merged 15 commits into from Mar 8, 2018
Merged

Conversation

alexAubin
Copy link
Member

@alexAubin alexAubin commented Feb 13, 2018

This is an attempt to clean and improve the install script.

In particular, for the following :

  • Simplify the syntax for handling step exception (instead of if ! step foo; then die "bar" fi, just do step foo || die "bar") ;
  • Centralize 'assertions check', such as being on the right debian distribution, to immediately identify problematic situation before running anything else ;
  • Wrap everything in function. This is for defensive bash, but also in the optic of moving to a curl | bash instruction, we need to avoid the case where the curl ends up in the middle of the request, but still dumps half the script and we get weirdly corrupted installs ;
  • Improve message logging cosmetics, and other misc cleaning / reorganization ;
  • Following some user feedback, detect apache2 and bind9 which might be conflict with nginx and dnsmasq. Provide an option to force the install if the user knows what it's doing ;

As discussed in https://dev.yunohost.org/issues/525 , one of the goal is also to move towards a simple curl https://install.yunohost.org | bash install procedure (and provide more cautious instructions for people willing to check integrity / authenticity..). In particular, we should also be able to move step 3 (= check that root has password - not sure why it's necessary) as a check inside the script.

Copy link
Member

@Psycojoker Psycojoker left a comment

Choose a reason for hiding this comment

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

I've read all the commits, apart the bind9 grep everything looks fine for me (and the "keep old log stuff" but that's less important).

Thanks for this significant amount of work in improving the quality of this code 👍

install_yunohost Outdated
@@ -210,6 +216,14 @@ function check_assertions()
if is_raspbian ; then
user_pi_logged_out || die "The user pi should be logged out."
fi

# Check possible conflict with apache, bind9.
[[ -z "$(dpkg --list | grep ' bind9')" ]] || [[ "$FORCE" == "1" ]] \
Copy link
Member

Choose a reason for hiding this comment

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

This one will likely failed because it greps every package that has "bind9" in its name and YunoHost itself requires bind9-utils (for dyndns-keygen used by TSIG). You probably want to do a grep 'bind9 ' (with a space).

Copy link
Member

Choose a reason for hiding this comment

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

This one will likely failed because it greps every package that has "bind9" in its name and YunoHost itself requires bind9-utils (for dyndns-keygen used by TSIG). You probably want to do a grep 'bind9 ' (with a space).

Copy link
Member Author

Choose a reason for hiding this comment

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

Indeed, not sure why but actually in the final diff it's with bind9 (which is probably why github is flagging as outdated) so that should be ok :P

install_yunohost Outdated
parse_options
parse_options "$@"

rm -f $YUNOHOST_LOG
Copy link
Member

Choose a reason for hiding this comment

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

You might want to do a mv + date $YUNOHOST_LOG $YUNOHOST_LOG$(date +%F_%X) instead to keep old logs for debugging.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yea, I was a bit lazy about that but that shouldn't take long to implement, will do x)

Copy link
Member

Choose a reason for hiding this comment

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

okay, once it's done you can merge for me :)

@Psycojoker
Copy link
Member

Ah, so apparently github haven't kept my bind9 comment :|

Copy link
Member

@Psycojoker Psycojoker left a comment

Choose a reason for hiding this comment

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

Review system seems broken when made on several commits.

install_yunohost Outdated
@@ -210,6 +216,14 @@ function check_assertions()
if is_raspbian ; then
user_pi_logged_out || die "The user pi should be logged out."
fi

# Check possible conflict with apache, bind9.
[[ -z "$(dpkg --list | grep ' bind9')" ]] || [[ "$FORCE" == "1" ]] \
Copy link
Member

Choose a reason for hiding this comment

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

This one will likely failed because it greps every package that has "bind9" in its name and YunoHost itself requires bind9-utils (for dyndns-keygen used by TSIG). You probably want to do a grep 'bind9 ' (with a space).

@Psycojoker
Copy link
Member

Also thanks a lot for having taken the time to split this in a lot of commits, this has made the review painless for me and I greatly appreciate it ❤️

@alexAubin
Copy link
Member Author

Fixed the remaining point and tested an install on a VPS with wget | bash: it seems to be working as expected.. (Except that at the end, when attempting to launch the postinstall, it failed, but then launching it manually worked ?)

@Psycojoker
Copy link
Member

Except that at the end, when attempting to launch the postinstall, it failed, but then launching it manually worked ?

That looks weird, but shouldn't we fix that before merging :o?

@alexAubin
Copy link
Member Author

I guess x) I'll have a deeper look

@alexAubin
Copy link
Member Author

So after investigating :

  • this is actually not an issue with the script, but with the way I used it ...
  • turns out that you cant use curl | bash if you expect the script to use stdin, which we do when we run the postinstall (ask the main domain, then password)
  • as described in this stackoverflow thread, an alternative is to use bash <(curl https://url/of/script.sh), which is a bit less elegant...

So, not sure what to do with this... I see those possibilities :

  • keep it as it is right now, but we'll have tell people to either use curl <(bash), or something like curl && source script.sh ;
  • ask for main domain and password with whiptail ;
  • don't attempt to run the postinstall from the install script, just tell the user to run yunohost tools postinstall.

@alexAubin
Copy link
Member Author

Okay I'm merging this as is, since as described, the issue I mentioned is not related to the changes but with the way I did my tests. We can discuss at some point how we want to design the use of this script.

@alexAubin alexAubin merged commit 882ee11 into stretch2 Mar 8, 2018
@alexAubin alexAubin deleted the improve-install-script branch March 8, 2018 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants