I was setting up this server with a local interface (eth1) listening on (say) 10.0.0.1 and I forgot to change my "bind-address" in MySQL so that it listens on that interface, yet the install script happily told me:

master:~$ sh install.sh.txt aegir.master.koumbit.net
==> Aegir HEAD automated install script
==> MySQL is listening on 10.0.0.1.

... so there's clearly something wrong here, either in the wording of that message or in the test.

CommentFileSizeAuthor
#7 894004.patch1.38 KBmig5

Comments

anarcat’s picture

Priority: Normal » Critical
Anonymous’s picture

The error is being lost in the redirection to /dev/null

_MYSQLTEST=`mysql -h$AEGIR_HOST_IP  -uINVALIDLOGIN  -pINVALIDPASS 2>&1 >/dev/null | cat`

Remove the 2>&1 and I think that'll be enough to fix, no?

Mig

anarcat’s picture

well, we'd see the error, but we're supposed to *catch* it too...

anarcat’s picture

In my opinion, this should be done in PHP, so that we have better error feedback.

Anonymous’s picture

So I have a mysql_connect in install.hostmaster.inc, is there a better drush command to do this (without it trying to bootstrap Drupal)?

It outputs and dies but I suppose the error isn't pretty, and I don't understand the quote() errors from provision's db.drush.inc that we always see when something goes wrong


aegir:~#  su -s /bin/sh aegir -c "sh install.sh.txt aegir.mig5-forge.net"
==> Aegir HEAD automated install script
==> This script makes the following assumptions: 
 * you have read INSTALL.txt and prepared the platform accordingly
 * you are executing this script as your "aegir" user
Do you want to proceed with the install? [Y/n] 
==> Aegir will now generate a mysql super user password for you: 
  Username : aegir_root
  Password : 80ff5221b9809ab8115710db9c569586
  Hostname : aegir (173.203.100.185)

You will be asked to enter your mysql root user password now :
Enter password: 
==> Drush found in /var/aegir/drush/drush.php, good
==> Drush seems to be functioning properly
==> Provision already seems to be installed
==> Installing the frontend
mysql_connect(): Lost connection to MySQL server at 'reading initial communication packet', system error: 111 install.hostmaster.inc:29                                                [warning]
Could not connect to DB server: Lost connection to MySQL server at 'reading initial communication packet', system error: 111                                                           [error]
The external command could not be executed due to an application error.                                                                                                                [error]
SQLSTATE[HY000] [2003] Can't connect to MySQL server on 'aegir' (111)                                                                                                                  [error]
Drush command could not be completed.                                                                                                                                                  [error]
Output from failed command :                                                                                                                                                           [error]
 
Fatal error: Call to a member function quote() on a non-object in /var/aegir/.drush/provision/db/db.drush.inc on line 322

An error occurred at function : drush_provision_hostmaster_install                                                                                                                     [error]
adrian’s picture

we use PDO

Anonymous’s picture

Status: Active » Needs review
StatusFileSize
new1.38 KB

Sorry brain fart.

How do we feel about this. I am just blatantly hardcoding mysql as the dbtype here, for the time being, tell me if it could be more elegant.

I guess the other awkward thing is we make the superuser grants in the install.sh script, which might also fail there and press on - but we don't set the --host in those mysql commands, maybe we'd get away with it in most cases..

Example output

aegir:~#  su -s /bin/sh aegir -c "sh install.sh.txt aegir.mig5-forge.net --client_email=miguel.jacq@gmail.com"
==> Aegir HEAD automated install script
==> This script makes the following assumptions: 
 * you have read INSTALL.txt and prepared the platform accordingly
 * you are executing this script as your "aegir" user
Do you want to proceed with the install? [Y/n] 
==> Aegir will now generate a mysql super user password for you: 
  Username : aegir_root
  Password : 61ee02ddbc8441ff4e090s99339f5551
  Hostname : aegir (173.203.100.185)

You will be asked to enter your mysql root user password now :
Enter password: 
==> Drush found in /var/aegir/drush/drush.php, good
==> Drush seems to be functioning properly
==> Provision already seems to be installed
==> Installing the frontend
SQLSTATE[HY000] [2003] Can't connect to MySQL server on 'aegir' (111)                                                                                                                  [error]
An error occurred at function : drush_provision_hostmaster_install                                                                                                                     [error]
anarcat’s picture

I think you shouldn't use the PDO primitives directly, but rather work with the server object. So you want something like this:

--- a/install.hostmaster.inc
+++ b/install.hostmaster.inc
@@ -42,6 +42,7 @@ function drush_provision_hostmaster_install($site = NULL) {
     'db_service_type' => 'mysql',
     'master_db' => $data['master_db'],
   ));
+  d($server)->grant("...");
   provision_backend_invoke($server, 'provision-verify');

   // exit if an error has occured.

Problem is then you end up with a chicken and egg problem: you can't grant credentials before the db server has been created!

I think our whole approach is flawed here anyways: why are we creating a *new* root user in the first place?! We're asking for root credentials... why not just use that? They should be working, otherwise we can't create the GRANTs anyways!!

So I have created a branch that does just that: it just rips out the grant creation code from install.sh. It also makes hostmaster-install default to "root" instead of "aegir-root" and will prompt the user for a password if missing. This looks something like this:

$ drush hostmaster-install
Aegir domain name [aegir.example.com]:
Project drush_make (6.x-2.0-beta9) downloaded to /home/anarcat/.drush/drush_make.                                                                             [success]
MySQL privileged user ("root") password:

Maybe the order here is a little wrong but that's not the point. My idea here is to simplify the install.sh to the extreme, so that only very junior users will need it (ie. users that can't download drush and provision themselves).

I am assuming here a lot of people already have drush and can handle downloading one extra package. We could simplify the INSTALL.txt to this:

1. download drush
2. drush dl provision --destination ~/.drush/provision
3. drush hostmaster-install

Everything else is prompted. This way, we could even get totally rid of install.sh (which I recommend, actually).

This code is up on the dev-simplerinstaller branch in git:

http://git.aegirproject.org/?p=provision.git;a=shortlog;h=refs/heads/dev...

... for your review.

anarcat’s picture

So here's what the complete output looks like:

anarcat@angela:provision$ drush hostmaster-install
Aegir HEAD automated install script
==============================================================================

This script will operate the following changes in your system:

1. Create server-level configuration directories
2. Download drush_make
3. Create the Hostmaster frontend platform
4. Install the frontend site
5. Setup the dispatcher (a user cron job)

We are making the following assumptions:
 * you have read INSTALL.txt and prepared the platform accordingly
 * you are executing this script as your "aegir" user

Do you really want to proceed with the install [Y/n]: y
Aegir domain name [aegir.example.com]: aegir.anarcat.ath.cx
MySQL privileged user ("root") password:
The external command could not be executed due to an application error.                                                                                       [error]
SQLSTATE[HY000] [2003] Can't connect to MySQL server on 'angela' (111)                                                                                        [error]
Drush command could not be completed.                                                                                                                         [error]
Output from failed command :                                                                                                                                  [error]

Fatal error: Call to a member function quote() on a non-object in /home/anarcat/src/provision/db/db.drush.inc on line 322

An error occurred at function : drush_provision_hostmaster_install                                                                                            [error]

Of course that quote() error is horrible and should be destroyed, but we need to fix that anyways. Obviously, the above is a failed call: the mysql server is down...

Anonymous’s picture

Somehow in my previous patch there, I avoided the quote() weird shit, in the way I caught the exception in PDO. It was very clean, maybe something similar needs to be done here (disclaimer: i haven't actually read your modified code here yet)

I don't disagree with anything that's been said here. I do want you guys to be aware that the switching *back* to the old method of saying in the INSTALL.txt to manually download drush and provision will alienate some users (we switched to the install.sh.txt to try and avoid that 'human error' here), it is likely to result in a lot more support requests.

Why, just because of having to download two packages manually first?

Yes, that really is a big hurdle for some users, we learnt that in the 0.3 days.

All the same, both methods work, so why not.

anarcat’s picture

Actually, if you look at the diff with master on that branch, I do update the INSTALL.txt and tell people to manually drush and provision *but* also leave the install.sh instructions in to help them with that.

My objective with 0.4 is to start providing packages for the big three (APT, RPM and... fink?) so that drush and provision are effectively installed automatically. From there INSTALL.txt is actually already installed alongside with provision and we don't even *need* to tell people how to download the thing and install it: that's done for them, and is outside the scope.

Of course while we wait for that to magically happen (ouch), install.sh still has its place.

As for the ugly quote() error, I think this should be caught beforehand and handled better. I've seen that error message elsewhere and it should be fixed because it doesn't say *anything*.

anarcat’s picture

Title: install.sh lies about mysql listen » install.sh lies about mysql listen AKA move the mysql creds handling to hostmaster-install

So this grew way beyond what I was expecting, but I think it's now much nicer.

After installing this on my laptop, I'm confident that it works better than what we had before, so I merged this into head:

anarcat@angela:provision$ git merge dev-simplerinstaller
Updating 929f615..3209086
Fast-forward
 docs/INSTALL.txt       |   36 ++++++++++++--
 install.hostmaster.inc |  127 ++++++++++++++++++++++++++++++++++++++++--------
 install.sh.txt         |   85 ++------------------------------
 3 files changed, 143 insertions(+), 105 deletions(-)

You have seen how a failed install behaves, this is a successful install in all its beauty:

aegir@angela:~$ drush hostmaster-install aegir.angela.anarcat.ath.cx --aegir_host=angela.anarcat.ath.cx --client_email=anarcat@anarcat.ath.cx
Aegir HEAD automated install script
==============================================================================
Some settings have not been guessed and will now be prompted.
Don't worry: you will get to review those settings after the final install
MySQL privileged user ("root") password:

This script will operate the following changes in your system:

1. Create server-level configuration directories
2. Download drush_make
3. Create the Hostmaster frontend platform
4. Install the frontend site
5. Setup the dispatcher (a user cron job)

We are making the following assumptions:
 * you have read INSTALL.txt and prepared the platform accordingly
 * the FQDN of this machine is valid and resolves
 * you are executing this script as your "aegir" user

The following settings will be used:
 Aegir frontend URL: aegir.angela.anarcat.ath.cx
 Master server: angela.anarcat.ath.cx
 Aegir root: /var/aegir
 Aegir user: aegir
 Web group: www-data
 Web server: apache
 Aegir DB user: root
 Aegir DB password: <prompted>
 Drush make version: 6.x-2.0-beta9
 Aegir version: HEAD
 Aegir platform path: /var/aegir/hostmaster-HEAD
 Aegir makefile: /var/aegir/.drush/provision/aegir.make
 Client email: anarcat@anarcat.ath.cx

Do you really want to proceed with the install (y/n): y
Project information for drupal retrieved.                                                                                                                     [ok]
drupal downloaded from http://ftp.drupal.org/files/projects/drupal-6.19.tar.gz.                                                                               [ok]
hostmaster cloned from git://git.aegirproject.org/hostmaster.git.                                                                                             [ok]
Found makefile: hostmaster.make                                                                                                                               [ok]
Project information for admin_menu retrieved.                                                                                                                 [ok]
Project information for openidadmin retrieved.                                                                                                                [ok]
Project information for install_profile_api retrieved.                                                                                                        [ok]
Project information for jquery_ui retrieved.                                                                                                                  [ok]
Project information for modalframe retrieved.                                                                                                                 [ok]
admin_menu downloaded from http://ftp.drupal.org/files/projects/admin_menu-6.x-1.6.tar.gz.                                                                    [ok]
openidadmin downloaded from http://ftp.drupal.org/files/projects/openidadmin-6.x-1.2.tar.gz.                                                                  [ok]
install_profile_api downloaded from http://ftp.drupal.org/files/projects/install_profile_api-6.x-2.1.tar.gz.                                                  [ok]
jquery_ui downloaded from http://ftp.drupal.org/files/projects/jquery_ui-6.x-1.3.tar.gz.                                                                      [ok]
modalframe downloaded from http://ftp.drupal.org/files/projects/modalframe-6.x-1.6.tar.gz.                                                                    [ok]
jquery_ui downloaded from http://jquery-ui.googlecode.com/files/jquery.ui-1.6.zip.                                                                            [ok]
Created aegirangelaanarc database                                                                                                                             [success]
Initializing the hosting system
Dispatch command was run successfully                                                                                                                         [success]
Your existing cron entry will be replaced.                                                                                                                    [warning]
This command will replace your crontab for this user. continue? (y/n): y
/usr/share/drush/drush.php '@hostmaster' hosting-dispatch
Aegir is now installed. You can visit it at http://aegir.angela.anarcat.ath.cx/user/reset/1/1288360351/b850fa7ab7b73a23601dbde838985b31

Note that I passed the FQDN and the email on the commandline just to avoid getting prompted for it.

The only thing that's missing right now is that this will wipe existing aliases in .drush: maybe we want to persist the answers across invocations?

anarcat’s picture

Status: Needs review » Fixed

merged on head, I'm satisfied this is fixed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.