Commit 48819871 authored by drumm's avatar drumm Committed by Neil Drumm

Merge branch 'dev-services' of ssh://gitosis@git.aegirproject.org/provision into dev-services

parents e68317a4 3afc5299
......@@ -37,8 +37,8 @@ Shell commands::
export AEGIR_VERSION=HEAD
export DRUPAL_DIR=/var/aegir/hostmaster-$AEGIR_VERSION
export OLD_DRUPAL_DIR=/var/aegir/drupal-6.14
export DRUSH_VERSION=All-versions-3.0-beta1
export OLD_DRUPAL_DIR=/var/aegir/hostmaster-0.4-alpha6
export DRUSH_VERSION=All-versions-3.0-rc4
export DRUSH_MAKE_VERSION=6.x-2.0-beta6
This document also assumes drush is installed properly and we use an
......
......@@ -57,26 +57,15 @@ class provisionService_db extends provisionService {
function __construct() {
$master_db = drush_get_option('master_db');
if ($master_db) {
$db = parse_url($master_db);
$host = urldecode($db['host']);
$user = urldecode($db['user']);
$pass = urldecode($db['pass']);
$scheme = $db['scheme'];
if (!$master_db) {
drush_set_error("PROVISION_DB_FAILED", dt("Database credentials unavailable, run provision-verify"));
}
else {
#TODO - this stuff is all pretty wrong imo. it should not be asked here
drush_print(dt("No database configuration provided, asking for one interactively"));
$scheme = drush_prompt(dt("Database type"), "mysql");
$host = drush_prompt(dt("Database server"), "localhost");
$user = drush_prompt(dt("Database user"), "root");
system('stty -echo');
$pass = drush_prompt(dt("Database password"));
system('stty echo');
print "\n"; # add a cr since the user's didn't echo
drush_set_option('master_db', "$scheme://$user:$pass@$host", 'user');
}
$db = parse_url($master_db);
$host = urldecode($db['host']);
$user = urldecode($db['user']);
$pass = urldecode($db['pass']);
$scheme = $db['scheme'];
drush_set_default('master_db_user', $user);
drush_set_default('master_db_passwd', $pass);
......
......@@ -119,14 +119,14 @@ class provisionConfig_apache_site extends provisionConfig_apache {
public $description = 'apache site configuration file';
function filename() {
if (!$this->data['site_port'] || $this->data['site_port'] < 1 || $this->data['site_port'] > 66535) {
$this->data['site_port'] = 80;
}
return $this->data['vhost_path'] . '/' . $this->data['site_url'] . '_' . $this->data['site_port'];
}
function process() {
if (!$this->data['site_port'] || $this->data['site_port'] < 1 || $this->data['site_port'] > 66535) {
$this->data['site_port'] = 80;
}
if ($this->data['aliases'] && !is_array($this->data['aliases'])) {
$this->data['aliases'] = explode(",", $this->data['aliases']);
}
......
......@@ -21,9 +21,10 @@ function drush_http_post_provision_verify($url = null) {
drush_set_option('master_url', drush_get_option('master_url'), 'user');
drush_set_option('web_host', drush_get_option('web_host', '127.0.0.1'), 'user');
drush_set_option('web_ip', drush_get_option('web_ip', ''), 'user');
drush_set_option('web_port', drush_get_option('web_port', 80), 'user');
drush_set_option('web_group', drush_get_option('web_group'), 'user');
drush_set_option('script_user', drush_get_option('script_user'), 'user');
drush_set_option('restart_cmd', drush_get_option('restart_cmd'), 'user');
drush_set_option('restart_cmd', drush_get_option('restart_cmd', _provision_default_restart_cmd(), 'user'), 'user');
drush_set_option('backup_path', drush_get_option('backup_path'), 'user');
drush_set_option('config_path', drush_get_option('config_path'), 'user');
}
......
<?php
/**
* @file install the hostmaster system
*/
function drush_provision_hostmaster_install($site) {
if (!$site) {
return drush_set_error('SITE_MISSING', dt('You need to specify the FQDN of the hostmaster install'));
}
$version = drush_get_option('version', 'HEAD');
$parent_path = drush_get_option('parent_path', drush_server_home());
$platform = drush_get_option(array('r', 'root'), $parent_path . '/' . 'hostmaster-' . $version);
if (!drush_get_option('backend-only')) {
if (!function_exists('drush_make_drush_command')) {
drush_backend_invoke('dl', array('drush_make-' . drush_get_option('drush_make_version', '6.x-2.0-beta6'), 'destination' => $parent_path . '/.drush/'));
}
drush_print(dt("deploying hostmaster application"));
drush_backend_invoke('hostmaster-make', array($platform));
}
$data['master_db'] = drush_get_option('master_db');
if (!$data['master_db']) {
drush_print(dt("No database configuration provided, asking for one interactively"));
$scheme = drush_prompt(dt("Database type"), "mysql");
$host = drush_prompt(dt("Database server"), "localhost");
$user = drush_prompt(dt("Database user"), "root");
system('stty -echo');
$pass = drush_prompt(dt("Database password"));
system('stty echo');
print "\n"; # add a cr since the user's didn't echo
$data['master_db'] = "$scheme://$user:$pass@$host";
}
$data['init_http'] = 'apache';
$data['init_db'] = 'mysql';
$data['provision_context'] = 'server';
$data['parent_path'] = $parent_path;
$data['script_user'] = drush_get_option('script_user', 'aegir');
$data['web_group'] = drush_get_option('web_group', _provision_default_web_group());
$data['web_port'] = drush_get_option('web_port', 80);
$data['config_path'] = drush_get_option('config_path', $parent_path . '/config');
$data['backup_path'] = drush_get_option('backup_path', $parent_path . '/backups');
$data['drush_path'] = DRUSH_COMMAND;
// verify the server
drush_backend_invoke('provision-verify', $data, 'POST');
if (drush_get_option('backend-only')) {
return;
}
// verify the current platform
drush_backend_invoke('provision-verify', array(
'root' => $platform,
'provision_context' => "platform",
'publish_path' => $platform,
'platform' => '5') // dirty hardcoded to create the first platform apache config
// this will become unnecessary when we have drush aliases
);
// install the hostmaster site
$data = drush_backend_invoke('provision-install', array(
$site,
'uri' => $site,
'root' => $platform,
'client_email' => drush_get_option('client_email', 'webmaster@localhost'),
'profile' => "hostmaster",
'provision_context' => "site",
'site_port' => drush_get_option('web_port', 80)),
'GET', TRUE
);
drush_print("Initializing the hosting system");
drush_backend_invoke('hosting-setup', array('uri' => $site, 'root' => $platform));
drush_print(dt("Aegir is now installed. You can visit it at @link", array('@link' => $data['context']['login_link'])));
}
......@@ -30,14 +30,8 @@
#
########################################################################
# basic variables, change before release
AEGIR_DOMAIN=aegir.example.com
AEGIR_VERSION=HEAD
AEGIR_HOME=$HOME
WEB_GROUP=www-data
# doesn't exist yet, but we need drush_prompt in HEAD
DRUSH_VERSION=All-versions-3.0-rc4
DRUSH_MAKE_VERSION=6.x-2.0-beta6
CLIENT_EMAIL="you@example.com"
AEGIR_VERSION="HEAD"
DRUSH_VERSION=All-versions-3.0
# when adding a variable here, add it to the display below
......@@ -72,37 +66,11 @@ prompt_yes_no() {
}
usage() {
cat <<EOF
Usage: $0 [ -V version ] [ -h ] [ -w group ] [ -d home ] hostname
EOF
}
########################################################################
# Main script
# stop on error
set -e
# parse commandline
args=`getopt bV:w:d:h $*`
set -- $args
for i
do
case "$i" in
-w) shift; WEB_GROUP=$1; shift;;
-V) shift; AEGIR_VERSION=$1; shift;;
-d) shift; AEGIR_HOME=$1; shift;;
-b) BACKEND_ONLY=1; shift;;
-h) shift; usage; exit;;
--) shift; break;;
esac
done
AEGIR_DOMAIN=${1:-$AEGIR_DOMAIN}
AEGIR_HOME="$HOME"
DRUSH="$AEGIR_HOME/drush/drush.php"
HOSTMASTER_DIR=$AEGIR_HOME/hostmaster-$AEGIR_VERSION
msg "Aegir automated install script"
......@@ -115,21 +83,6 @@ msg "This script makes the following assumptions: "
cat <<EOF
* you have read INSTALL.txt and prepared the platform accordingly
* you are running as your "aegir" user
* the following settings are correct:
AEGIR_DOMAIN=$AEGIR_DOMAIN
AEGIR_VERSION=$AEGIR_VERSION
AEGIR_HOME=$AEGIR_HOME
WEB_GROUP=$WEB_GROUP
HOSTMASTER_DIR=$HOSTMASTER_DIR
DRUSH=$DRUSH
DRUSH_VERSION=$DRUSH_VERSION
CLIENT_EMAIL=$CLIENT_EMAIL
Some of those settings can be changed on the commandline, see:
$0 -h
for more information.
EOF
if prompt_yes_no "Do you want to proceed with the install?" ; then
......@@ -139,14 +92,6 @@ else
exit 1
fi
msg "Creating basic directory structure"
mkdir -p $AEGIR_HOME/config/vhost.d
mkdir -p $AEGIR_HOME/config/platform.d
mkdir -p $AEGIR_HOME/config/apache.d
mkdir -p $AEGIR_HOME/backups
chmod 0711 $AEGIR_HOME/config
chmod 0700 $AEGIR_HOME/backups
# 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"
......@@ -170,14 +115,6 @@ else
exit 1
fi
if $DRUSH help | grep "^ make" > /dev/null ; then
msg "Drush make already seems to be installed"
else
msg "Installing drush make in $AEGIR_HOME/.drush"
mkdir -p $AEGIR_HOME/.drush
$DRUSH dl drush_make-$DRUSH_MAKE_VERSION --destination=$AEGIR_HOME/.drush
fi
if $DRUSH help | grep "^ provision-install" > /dev/null ; then
msg "Provision already seems to be installed"
else
......@@ -193,30 +130,5 @@ else
fi
fi
# this will prompt the user for the database password if not provided through stdin in JSON
$DRUSH provision-verify --parent_path="$AEGIR_HOME" --web_group="$WEB_GROUP" --drush_path="$DRUSH" --provision_context="server" --init_http="apache"
msg "Aegir provision backend installed successfully"
if [ ! -z "$BACKEND_ONLY" ] ; then
exit 0
fi
if [ ! -d $HOSTMASTER_DIR ] ; then
msg "Deploying hostmaster application"
$DRUSH hostmaster-make $HOSTMASTER_DIR
$DRUSH provision-verify --root="$HOSTMASTER_DIR" --provision_context="platform"
$DRUSH provision-install --root="$HOSTMASTER_DIR" --provision_context="site" --client_email=$CLIENT_EMAIL --profile="hostmaster" "$AEGIR_DOMAIN"
cd $HOSTMASTER_DIR
$DRUSH hosting-setup --uri="$AEGIR_DOMAIN" -y
fi
cat <<EOF
Aegir is installed. You can visit it at http://$AEGIR_DOMAIN
EOF
msg "Installing the frontend"
$DRUSH hostmaster-install "$*"
......@@ -90,13 +90,13 @@ function install_mail($key, &$message, $params) {
function install_main() {
global $profile, $install_locale, $client_email, $conf, $url, $base_url;
require_once('install.php');
require_once DRUPAL_ROOT . '/includes/install.core.inc';
drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_CONFIGURATION);
// We have an existing settings.php.
$db_spec = _drush_sql_get_db_spec();
$db_spec = drush_core_site_install_db_spec();
$db_spec['db_prefix'] = $GLOBALS['db_prefix'];
if ($db_spec['driver'] == 'mysqli') {
......
......@@ -175,6 +175,15 @@ function provision_drush_command() {
),
);
$items['hostmaster-install'] = array(
'description' => dt('Install and verify the Hostmaster frontend.'),
'bootstrap' => DRUSH_BOOTSTRAP_DRUSH,
'arguments' => array(
'example.com' => dt('The name of the site to install'),
'/path/to/platform' => dt('The platform to install the site on.'),
'you@example.com' => dt('The email account to send a welcome mail to'),
),
);
$items['hostmaster-pause'] = array(
'description' => dt('Prepare the site to be migrated to a new platform.'),
......
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