Skip to content
Commits on Source (60)
......@@ -40,7 +40,7 @@ class Provision_ChainedState {
*/
function succeed($message) {
if ($this->last_status === TRUE) {
drush_log(dt($message, $this->tokens), 'message');
drush_log(dt($message, $this->tokens), 'success');
}
return $this;
......
......@@ -15,11 +15,16 @@ class Provision_Config_Drupal_Settings extends Provision_Config {
}
function process() {
if (drush_drupal_major_version() >= 8) {
$this->data['config_directories_active_var'] = 'config_directories_active';
$this->data['config_directories_staging_var'] = 'config_directories_staging';
}
if (drush_drupal_major_version() >= 7) {
$this->data['db_type'] = ($this->data['db_type'] == 'mysqli') ? 'mysql' : $this->data['db_type'];
$this->data['file_directory_path_var'] = 'file_public_path';
$this->data['file_directory_temp_var'] = 'file_temporary_path';
$this->data['file_directory_private_var'] = 'file_private_path';
$this->data['drupal_hash_salt_var'] = 'empty';
}
else {
$this->data['file_directory_path_var'] = 'file_directory_path';
......
......@@ -130,7 +130,18 @@ if (isset($_SERVER['db_name'])) {
$conf['<?php print $file_directory_temp_var ?>'] = 'sites/<?php print $this->uri ?>/private/temp';
<?php if (isset($file_directory_private_var)): ?>
$conf['<?php print $file_directory_private_var ?>'] = 'sites/<?php print $this->uri ?>/private/files';
<?php endif; ?>
<?php endif; ?>
<?php if (isset($drupal_hash_salt_var)): ?>
$drupal_hash_salt = '';
<?php endif; ?>
<?php if (isset($config_directories_active_var)): ?>
$config_directories['active']['path'] = 'sites/<?php print $this->uri ?>/private/config/active';
$config_directories['active']['absolute'] = TRUE;
<?php endif; ?>
<?php if (isset($config_directories_staging_var)): ?>
$config_directories['staging']['path'] = 'sites/<?php print $this->uri ?>/private/config/staging';
$config_directories['staging']['absolute'] = TRUE;
<?php endif; ?>
$conf['clean_url'] = 1;
$conf['aegir_api'] = <?php print !$this->backup_in_progress ? $this->api_version : 0 ?>;
......
......@@ -50,7 +50,7 @@ class Provision_FileSystem extends Provision_ChainedState {
function exists($path) {
$this->_clear_state();
$this->last_status = file_exists($path);
$this->last_status = file_exists($path) || is_link($path);
$this->tokens = array('@path' => $path);
return $this;
......
......@@ -2,6 +2,8 @@ core = 6.x
api = 2
projects[drupal][type] = "core"
projects[drupal][version] = "6.28"
projects[drupal][patch][] = "http://drupal.org/files/common.inc_6.28.patch"
projects[hostmaster][type] = "profile"
projects[hostmaster][download][type] = "git"
......
......@@ -32,13 +32,13 @@ class Provision_Service_db extends Provision_Service {
function verify_server_cmd() {
if ($this->connect()) {
if ($this->can_create_database()) {
drush_log(dt('Provision can create new databases.'), 'message');
drush_log(dt('Provision can create new databases.'), 'success');
}
else {
drush_set_error('PROVISION_CREATE_DB_FAILED');
}
if ($this->can_grant_privileges()) {
drush_log(dt('Provision can grant privileges on database users.'), 'message');;
drush_log(dt('Provision can grant privileges on database users.'), 'success');;
}
else {
drush_set_error('PROVISION_GRANT_DB_USER_FAILED');
......
......@@ -7,5 +7,6 @@ function drush_db_provision_migrate_validate() {
// Deletes the old database credentials
function drush_db_post_provision_migrate() {
provision_reload_config('site', d()->site_path . '/drushrc.php');
d()->service('db')->destroy_site_database();
}
......@@ -47,8 +47,14 @@ case "$1" in
RET='apache' # convert argument to something aegir can understand
fi
FLAGS="$FLAGS --http_service_type='$RET'"
WEBSERVER="$RET"
fi
# make sure the configuration file exists before symlinking it in place (below)
touch $VARLIB/config/$WEBSERVER.conf
# fix permissions on installed directories
chown aegir:aegir "$VARLIB" "$VARLIB/config" "$VARLIB/config/$WEBSERVER.conf"
# flush the drush cache to find new commands
su -s /bin/sh aegir -c 'drush cc drush'
TEMPFILE=`tempfile`
......@@ -109,10 +115,6 @@ case "$1" in
DEBUG="--debug"
fi
# fix permissions on installed directories
touch $VARLIB/config/$WEBSERVER.conf
chown aegir:aegir "$VARLIB" "$VARLIB/config" "$VARLIB/config/$WEBSERVER.conf"
# pass data through JSON for extra security
su -s /bin/sh aegir -c "cd $VARLIB && drush hostmaster-install $FLAGS --backend $site_uri 2>&1 | drush backend-parse $DEBUG" <<EOF
{ "yes": 1,
......
aegir-provision2 (2.0~rc4) unstable; urgency=low
* Fixes a missed step in the 2.0~rc3 release process.
-- Christopher Gervais <chris@ergonlogic.com> Fri, 30 Aug 2013 15:46:06 -0400
aegir-provision2 (2.0~rc3) unstable; urgency=low
* This release mainly fixes a couple critical bugs in 2.0-rc2 that were
causing problems when sites were being cloned or renamed.
* We've added a couple small features, such as additional options during
hostmaster-install, and allowing the redirect to the Welcome page to be
turned off.
* Also, we've made a small addition to the API, in that there is now a hook
available (hook_provision_drupal_create_directories_alter()) to allow
altering the directories created when a site installed.
-- Christopher Gervais <chris@ergonlogic.com> Thu, 29 Aug 2013 11:53:43 -0400
aegir-provision2 (2.0~rc2) unstable; urgency=low
* This release mainly fixes an error during the rc1 release, which had not
been properly updated to pull in the latest tagged code.
* A small fix to SSL handling, and updates to external dependencies are
the only other changes since rc1.
* Full release notes at http://community.aegirproject.org/2.0-rc2
-- Christopher Gervais <chris@ergonlogic.com> Sat, 20 Jul 2013 15:32:46 -0400
aegir-provision2 (2.0~rc1) unstable; urgency=low
* This release mainly targets a few critical bugs that were found in the
second beta, mostly related to ongoing Views and Drush integration and
access control. We also introduce a number of new features and finally
drop support for provisionning Drupal 5 sites completely.
* We've added some long-standing UI enhancements, and fixed a number of
bugs in the views integration and other usability problems, as well as
overhauling our access control.
* Full release notes at http://community.aegirproject.org/2.0-rc1
-- Christopher Gervais <chris@ergonlogic.com> Fri, 19 Jul 2013 14:41:19 -0400
aegir-provision2 (2.0~beta2) unstable; urgency=low
* This release mainly targets a few critical bugs that were found in the
......
......@@ -63,3 +63,8 @@
* The database prefix to use instead of the default 'site_'
*/
# $options['aegir_db_prefix'] = 'prefix_';
/**
* The username to assign UID1 for provisioned sites.
*/
# $options['admin_user'] = 'admin';
......@@ -44,9 +44,9 @@ if (sizeof($this->aliases)) {
RewriteEngine on
<?php
if ($this->redirection) {
// Redirect all aliases to the main https url.
print " RewriteCond %{HTTP_HOST} !^{$this->uri}$ [NC]\n";
print " RewriteRule ^/*(.*)$ https://{$this->uri}/$1 [NE,L,R=301]\n";
// Redirect to the selected alias.
print " RewriteCond %{HTTP_HOST} !^{$this->redirection}$ [NC]\n";
print " RewriteRule ^/*(.*)$ https://{$this->redirection}/$1 [NE,L,R=301]\n";
}
?>
RewriteRule ^/files/(.*)$ /sites/<?php print $this->uri; ?>/files/$1 [L]
......
......@@ -117,7 +117,17 @@ class Provision_Service_http_ssl extends Provision_Service_http_public {
if (provision_file()->exists($path)->status()) {
drush_log(dt('generating 2048 bit RSA key in %path/', array('%path' => $path)));
// generate a key
/*
* according to RSA security and most sites I could read, 1024
* was recommended until 2010-2015 and 2048 is now the
* recommended length for more sensitive data. we are therefore
* taking the safest route.
*
* http://www.javamex.com/tutorials/cryptography/rsa_key_length.shtml
* http://www.vocal.com/cryptography/rsa-key-size-selection/
* https://en.wikipedia.org/wiki/Key_size#Key_size_and_encryption_system
* http://www.redkestrel.co.uk/Articles/CSR.html
*/
drush_shell_exec('openssl genrsa -out %s/openssl.key 2048', $path)
|| drush_set_error('SSL_KEY_GEN_FAIL', dt('failed to generate SSL key in %path', array('%path' => $path . '/openssl.key')));
......
......@@ -4,6 +4,29 @@
* @file install the hostmaster system
*/
/**
* Implements drush_COMMAND_pre_validate().
*
* Ensure the database cannot be accessed by anonymous users, as it will
* otherwise fail later in the install, and thus be harder to recover from.
*
* @see Provision_Service_db_mysql::grant_host().
*/
function drush_provision_hostmaster_install_pre_validate() {
$command = sprintf('mysql -u intntnllyInvalid -h %s -P %s -e "SELECT VERSION()"', drush_get_option('aegir_db_host', 'localhost'), drush_get_option('aegir_db_port', '3306'));
drush_shell_exec($command);
if (preg_match("/Access denied for user 'intntnllyInvalid'@'([^']*)'/", implode('', drush_shell_exec_output()), $match)) {
return;
}
elseif (preg_match("/Host '([^']*)' is not allowed to connect to/", implode('', drush_shell_exec_output()), $match)) {
return;
}
else {
return drush_set_error('PROVISION_DB_CONNECT_FAIL', dt('Dummy connection failed to fail. Either your MySQL permissions are too lax, or the response was not understood. See http://is.gd/Y6i4FO for more information. %msg', array('%msg' => join("\n", drush_shell_exec_output()))));
}
}
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
......@@ -15,7 +38,9 @@ function drush_provision_hostmaster_install_validate($site = NULL) {
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('http_port', '80');
drush_set_default('aegir_db_user', 'root');
drush_set_default('aegir_db_port', '3306');
drush_set_default('client_name', 'admin');
$aegir_db_user = drush_get_option('aegir_db_user');
drush_set_default('makefile', dirname(__FILE__) . '/aegir.make');
......@@ -41,7 +66,7 @@ Don't worry: you will get to review those settings after the final install");
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
print "\n"; // add a newline since the user's didn't print
}
if (drush_get_option('aegir_host') == 'localhost') {
......@@ -75,9 +100,11 @@ The following settings will be used:
Aegir user: !user
Web group: !web
Web server: !web_server
Web server port: !web_server_port
Aegir DB host: !db_host
Aegir DB user: !db_user
Aegir DB password: !db_pass
Aegir DB port: !db_port
Aegir version: !version
Aegir platform path: !root
Aegir makefile: !makefile
......@@ -88,9 +115,11 @@ The following settings will be used:
'!user' => drush_get_option('script_user'),
'!web' => drush_get_option('web_group'),
'!web_server' => drush_get_option('http_service_type'),
'!web_server_port' => drush_get_option('http_port'),
'!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>',
'!db_port' => drush_get_option('aegir_db_port'),
'!version' => drush_get_option('version'),
'!root' => drush_get_option(array('r', 'root')),
'!makefile' => drush_get_option('makefile'),
......@@ -113,34 +142,41 @@ function drush_provision_hostmaster_install($site = NULL) {
$aegir_root = drush_get_option('aegir_root');
$platform = drush_get_option(array('r', 'root'));
$aegir_http_host = drush_get_option('aegir_host');
$aegir_http_port = drush_get_option('http_port');
$aegir_db_user = drush_get_option('aegir_db_user');
$aegir_db_pass = drush_get_option('aegir_db_pass');
$aegir_db_port = drush_get_option('aegir_db_port');
$aegir_db_host = drush_get_option('aegir_db_host');
$server = '@server_master';
$master_context = array(
'context_type' => 'server',
// files
'remote_host' => drush_get_option('aegir_host'),
'remote_host' => $aegir_http_host,
'aegir_root' => $aegir_root,
'script_user' => drush_get_option('script_user'),
// apache or nginx or..
'http_service_type' => drush_get_option('http_service_type'),
'http_port' => $aegir_http_port,
'web_group' => drush_get_option('web_group'),
'master_url' => "http://" . $site,
'db_port' => $aegir_db_port,
);
$master_db = sprintf("mysql://%s:%s@%s", urlencode($aegir_db_user), urlencode($aegir_db_pass), drush_get_option('aegir_db_host'));
if (drush_get_option('aegir_host') == drush_get_option('aegir_db_host')) {
$master_db = sprintf("mysql://%s:%s@%s:%s", urlencode($aegir_db_user), urlencode($aegir_db_pass), $aegir_db_host, $aegir_db_port);
if ($aegir_http_host == $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 = '@server_' . $aegir_db_host;
$dbserver_context = array(
'remote_host' => drush_get_option('aegir_db_host'),
'remote_host' => $aegir_db_host,
'context_type' => 'server',
'db_service_type' => 'mysql',
'master_db' => $master_db,
'db_port' => $aegir_db_port,
);
drush_invoke_process('@none', "provision-save", array($dbserver), $dbserver_context);
provision_backend_invoke($dbserver, 'provision-verify');
......@@ -148,7 +184,7 @@ function drush_provision_hostmaster_install($site = NULL) {
drush_invoke_process('@none', "provision-save", array($server), $master_context);
provision_backend_invoke($server, 'provision-verify');
// exit if an error has occured.
// exit if an error has occured.
if (drush_get_error()) {
return false;
}
......@@ -172,7 +208,7 @@ function drush_provision_hostmaster_install($site = NULL) {
}
provision_backend_invoke($platform_name, 'provision-verify', array(), $options);
// exit if an error has occured.
// exit if an error has occured.
if (drush_get_error()) {
return false;
}
......@@ -192,7 +228,7 @@ function drush_provision_hostmaster_install($site = NULL) {
$data = provision_backend_invoke($site_name, 'provision-install', array(), array('client_email' => drush_get_option('client_email')));
provision_backend_invoke($site_name, 'provision-verify');
// exit if an error has occured.
// exit if an error has occured.
if (drush_get_error()) {
return false;
}
......
......@@ -71,4 +71,6 @@ function drush_provision_drupal_provision_clone($new_uri, $platform = null) {
provision_backend_invoke($new_uri, 'provision-verify');
}
provision_reload_config('site', d()->site_path . '/drushrc.php');
}
......@@ -60,6 +60,10 @@ function drush_provision_drupal_pre_provision_deploy($backup_file) {
provision_file()->chgrp(drush_get_option('extract_path') . '/files', d('@server_master')->web_group, TRUE)
->succeed('Changed group ownership of files in <code>@path</code> to @gid')
->fail('Could not change group ownership of files in <code>@path</code> to @gid');
provision_file()->chgrp(drush_get_option('extract_path') . '/private/files', d('@server_master')->web_group, TRUE)
->succeed('Changed group ownership of private files in <code>@path</code> to @gid')
->fail('Could not change group ownership of private files in <code>@path</code> to @gid');
if (drush_get_option('deploy_replace_site', FALSE)) {
$old = d()->site_path . '.restore';
......
<?php
/**
* @file
* Rebuild all the caches
*/
cache_clear_all();
drush_log(t('Cleared all caches'));
node_types_rebuild();
drush_log(t('Rebuilt node type cache'));
module_rebuild_cache();
drush_log(t('Rebuilt module cache'));
system_theme_data();
drush_log(t('Rebuilt theme cache'));
menu_rebuild();
drush_log(t('Rebuilt menu cache'));
<?php
// $Id$
/**
* @file
* Rebuild all the caches
*/
drupal_flush_all_caches();
drush_log(t('All caches flushed'));
<?php
// Fetch the cron key from the Drupal site and set in a drush context.
drush_set_option('cron_key', variable_get('cron_key', 'drupal'));
\ No newline at end of file
<?php
// $Id$
$new_url = d()->uri;
/**
* @deprecated in drush3 it's 'options', in drush 4 it's 'cli', drop
* 'options' when we drop drush3 support
*/
$context = drush_get_context('cli') ? 'cli' : 'options';
$old_url = drush_get_option('old_uri', $new_url, $context);
/**
* @file
......@@ -16,37 +7,38 @@ $old_url = drush_get_option('old_uri', $new_url, $context);
* directories.
*/
drush_log(
dt('Changed paths from sites/@old_url to sites/@new_url',
array('@old_url' => $old_url, '@new_url' => $new_url)));
$new_url = d()->uri;
$old_url = drush_get_option('old_uri', $new_url, 'cli');
$old_url_pattern = '/^' . preg_quote('sites/' . $old_url, '/') . '/';
/*
* Update paths for sites migrated
* from standalone to the multisite install.
*/
// Update paths for sites migrated from standalone to the multisite install.
db_query("UPDATE {files} SET filepath = REPLACE(filepath, 'sites/default', 'sites/%s')", $new_url);
db_query("UPDATE {users} SET picture = REPLACE(picture, 'sites/default', 'sites/%s')", $new_url);
db_query("UPDATE {boxes} SET body = REPLACE(body, 'sites/default', 'sites/%s')", $new_url);
db_query("UPDATE {node_revisions} SET body = REPLACE(body, 'sites/default', 'sites/%s')", $new_url);
db_query("UPDATE {node_revisions} SET teaser = REPLACE(teaser, 'sites/default', 'sites/%s')", $new_url);
/*
* Update paths for sites cloned/migrated/renamed
* in the multisite install.
*/
// Update paths for sites cloned/migrated/renamed in the multisite install.
db_query("UPDATE {files} SET filepath = REPLACE(filepath, 'sites/%s', 'sites/%s')", $old_url, $new_url);
db_query("UPDATE {users} SET picture = REPLACE(picture, 'sites/%s', 'sites/%s')", $old_url, $new_url);
db_query("UPDATE {boxes} SET body = REPLACE(body, 'sites/%s', 'sites/%s')", $old_url, $new_url);
db_query("UPDATE {node_revisions} SET body = REPLACE(body, 'sites/%s', 'sites/%s')", $old_url, $new_url);
db_query("UPDATE {node_revisions} SET teaser = REPLACE(teaser, 'sites/%s', 'sites/%s')", $old_url, $new_url);
// File paths.
variable_set('file_directory_path', "sites/$new_url/files");
variable_set('file_directory_temp', "sites/$new_url/files/tmp");
// Default user picture.
if ($picture = variable_get('user_picture_default', FALSE)) {
$picture = preg_replace($old_url_pattern, 'sites/' . $new_url, $picture);
variable_set('user_picture_default', $picture);
}
// Global theme settings paths.
if ($var = variable_get('theme_settings', FALSE)) {
$var['logo_path'] = str_replace($old_url, $new_url, $var['logo_path']);
$var['favicon_path'] = str_replace($old_url, $new_url, $var['favicon_path']);
$var['logo_path'] = preg_replace($old_url_pattern, 'sites/' . $new_url, $var['logo_path']);
$var['favicon_path'] = preg_replace($old_url_pattern, 'sites/' . $new_url, $var['favicon_path']);
variable_set('theme_settings', $var);
}
......@@ -54,16 +46,21 @@ $themes = list_themes();
foreach (array_keys($themes) as $theme) {
// Update logo and favicon paths for each theme.
if ($var = variable_get('theme_'. $theme .'_settings', FALSE)) {
$var['logo_path'] = str_replace($old_url, $new_url, $var['logo_path']);
$var['favicon_path'] = str_replace($old_url, $new_url, $var['favicon_path']);
$var['logo_path'] = preg_replace($old_url_pattern, 'sites/' . $new_url, $var['logo_path']);
$var['favicon_path'] = preg_replace($old_url_pattern, 'sites/' . $new_url, $var['favicon_path']);
variable_set('theme_'. $theme .'_settings', $var);
}
// Update color module paths.
if (module_exists('color')) {
foreach (array('_files', '_logo', '_screenshot', '_stylesheets') as $suffix) {
if ($var = variable_get('color_'. $theme . $suffix, FALSE)) {
variable_set('color_'. $theme . $suffix, str_replace($old_url, $new_url, $var));
variable_set('color_'. $theme . $suffix, preg_replace($old_url_pattern, 'sites/' . $new_url, $var));
}
}
}
}
drush_log(
dt('Changed paths from sites/@old_url to sites/@new_url',
array('@old_url' => $old_url, '@new_url' => $new_url)));
<?php
// $Id$
$new_url = d()->uri;
/**
* @deprecated in drush3 it's 'options', in drush 4 it's 'cli', drop
* 'options' when we drop drush3 support
*/
$context = drush_get_context('cli') ? 'cli' : 'options';
$old_url = drush_get_option('old_uri', $new_url, $context);
/**
* @file
* Handle site migration tasks for redeployed sites.
* This is primarily to handle the rename of the sites
* directories.
*/
if (db_table_exists('file_managed')) {
db_query("UPDATE {file_managed} SET uri = REPLACE(uri, :old, :new)", array(':old' => 'sites/default', ':new' => 'sites/$new_url'));
db_query("UPDATE {file_managed} SET uri = REPLACE(uri, :old, :new)", array(':old' => 'sites/$old_url', ':new' => 'sites/$new_url'));
}
if (db_table_exists('files')) {
db_query("UPDATE {files} SET filepath = REPLACE(filepath, :old, :new)", array(':old' => 'sites/$old_url', ':new' => 'sites/$new_url'));
db_query("UPDATE {files} SET filepath = REPLACE(filepath, :old, :new)", array(':old' => 'sites/default', ':new' => 'sites/$new_url'));
}
variable_set('file_public_path', "sites/$new_url/files");
variable_set('file_private_path', "sites/$new_url/private/files");
variable_set('file_temporary_path', "sites/$new_url/private/temp");
drush_log(
dt('Changed paths from sites/@old_url to sites/@new_url',
array('@old_url' => $old_url, '@new_url' => $new_url)));