Commit e65e03b8 authored by anarcat's avatar anarcat Committed by anarcat

simplify the MySQL credentials handling

instead of creating a root user just for aegir, prompt the user for the
mysql root password. there's one on all MySQL server, and it will work
everywhere. people that have crazy configs can customize the user/pass
used by passing the right flags to hostmaster-install.

this shouldn't change anything for existing users, that already have a
proper root user and should work fine for new users, depending on their
local configuration, for which we can't do much anyways.
parent 23d6c544
......@@ -14,8 +14,12 @@ function drush_provision_hostmaster_install($site = NULL) {
$platform = drush_get_option(array('r', 'root'), $aegir_root . '/' . 'hostmaster-' . $version);
$aegir_host = drush_get_option('aegir_host', php_uname('n'), 'options');
$aegir_db_pass = drush_get_option('aegir_db_pass', 'pass', 'options');
$aegir_db_user = drush_get_option('aegir_db_user', 'aegir_root', 'options');
$aegir_db_user = drush_get_option('aegir_db_user', 'root', 'options');
$aegir_db_pass = drush_get_option('aegir_db_pass', NULL, 'options');
if (!$aegir_db_pass) {
$aegir_db_pass = drush_prompt(dt('MySQL privileged user password ("!root")', array('!root' => $aegir_db_user)));
}
$master_db = sprintf("mysql://%s:%s@%s",$aegir_db_user, $aegir_db_pass, $aegir_host);
// TODO: support creation of an external db server
......
......@@ -77,27 +77,6 @@ if [ `whoami` = "root" ] ; then
exit 1
fi
_RESOLVEIP=`resolveip $AEGIR_HOST 2> /dev/null`
if [ -z "$_RESOLVEIP" ] ; then
msg "This server does not have a hostname that resolves to an IP address"
exit 1
else
AEGIR_HOST_IP=`echo $_RESOLVEIP | cut -d: -f2 | awk '{ print $6}'`
true
fi
_MYSQLTEST=`mysql -h$AEGIR_HOST_IP -uINVALIDLOGIN -pINVALIDPASS 2>&1 >/dev/null | cat`
if [ -z `echo $_MYSQLTEST | grep -q "ERROR \(2003\|1130\)"` ] ; then
msg "MySQL is listening on $AEGIR_HOST_IP."
true
else
msg "MySQL is not configured to listen on $AEGIR_HOST_IP."
exit 1
fi
msg "This script makes the following assumptions: "
cat <<EOF
* you have read INSTALL.txt and prepared the platform accordingly
* you are executing this script as your "aegir" user
......@@ -110,25 +89,6 @@ else
exit 1
fi
AEGIR_DB_USER=aegir_root
AEGIR_DB_PASS=`echo $RANDOM:\`date\`:$AEGIR_HOST | openssl md5 | sed -e 's/(stdin)= //;'`
msg "Aegir will now generate a mysql super user password for you: "
cat <<EOF
Username : $AEGIR_DB_USER
Password : $AEGIR_DB_PASS
Hostname : $AEGIR_HOST ($AEGIR_HOST_IP)
You will be asked to enter your mysql root user password now :
EOF
mysql -uroot -p mysql<<EOFMYSQL
GRANT ALL PRIVILEGES ON *.* TO '$AEGIR_DB_USER'@'$AEGIR_HOST' IDENTIFIED BY '$AEGIR_DB_PASS' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO '$AEGIR_DB_USER'@'$AEGIR_HOST_IP' IDENTIFIED BY '$AEGIR_DB_PASS' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO '$AEGIR_DB_USER'@'localhost' IDENTIFIED BY '$AEGIR_DB_PASS' WITH GRANT OPTION;
EOFMYSQL
# we need to check both because some platforms (like SunOS) return 0 even if the binary is not found
if which drush 2> /dev/null && which drush | grep -v 'no drush in' > /dev/null; then
msg "Drush is in the path, good"
......@@ -168,4 +128,4 @@ else
fi
msg "Installing the frontend"
$DRUSH hostmaster-install --aegir_host=$AEGIR_HOST --aegir_db_user=$AEGIR_DB_USER --aegir_db_pass=$AEGIR_DB_PASS --version=$AEGIR_VERSION $@
$DRUSH hostmaster-install --version=$AEGIR_VERSION $@
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment