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

Merge commit 'provision-0.4-beta2' into prod-koumbit

parents 1da8abb3 aa331d19
......@@ -6,10 +6,11 @@ This is the backend of the Aegir hosting system.
The front end and back end are designed to be run separately, and each
front end will also be able to drive multiple back ends.
The most up to date information regarding the project and its goal
can be found in the Aegir wiki page:
The most up to date information regarding the project and its goals
can be found on the Aegir website and the community portal:
http://groups.drupal.org/aegir/overview
http://aegirproject.org
http://community.aegirproject.org
To install Aegir, you should follow the INSTALL.txt document in docs/.
The HINTS_<arch>.txt files can be useful if you have a specific
......@@ -20,8 +21,8 @@ To upgrade Aegir, follow the UPGRADE.txt document in docs/.
The core of the documentation in docs/ should be sufficient to get you
started. If you have further questions or are having trouble with Aegir,
head for the documentation wiki:
head for the documentation:
http://groups.drupal.org/aegir-hosting-system/documentation
http://community.aegirproject.org/notebook
Other documentation for developpers is also available in docs/.
Other documentation for developers is also available in docs/.
......@@ -4,6 +4,6 @@ api = 2
projects[drupal][type] = "core"
projects[hostmaster][type] = "profile"
projects[hostmaster][download][type] = "git"
projects[hostmaster][download][url] = "git://git.aegirproject.org/hostmaster.git"
projects[hostmaster][download][branch] = "master"
projects[hostmaster][download][type] = "get"
projects[hostmaster][download][url] = "http://files.aegirproject.org/hostmaster-0.4-beta2.tgz"
projects[hostmaster][download][directory_name] = "hostmaster"
......@@ -91,8 +91,10 @@ class provisionService_db extends provisionService {
/**
* Generate a new mysql database and user account for the specified credentials
*/
function create_site_database() {
$creds = $this->generate_site_credentials();
function create_site_database($creds = array()) {
if (!sizeof($creds)) {
$creds = $this->generate_site_credentials();
}
extract($creds);
if (!$this->can_create_database()) {
......@@ -150,12 +152,14 @@ class provisionService_db extends provisionService {
}
function import_site_database($dump_file = null) {
function import_site_database($dump_file = null, $creds = array()) {
if (is_null($dump_file)) {
$dump_file = d()->site_path . '/database.sql';
}
$creds = $this->fetch_site_credentials();
if (!sizeof($creds)) {
$creds = $this->fetch_site_credentials();
}
$exists = provision_file()->exists($dump_file)
->succeed('Found database dump at @path.')
......
......@@ -14,6 +14,8 @@ class provisionService_db_mysql extends provisionService_db_pdo {
}
function database_exists($name) {
// An underscore in a LIKE clause is a single character wildcard, escape it.
$name = str_replace('_', '\_', $name);
$result = $this->query("SHOW DATABASES LIKE '%s'", $name);
if ($result) {
return $result->fetchColumn(0);
......@@ -88,7 +90,7 @@ class provisionService_db_mysql extends provisionService_db_pdo {
}
function grant_host(provisionContext_server $server) {
$command = sprintf('mysql -u intntnllyInvalid -h %s -P %s',
$command = sprintf('mysql -u intntnllyInvalid -h %s -P %s -e ""',
escapeshellarg($this->server->remote_host),
escapeshellarg($this->server->db_port));
......@@ -124,6 +126,13 @@ class provisionService_db_mysql extends provisionService_db_pdo {
* We go through all this trouble to hide the password from the commandline,
* it's the most secure way (apart from writing a temporary file, which would
* create conflicts in parallel runs)
*
* XXX: this needs to be refactored so it:
* - works even if /dev/fd/3 doesn't exit
* - has a meaningful name (we're talking about reading and writing
* dumps here, really, or at least call mysql and mysqldump, not
* just any command)
* - can be pushed upstream to drush (http://drupal.org/node/671906)
*/
function safe_shell_exec($cmd, $db_host, $db_user, $db_passwd, $dump_file = null) {
$mycnf = sprintf('[client]
......@@ -141,6 +150,7 @@ port=%s
2 => array("pipe", "w"), // stderr is a file to write to
3 => array("pipe", "r"), // fd3 is our special file descriptor where we pass credentials
);
$pipes = array();
$process = proc_open($cmd, $descriptorspec, $pipes);
$this->safe_shell_exec_output = '';
if (is_resource($process)) {
......
......@@ -62,7 +62,11 @@ The first two commands below are optional but recommended.
Shell commands::
sudo port selfupdate
sudo port upgrade outdated
sudo port install apache2 mysql5-server git-core unzip php52 +mysql5
sudo port install apache2 mysql5-server git-core unzip php52 php5-posix \
php5-gd php5-apc +mysql5
php5-apc is optional, but highly recommended as it will significantly increase
PHP performance.
Watch the output of the last port command carefully, as there are
usually some boring tasks for you to perform once the install is
......@@ -76,7 +80,13 @@ Next we'll create the aegir user and add it to the _www group. This
part is very different on Mac OS X than Linux or most other
Unices. Must be a NeXTism. The command we will use he is "dscl", which
is a short for Directory Service Command Line. In OSX 10.3 and
earlier, that command is "nicl" (short for Net Info Command Line).
earlier, that command is "nicl" (short for Net Info Command Line). It is also
possible to create the user using the "Workgroup Manager" utility included with
OS X Server. To obtain Workgroup Manager for the OS X Client, download the
"Server Admin Tools" from Apple. For example, for Mac OS X 10.6, the admin tools
can be found at:
http://support.apple.com/downloads/Server_Admin_Tools_10_6
Shell commands::
sudo dscl . -create /Users/aegir NFSHomeDirectory /var/aegir
......
......@@ -51,6 +51,8 @@ The level of access required to be able to configure this system is very far
beyond what is commonly available to users with shared hosting. Commands are
assumed to be run as root user.
A standard umask of 022 is assumed. This is the default on most systems.
Web server
----------
......@@ -78,7 +80,7 @@ Database server
You will require a database server, obviously. Aegir currently only supports
MySQL. It is preferable to use a dedicated server since Aegir will create
database users and will require a privileged user.
database users and will requires the use of the mysql 'root' user.
Mail transfer agent
-------------------
......@@ -233,7 +235,7 @@ Any number of remote web servers may be configured. They need an aegir user and
Apache configuration as above, with the same user name and directory paths. SSH
public/private keys should be set up so hostmaster's Aegir user can access
remote web Aegir users with no passwords. The above apache configuration needs
to be performed to.
to be performed too.
They will also need a login shell, which can be modified using the ``chsh`` command.
......@@ -256,9 +258,9 @@ Now you need to restart mysql, to clear any caches.
Shell command as root::
/etc/init.d/mysql restart
The installer will prompt you for your MySQL root user password. It will
not store this information, but instead use it to generate a new super
user account for the aegir system.
The installer will prompt you for your MySQL root user password. The root
user will be used to make administrative tasks such as creating new databases,
and granting and revoking access to those databases for sites.
Even though MySQL is now listening on all IP's, it will not allow invalid users
to connect to the databases, without the correct user accounts configured.
......@@ -270,15 +272,21 @@ This is outside the scope of this document however.
3. Run the install script
=========================
This section deals with the actual installation of Aegir.
This section deals with the actual installation of Aegir. You can
install aegir in one of two ways: one assumes you have already
downloaded drush and provision, while the other will do that for you.
3.1 Installing aegir with only the install.sh script
----------------------------------------------------
There is an install script that takes care of installing the right packages and
preparing the backend and frontend install for you. That script needs to be run
as the aegir user created above. This file is available in Provision or can be
downloaded through the web with this command::
as the aegir user created above, so it needs to be placed somewhere that the
aegir user can access in order to execute it. This file is available in
Provision or can be downloaded through the web with this command::
Shell commands::
wget -O install.sh 'http://git.aegirproject.org/?p=provision.git;a=blob_plain;f=install.sh.txt;hb=HEAD'
wget -O install.sh 'http://git.aegirproject.org/?p=provision.git;a=blob_plain;f=install.sh.txt;hb=provision-0.4-beta2'
By default, the install script will install the "correct" version of Aegir
(ie. if it was downloaded through git, it will install the version from the
......@@ -287,20 +295,48 @@ the official release.). You can modify which version to install by editing the
AEGIR_VERSION variable in the script.
Shell commands::
su -s /bin/sh aegir -c "sh install.sh aegir.example.com"
su -s /bin/sh aegir -c "sh install.sh"
Note you must run the above command as root or prefix with sudo.
Be sure to change 'aegir.example.com' to match the URI of your site.
You will be prompted for the information necessary to complete the
installation.
Once you have run install.sh once, drush and provision should be
installed and you can use the more powerful hostmaster-install command
to retry the install if it failed the first time.
3.2 Installing aegir with drush and provision installed
-------------------------------------------------------
If you have already downloaded drush and provision, you can just install
provision in the commands directory of Drush (either ~aegir/.drush or
/usr/share/drush/commands), if that's not already done. Once provision
is properly installed, you can install all other aegir components using
the hostmaster-install command.
Shell commands::
drush hostmaster-install --version=HEAD
You will be prompted for the required information if not provided on the
commandline. See the inline help for the available options::
You can append '--client_email=you@example.com' to keep from being prompted for
an e-mail address during install. The traditional Drupal 'Welcome' e-mail will
be sent to this e-mail address upon completion of the installation. This e-mail
address will also be used as the default e-mail address of the first user and
client in Aegir, but can be changed later.
drush help hostmaster-install
It is imperative that you provide a valid FQDN to the installer. This is used
for database GRANTs. Remote web servers depend on the FQDN being resolvable
in order to connect back to your Aegir master server if it is used as your
database server for managed sites.
Upon completion of the installation, the traditional Drupal 'Welcome' e-mail
will be sent to the e-mail address specified by --client_email=(your e-mail)
or if not provided as a command line switch, the address prompted by the
installer process. This e-mail address will also be used as the default e-mail
address of the first user and client in Aegir, but can be changed later.
Checkpoint / Finished!
-----------
----------------------
At this point, you have checked out all the code and setup your basic Drupal
system (Drupal core, hosting, hostmaster and eldir) that will be the Aegir
......
......@@ -35,6 +35,7 @@ To become aegir user you can issue this command::
Note that /bin/sh is an example. You may wish to instead use the shell of your
choice, i.e /bin/bash
A standard umask of 022 is assumed. This is the default on most systems.
Upgrade script
==============
......@@ -50,10 +51,19 @@ the bottom of this document before attempting to run the upgrade.sh script,
as the script will assume you have your system set up appropriately to
handle the upgrade process.
You can download and run the upgrade.sh script with the following.
You can download the upgrade.sh script with the following command.
Make sure you download it to somewhere that the aegir user can access in order
to execute it.
Shell commands::
wget -O upgrade.sh.txt 'http://git.aegirproject.org/?p=provision.git;a=blob_plain;f=upgrade.sh.txt;hb=provision-0.4-beta2'
You may need to edit the script to set any variables that are different from the
defaults. Pay particular attention to the OLD_DRUPAL_DIR variable, as you may be
upgrading from a different release to the default here.
Shell commands::
wget -O upgrade.sh.txt 'http://git.aegirproject.org/?p=provision.git;a=blob_plain;f=upgrade.sh.txt;hb=HEAD'
su -s /bin/sh aegir -c "sh upgrade.sh.txt aegir.example.com"
Remember to replace aegir.example.com with the domain of your Aegir installation.
......@@ -76,13 +86,13 @@ you are reading this document.
Shell commands::
export AEGIR_VERSION=HEAD
export AEGIR_VERSION=0.4-beta2
export AEGIR_DIR=/var/aegir
export DRUPAL_DIR=$AEGIR_DIR/hostmaster-$AEGIR_VERSION
export DRUSH_VERSION=6.x-3.3
export DRUSH_MAKE_VERSION=6.x-2.0-beta9
export AEGIR_DOMAIN=aegir.example.com
export OLD_DRUPAL_DIR=$AEGIR_DIR/hostmaster-0.4-alpha9
export OLD_DRUPAL_DIR=$AEGIR_DIR/hostmaster-0.4-beta1
This document also assumes drush is installed properly and we use an
environment variable to simplify the documentation again.
......@@ -157,7 +167,6 @@ releases to the latest applicable versions.
Once you have upgraded the backend, and you have installed drush_make you will
need to run the hostmaster migrate command.
Shell commands::
cd $OLD_DRUPAL_DIR
......@@ -175,6 +184,11 @@ will be halted as it is necessary for the task queue to be processed.
The command above will fetch the latest stable Drupal release, so it can
simply be run again when a new security release of Drupal is made available.
If you have customized your Aegir installation and are maintaining your own
makefile, you can use the --makefile flag so the platform is created with
another makefile than the default. Be warned that this may create problems if
the makefile doesn't include the right Aegir modules.
Version-specific upgrade notes
==============================
......@@ -221,7 +235,7 @@ Finally, set an $AEGIR_IP environment variable for use in the Database
configuration step below.
Shell commands as root::
AEGIR_IP=`resolveip $AEGIR_HOST`
AEGIR_IP=`resolveip $AEGIR_HOST | awk {'print $6'}`
0.4 - unzip dependency
----------------------
......@@ -264,8 +278,8 @@ You need to re-use the pasword you had for the account before.
Shell commands::
mysql -u root -p -e "GRANT ALL ON *.* to 'aegir_root'@$AEGIR_HOST IDENTIFIED BY 'xxxx' WITH GRANT OPTION;"
mysql -u root -p -e "GRANT ALL ON *.* to 'aegir_root'@$AEGIR_IP IDENTIFIED BY 'xxxx' WITH GRANT OPTION;"
mysql -u root -p -e "GRANT ALL ON *.* to 'aegir_root'@'$AEGIR_HOST' IDENTIFIED BY 'xxxx' WITH GRANT OPTION;"
mysql -u root -p -e "GRANT ALL ON *.* to 'aegir_root'@'$AEGIR_IP' IDENTIFIED BY 'xxxx' WITH GRANT OPTION;"
0.4 - Apache configuration
......@@ -278,8 +292,7 @@ and a single apache.conf. The vhost.d directory is for virtual hosts,
platform.d is for platform-specific configuration and apache.conf is the
server-wide configuration file.
After you have completed the migration process as outlined above,
you will need to change the line you added to either the httpd.conf file
You will need to change the line you added to either the httpd.conf file
or /etc/apache2/conf.d/aegir file during installation.
Open your httpd.conf file and modify::
......@@ -290,11 +303,11 @@ To read ::
Include /var/aegir/config/apache.conf
If you are upgrading from 0.4 releases between alpha8 and alpha14, you will
need to rename your conf.d directory to post.d in Apache and pre.d in
If you are upgrading from 0.4 releases between alpha8 and (including) alpha14,
you will need to rename your conf.d directory to post.d in Apache and pre.d in
Nginx. Example, in Apache::
mv /var/aegir/config/server_master/apache/{conf.d,post.d}
Now log into Aegir, and verify the hostmaster platform. This will generate
the correct apache.conf file and restart apache.
the correct apache.conf file and restart Apache.
<?php if ($this->ssl_enabled && $this->ssl_key) : ?>
<VirtualHost <?php print "{$ip_address}:{$http_ssl_port}"; ?>>
<?php if ($this->site_mail) : ?>
ServerAdmin <?php print $this->site_mail; ?>
<?php endif;?>
DocumentRoot <?php print $this->root; ?>
ServerName <?php print $this->uri; ?>
# Enable SSL handling.
SSLEngine on
SSLCertificateFile <?php print $ssl_cert; ?>
SSLCertificateKeyFile <?php print $ssl_cert_key; ?>
<?php
if (sizeof($this->aliases)) {
print "\n ServerAlias " . implode("\n ServerAlias ", $this->aliases) . "\n";
}
?>
RewriteEngine on
# the ? at the end is to remove any query string in the original url
RewriteRule ^(.*)$ <?php print $this->platform->server->web_disable_url . '/' . $this->uri ?>?
</VirtualHost>
<?php endif; ?>
<?php
include('http/apache/vhost_disabled.tpl.php');
?>
......@@ -104,8 +104,8 @@ class provisionService_http_public extends provisionService_http {
// Redirection urls
$this->server->setProperty('web_disable_url', $this->server->master_url .'/hosting/disabled');
$this->server->setProperty('web_maintenance_url', $this->server->master_url .'/hosting/maintenance');
$this->server->web_disable_url = rtrim($this->server->master_url, '/') .'/hosting/disabled';
$this->server->web_maintenance_url = rtrim($this->server->master_url, '/') .'/hosting/maintenance';
if (!is_null($this->application_name)) {
......@@ -114,6 +114,7 @@ class provisionService_http_public extends provisionService_http {
$this->server->http_postd_path = "{$app_dir}/post.d";
$this->server->http_platformd_path = "{$app_dir}/platform.d";
$this->server->http_vhostd_path = "{$app_dir}/vhost.d";
$this->server->http_platforms_path = "{$this->server->aegir_root}/platforms";
}
}
......@@ -142,7 +143,10 @@ class provisionService_http_public extends provisionService_http {
provision_file()->create_dir($this->server->http_vhostd_path , dt("Webserver virtual host configuration"), 0700);
$this->sync($this->server->http_vhostd_path, array(
'exclude' => $this->server->http_vhostd_path . '/*', // Make sure remote directory is created
));
));
provision_file()->create_dir($this->server->http_platforms_path, dt("Platforms"), 0755);
$this->sync($this->server->http_platforms_path);
}
parent::verify_server_cmd();
......
<?php if ($this->ssl_enabled && $this->ssl_key) : ?>
server {
<?php
print " include " . $server->include_path . "/fastcgi_ssl_params.conf;\n";
?>
limit_conn gulag 10; # like mod_evasive - this allows max 10 simultaneous connections from one IP address
listen <?php print "{$ip_address}:{$http_ssl_port}"; ?>;
server_name <?php print $this->uri . ' ' . implode(' ', $this->aliases); ?>;
root <?php print $this->root; ?>;
index index.php index.html;
ssl on;
ssl_certificate <?php print $ssl_cert; ?>;
ssl_certificate_key <?php print $ssl_cert_key; ?>;
ssl_protocols SSLv2 SSLv3 TLSv1;
ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
ssl_prefer_server_ciphers on;
keepalive_timeout 70;
location / {
root /var/www/nginx-default;
index index.html index.htm;
rewrite ^/(.*)$ <?php print $this->platform->server->web_disable_url . '/' . $this->uri ?>? permanent;
}
}
<?php endif; ?>
<?php
// Generate the standard virtual host too.
include('http/nginx/vhost_disabled.tpl.php');
?>
......@@ -4,36 +4,147 @@
* @file install the hostmaster system
*/
function drush_provision_hostmaster_install($site = NULL) {
function drush_provision_hostmaster_install_validate($site = NULL) {
// set defaults for this whole script
// those are settings that are not prompted to the user but still overridable
drush_set_default('version', provision_version());
$version = drush_get_option('version');
$aegir_root = drush_set_default('aegir_root', drush_server_home());
drush_set_default('root', $aegir_root . '/' . 'hostmaster-' . $version);
drush_set_default('r', drush_get_option('root'));
drush_set_default('script_user', provision_current_user());
drush_set_default('web_group', _provision_default_web_group());
drush_set_default('http_service_type', 'apache');
drush_set_default('drush_make_version', '6.x-2.0-beta9');
drush_set_default('aegir_db_user', 'root');
$aegir_db_user = drush_get_option('aegir_db_user');
drush_set_default('makefile', $aegir_root . '/.drush/provision/aegir.make');
drush_print("Aegir $version automated install script");
drush_print("==============================================================================");
if (!$site || !drush_get_option('aegir_host', NULL) || !drush_get_option('aegir_db_pass', NULL) || filter_var(drush_get_option('client_email'), FILTER_VALIDATE_EMAIL)) {
drush_print("Some settings have not been provided and will now be prompted.
Don't worry: you will get to review those settings after the final install");
}
// now we prompt the user for settings if not provided or not sane
if (!$site) {
$site = drush_prompt(dt("Aegir domain name"), "aegir.example.com");
$site = drush_prompt(dt("Aegir frontend URL"), provision_fqdn());
}
drush_set_option('site', $site);
drush_set_default('aegir_host', provision_fqdn());
drush_set_default('aegir_db_host', 'localhost');
if (is_null(drush_get_option('aegir_db_pass', NULL))) {
// XXX: may not be portable everywhere?
system('stty -echo');
drush_set_option('aegir_db_pass', drush_prompt(dt('MySQL privileged user ("!root") password', array('!root' => $aegir_db_user))));
system('stty echo');
print "\n"; // add a newline since the user's didn't print
}
if (drush_get_option('aegir_host') == 'localhost') {
$default_email = 'webmaster@example.com';
} else {
$default_email = 'webmaster@' . drush_get_option('aegir_host');
}
while (!filter_var(drush_get_option('client_email'), FILTER_VALIDATE_EMAIL)) {
$client_email = drush_prompt(dt("Admin user e-mail"), $default_email);
drush_set_option('client_email', $client_email);
}
$version = drush_get_option('version', 'HEAD');
$aegir_root = drush_get_option('aegir_root', drush_server_home());
$platform = drush_get_option(array('r', 'root'), $aegir_root . '/' . 'hostmaster-' . $version);
drush_print(dt('
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: !site
Master server FQDN: !fqdn
Aegir root: !home
Aegir user: !user
Web group: !web
Web server: !web_server
Aegir DB host: !db_host
Aegir DB user: !db_user
Aegir DB password: !db_pass
Drush make version: !drush_make
Aegir version: !version
Aegir platform path: !root
Aegir makefile: !makefile
Client email: !email
', array('!site' => $site,
'!fqdn' => drush_get_option('aegir_host'),
'!home' => drush_get_option('aegir_root'),
'!user' => drush_get_option('script_user'),
'!web' => drush_get_option('web_group'),
'!web_server' => drush_get_option('http_service_type'),
'!db_host' => drush_get_option('aegir_db_host'),
'!db_user' => drush_get_option('aegir_db_user'),
'!db_pass' => is_null(drush_get_option('aegir_db_pass', NULL, 'process')) ? '<previously set>' : '<prompted>',
'!drush_make' => drush_get_option('drush_make_version'),
'!version' => drush_get_option('version'),
'!root' => drush_get_option(array('r', 'root')),
'!makefile' => drush_get_option('makefile'),
'!email' => drush_get_option('client_email'),
)));
if (!drush_confirm(dt('Do you really want to proceed with the install'))) {
return drush_set_error('PROVISION_CANCEL_INSTALL', dt('Installation aborted by user'));
}
$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');
$master_db = sprintf("mysql://%s:%s@%s",$aegir_db_user, $aegir_db_pass, $aegir_host);
return TRUE;
}
// TODO: support creation of an external db server
function drush_provision_hostmaster_install($site = NULL) {
$version = drush_get_option('version');
$site = drush_get_option('site', provision_fqdn());
$aegir_root = drush_get_option('aegir_root');
$platform = drush_get_option(array('r', 'root'));
$aegir_db_user = drush_get_option('aegir_db_user');
$aegir_db_pass = drush_get_option('aegir_db_pass');
$server = '@server_master';
drush_backend_invoke_args("provision-save", array($server), array(
$master_context = array(
'context_type' => 'server',
// files
'remote_host' => $aegir_host,
'remote_host' => drush_get_option('aegir_host'),
'aegir_root' => $aegir_root,
'script_user' => drush_get_option('script_user', provision_current_user()),
'script_user' => drush_get_option('script_user'),
// apache or nginx or..
'http_service_type' => drush_get_option('http_service_type', 'apache', 'options'),
'web_group' => drush_get_option('web_group', _provision_default_web_group()),
'http_service_type' => drush_get_option('http_service_type'),
'web_group' => drush_get_option('web_group'),
'master_url' => "http://" . $site,
// mysql
'db_service_type' => 'mysql',
'master_db' => $master_db,
));
);
$master_db = sprintf("mysql://%s:%s@%s",$aegir_db_user, $aegir_db_pass, drush_get_option('aegir_db_host'));
if (drush_get_option('aegir_host') == drush_get_option('aegir_db_host')) {
$master_context['db_service_type'] = 'mysql';
$master_context['master_db'] = $master_db;
$dbserver = $server;
} else {
$dbserver = '@server_' . drush_get_option('aegir_db_host');
$dbserver_context = array(
'remote_host' => drush_get_option('aegir_db_host'),
'context_type' => 'server',
'db_service_type' => 'mysql',
'master_db' => $master_db,
);
drush_backend_invoke_args("provision-save", array($dbserver), $dbserver_context);
provision_backend_invoke($dbserver, 'provision-verify');
}
drush_backend_invoke_args("provision-save", array($server), $master_context);
provision_backend_invoke($server, 'provision-verify');
// exit if an error has occured.
......@@ -46,7 +157,7 @@ function drush_provision_hostmaster_install($site = NULL) {
}
if (!function_exists('drush_make_drush_command')) {
drush_backend_invoke('dl', array('drush_make-' . drush_get_option('drush_make_version', '6.x-2.0-beta9'), 'destination' => $aegir_root . '/.drush/'));
drush_backend_invoke('dl', array('drush_make-' . drush_get_option('drush_make_version'), 'destination' => $aegir_root . '/.drush/'));
}
$platform_name = '@platform_hostmaster';
......@@ -55,25 +166,25 @@ function drush_provision_hostmaster_install($site = NULL) {
'server' => $server,
'web_server' => $server,
'root' => $platform,
'makefile' => $aegir_root . '/.drush/provision/aegir.make',
'makefile' => drush_get_option('makefile'),
));
provision_backend_invoke($platform_name, 'provision-verify');
// propagate working-copy args downward
$options = array();
if (drush_get_option('working-copy')) {
$options['working-copy'] = 1;
}
provision_backend_invoke($platform_name, 'provision-verify', array(), $options);
// exit if an error has occured.
if (drush_get_error()) {
return false;
}
while (!filter_var(drush_get_option('client_email'), FILTER_VALIDATE_EMAIL)) {
$client_email = drush_prompt(dt("Admin user e-mail"), "you@example.com");
drush_set_option('client_email', $client_email);
}
$site_name = '@hostmaster';
drush_backend_invoke_args("provision-save", array($site_name), array(
'context_type' => 'site',
'platform' => $platform_name,
'db_server' => $server,
'db_server' => $dbserver,
'uri' => $site,
'client_email' => drush_get_option('client_email'),
'profile' => 'hostmaster',
......
......@@ -22,16 +22,14 @@
########################################################################
# This script takes the following steps:
#
# 1. prompt for confirmation
# 2. downloads drush in $AEGIR_HOME
# 3. downloads provision in $AEGIR_HOME/.drush
# 4. delegate the rest of the install to hostmaster-install
# 1. downloads drush in $AEGIR_HOME
# 2. downloads provision in $AEGIR_HOME/.drush
# 3. delegate the rest of the install to hostmaster-install
########################################################################
# basic variables, change before release
AEGIR_VERSION="HEAD"
DRUSH_VERSION=6.x-3.3
# when adding a variable here, add it to the display below
# guess the aegir version based on the info file
AEGIR_VERSION="0.4-beta2"
DRUSH_VERSION=6.x-3.3
########################################################################
# functions
......@@ -41,28 +39,6 @@ msg() {
echo "==> $*"
}
# simple prompt
prompt_yes_no() {
while true ; do
printf "$* [Y/n] "
read answer
if [ -z "$answer" ] ; then
return 0
fi
case $answer in
[Yy]|[Yy][Ee][Ss])
return 0
;;
[Nn]|[Nn][Oo])
return 1
;;
*)
echo "Please answer yes or no"
;;
esac
done
}
########################################################################
# Main script
......@@ -70,65 +46,11 @@ AEGIR_HOME="$HOME"
AEGIR_HOST=`uname -n`
DRUSH="$AEGIR_HOME/drush/drush.php"
msg "Aegir $AEGIR_VERSION automated install script"
if [ `whoami` = "root" ] ; then
msg "This script should be ran as a non-root user"
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