...
 
Commits (51)
......@@ -184,11 +184,16 @@ class Provision_Config {
*/
function write() {
$filename = $this->filename();
// Debug tmp
drush_log("DEBUG A: filename is $filename");
// Make directory structure if it does not exist.
if ($filename && !provision_file()->exists(dirname($filename))->status()) {
provision_file()->mkdir(dirname($filename))
->succeed('Created directory @path.')
->fail('Could not create directory @path.');
// Debug tmp
$this_dirname = dirname($filename);
drush_log("DEBUG B: this_dirname is $this_dirname");
}
$status = FALSE;
......
......@@ -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';
......@@ -48,5 +53,29 @@ class Provision_Config_Drupal_Settings extends Provision_Config {
// then react to this and change any settings we don't want backed up.
$backup_file = drush_get_option('backup_file');
$this->backup_in_progress = !empty($backup_file);
// Create a blank local.settings.php file if not exists.
$local_settings = $this->site_path . '/local.settings.php';
$local_settings_blank = "<?php # local settings.php \n";
$local_description = 'Drupal local.settings.php file';
if (!provision_file()->exists($local_settings)->status()) {
provision_file()->file_put_contents($local_settings, $local_settings_blank)
->succeed('Generated blank ' . $local_description)
->fail('Could not generate ' . $local_description);
provision_file()->chgrp($local_settings, $this->group)
->succeed('Changed group ownership of <code>@path</code> to @gid')
->fail('Could not change group ownership of <code>@path</code> to @gid');
provision_file()->chmod($local_settings, $this->mode | 0440)
->succeed('Changed permissions of <code>@path</code> to @perm')
->fail('Could not change permissions of <code>@path</code> to @perm');
}
else {
provision_file()->chgrp($local_settings, $this->group)
->succeed('Changed group ownership of <code>@path</code> to @gid')
->fail('Could not change group ownership of <code>@path</code> to @gid');
provision_file()->chmod($local_settings, $this->mode | 0440)
->succeed('Changed permissions of <code>@path</code> to @perm')
->fail('Could not change permissions of <code>@path</code> to @perm');
}
}
}
......@@ -118,11 +118,9 @@ if (isset($_SERVER['db_name'])) {
@ini_set('arg_separator.output', '&amp;');
@ini_set('magic_quotes_runtime', 0);
@ini_set('magic_quotes_sybase', 0);
@ini_set('session.cache_expire', 200000);
@ini_set('session.cache_limiter', 'none');
@ini_set('session.cookie_lifetime', 0);
@ini_set('session.gc_maxlifetime', 200000);
@ini_set('session.save_handler', 'user');
@ini_set('session.use_cookies', 1);
@ini_set('session.use_only_cookies', 1);
@ini_set('session.use_trans_sid', 0);
@ini_set('url_rewriter.tags', '');
......@@ -139,6 +137,17 @@ 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 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 ?>;
......
core = 6.x
; Aegir Provision makefile
;
api = 2
core = 6.x
; BOA-2.3.6
; this makefile fetches the latest Aegir code from git from drupal.org
; it shouldn't really change at all apart from major upgrades, where
......
core = 6.x
; Aegir Provision makefile
;
api = 2
core = 6.x
; BOA-2.3.6
; this makefile fetches the latest release from Drupal.org
; it is maintained through the release.sh script
......
aegir-dev.make
\ No newline at end of file
; Aegir Provision makefile
;
api = 2
core = 6.x
; BOA-2.3.6
projects[pressflow][type] = "core"
projects[pressflow][download][type] = "get"
projects[pressflow][download][url] = "http://files.aegir.cc/core/pressflow-6.33.1.tar.gz"
projects[hostmaster][type] = "profile"
projects[hostmaster][download][type] = "get"
projects[hostmaster][download][url] = "http://files.aegir.cc/versions/stable/tar/hostmaster-BOA-2.3.6.tar.gz"
......@@ -55,6 +55,9 @@ class Provision_Service_db_mysql extends Provision_Service_db_pdo {
}
function grant($name, $username, $password, $host = '') {
if (provision_file()->exists('/data/conf/clstr.cnf')->status()) {
$host = '%';
}
$host = ($host) ? $host : '%';
if ($host != "127.0.0.1") {
$extra_host = "127.0.0.1";
......@@ -65,6 +68,9 @@ class Provision_Service_db_mysql extends Provision_Service_db_pdo {
}
function revoke($name, $username, $host = '') {
if (provision_file()->exists('/data/conf/clstr.cnf')->status()) {
$host = '%';
}
$host = ($host) ? $host : '%';
$success = $this->query("REVOKE ALL PRIVILEGES ON `%s`.* FROM `%s`@`%s`", $name, $username, $host);
......@@ -148,7 +154,7 @@ class Provision_Service_db_mysql extends Provision_Service_db_pdo {
// non-readable by the webserver.
umask(0077);
// Mixed copy-paste of drush_shell_exec and provision_shell_exec.
$cmd = sprintf("mysqldump --defaults-file=/dev/fd/3 --single-transaction --quick %s | sed 's|/\\*!50001 CREATE ALGORITHM=UNDEFINED \\*/|/\\*!50001 CREATE \\*/|g; s|/\\*!50017 DEFINER=`[^`]*`@`[^`]*`\s*\\*/||g' | sed '/\\*!50013 DEFINER=.*/ d' > %s/database.sql", escapeshellcmd(drush_get_option('db_name')), escapeshellcmd(d()->site_path));
$cmd = sprintf("mysqldump --defaults-file=/dev/fd/3 --opt --skip-lock-tables --order-by-primary --default-character-set=utf8 -Q --hex-blob --single-transaction --quick %s | sed 's|/\\*!50001 CREATE ALGORITHM=UNDEFINED \\*/|/\\*!50001 CREATE \\*/|g; s|/\\*!50017 DEFINER=`[^`]*`@`[^`]*`\s*\\*/||g' | sed '/\\*!50013 DEFINER=.*/ d' > %s/database.sql", escapeshellcmd(drush_get_option('db_name')), escapeshellcmd(d()->site_path));
$success = $this->safe_shell_exec($cmd, drush_get_option('db_host'), urldecode(drush_get_option('db_user')), urldecode(drush_get_option('db_passwd')));
$dump_size_too_small = filesize(d()->site_path . '/database.sql') < 1024;
......
......@@ -45,7 +45,7 @@ Description: mass Drupal hosting system - frontend
.
This package provides the frontend web interface that users generally
interact with. It's made up of a regular Drupal site with a custom
install profile, module and theme.
installation profile, module and theme.
.
This meta-package will dynamically install the frontend using drush
and provision and as such doesn't bundle any files itself. Everything
......
......@@ -48,6 +48,13 @@ if ($is_crawler) {
return 403;
}
###
### Block semalt botnet.
###
if ($is_botnet) {
return 403;
}
###
### Include high load protection config if exists.
###
......@@ -164,7 +171,9 @@ location = /fpm-status {
access_log off;
allow 127.0.0.1;
deny all;
<?php if ($phpfpm_mode == 'port'): ?>
<?php if ($satellite_mode == 'boa'): ?>
fastcgi_pass unix:/var/run/www53.fpm.socket;
<?php elseif ($phpfpm_mode == 'port'): ?>
fastcgi_pass 127.0.0.1:9000;
<?php else: ?>
fastcgi_pass unix:/var/run/php5-fpm.sock;
......@@ -178,7 +187,9 @@ location = /fpm-ping {
access_log off;
allow 127.0.0.1;
deny all;
<?php if ($phpfpm_mode == 'port'): ?>
<?php if ($satellite_mode == 'boa'): ?>
fastcgi_pass unix:/var/run/www53.fpm.socket;
<?php elseif ($phpfpm_mode == 'port'): ?>
fastcgi_pass 127.0.0.1:9000;
<?php else: ?>
fastcgi_pass unix:/var/run/php5-fpm.sock;
......@@ -200,7 +211,9 @@ location = /cron.php {
deny all;
<?php endif; ?>
try_files $uri =404;
<?php if ($phpfpm_mode == 'port'): ?>
<?php if ($satellite_mode == 'boa'): ?>
fastcgi_pass unix:/var/run/www53.fpm.socket;
<?php elseif ($phpfpm_mode == 'port'): ?>
fastcgi_pass 127.0.0.1:9000;
<?php else: ?>
fastcgi_pass unix:/var/run/php5-fpm.sock;
......@@ -220,7 +233,9 @@ location = /core/cron.php {
deny all;
<?php endif; ?>
try_files $uri =404;
<?php if ($phpfpm_mode == 'port'): ?>
<?php if ($satellite_mode == 'boa'): ?>
fastcgi_pass unix:/var/run/www53.fpm.socket;
<?php elseif ($phpfpm_mode == 'port'): ?>
fastcgi_pass 127.0.0.1:9000;
<?php else: ?>
fastcgi_pass unix:/var/run/php5-fpm.sock;
......@@ -798,7 +813,9 @@ location ~* /(?:modules|libraries)/(?:contrib/)?(?:ad|tinybrowser|f?ckeditor|tin
return 403;
}
try_files $uri =404;
<?php if ($phpfpm_mode == 'port'): ?>
<?php if ($satellite_mode == 'boa'): ?>
fastcgi_pass unix:/var/run/www53.fpm.socket;
<?php elseif ($phpfpm_mode == 'port'): ?>
fastcgi_pass 127.0.0.1:9000;
<?php else: ?>
fastcgi_pass unix:/var/run/php5-fpm.sock;
......@@ -941,7 +958,13 @@ location ~ ^/(?<esi>esi/.*)"$ {
###
fastcgi_param QUERY_STRING q=$esi;
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
<?php if ($satellite_mode == 'boa'): ?>
fastcgi_pass unix:/var/run/www53.fpm.socket;
<?php elseif ($phpfpm_mode == 'port'): ?>
fastcgi_pass 127.0.0.1:9000;
<?php else: ?>
fastcgi_pass unix:/var/run/php5-fpm.sock;
<?php endif; ?>
###
### Use Nginx cache for all visitors.
###
......@@ -1080,7 +1103,9 @@ location = /index.php {
tcp_nopush off;
keepalive_requests 0;
try_files $uri =404; ### check for existence of php file first
<?php if ($phpfpm_mode == 'port'): ?>
<?php if ($satellite_mode == 'boa'): ?>
fastcgi_pass unix:/var/run/www53.fpm.socket;
<?php elseif ($phpfpm_mode == 'port'): ?>
fastcgi_pass 127.0.0.1:9000;
<?php else: ?>
fastcgi_pass unix:/var/run/php5-fpm.sock;
......@@ -1131,7 +1156,9 @@ location ~* ^/(?:index|cron|boost_stats|update|authorize)\.php$ {
keepalive_requests 0;
access_log off;
try_files $uri =404; ### check for existence of php file first
<?php if ($phpfpm_mode == 'port'): ?>
<?php if ($satellite_mode == 'boa'): ?>
fastcgi_pass unix:/var/run/www53.fpm.socket;
<?php elseif ($phpfpm_mode == 'port'): ?>
fastcgi_pass 127.0.0.1:9000;
<?php else: ?>
fastcgi_pass unix:/var/run/php5-fpm.sock;
......@@ -1159,7 +1186,9 @@ location @allowupdate {
keepalive_requests 0;
access_log off;
try_files $uri =404; ### check for existence of php file first
<?php if ($phpfpm_mode == 'port'): ?>
<?php if ($satellite_mode == 'boa'): ?>
fastcgi_pass unix:/var/run/www53.fpm.socket;
<?php elseif ($phpfpm_mode == 'port'): ?>
fastcgi_pass 127.0.0.1:9000;
<?php else: ?>
fastcgi_pass unix:/var/run/php5-fpm.sock;
......
......@@ -222,7 +222,17 @@ map $request_uri $key_uri {
###
map $http_user_agent $is_crawler {
default '';
~*HTTrack|BrokenLinkCheck|2009042316.*Firefox.*3\.0\.10|MJ12|HTMLParser|PECL|Automatic|SiteBot|BuzzTrack|Sistrix|Offline|Nutch|Mireo|SWEB|Morfeus|GSLFbot|HiScan|Riddler|DBot|CCBot is_crawler;
~*HTTrack|BrokenLinkCheck|2009042316.*Firefox.*3\.0\.10|MJ12|HTMLParser|PECL|Automatic|CCBot is_crawler;
~*SiteBot|BuzzTrack|Sistrix|Offline|Nutch|Mireo|SWEB|Morfeus|GSLFbot|HiScan|Riddler|DBot is_crawler;
}
###
### Block semalt botnet.
###
map $http_referer $is_botnet {
default '';
~*semalt\.com|kambasoft\.com|savetubevideo\.com|bottlenose\.com|yapoga\.com is_botnet;
~*descargar-musica-gratis\.net|baixar-musicas-gratis\.com is_botnet;
}
###
......
......@@ -55,6 +55,13 @@ location ^~ /<?php print $subdir; ?> {
return 403;
}
###
### Block semalt botnet.
###
if ($is_botnet) {
return 403;
}
###
### Include high load protection config if exists.
###
......@@ -189,7 +196,9 @@ location ^~ /<?php print $subdir; ?>/cdn/farfuture/ {
deny all;
<?php endif; ?>
try_files /cron.php $uri =404;
<?php if ($phpfpm_mode == 'port'): ?>
<?php if ($satellite_mode == 'boa'): ?>
fastcgi_pass unix:/var/run/www53.fpm.socket;
<?php elseif ($phpfpm_mode == 'port'): ?>
fastcgi_pass 127.0.0.1:9000;
<?php else: ?>
fastcgi_pass unix:/var/run/php5-fpm.sock;
......@@ -565,7 +574,9 @@ location ^~ /<?php print $subdir; ?>/cdn/farfuture/ {
return 403;
}
try_files /$1 $uri =404;
<?php if ($phpfpm_mode == 'port'): ?>
<?php if ($satellite_mode == 'boa'): ?>
fastcgi_pass unix:/var/run/www53.fpm.socket;
<?php elseif ($phpfpm_mode == 'port'): ?>
fastcgi_pass 127.0.0.1:9000;
<?php else: ?>
fastcgi_pass unix:/var/run/php5-fpm.sock;
......@@ -745,10 +756,12 @@ location ^~ /<?php print $subdir; ?>/cdn/farfuture/ {
keepalive_requests 0;
access_log off;
try_files /$1.php =404; ### check for existence of php file first
<?php if ($phpfpm_mode == 'port'): ?>
fastcgi_pass 127.0.0.1:9000;
<?php if ($satellite_mode == 'boa'): ?>
fastcgi_pass unix:/var/run/www53.fpm.socket;
<?php elseif ($phpfpm_mode == 'port'): ?>
fastcgi_pass 127.0.0.1:9000;
<?php else: ?>
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_pass unix:/var/run/php5-fpm.sock;
<?php endif; ?>
}
......@@ -818,7 +831,9 @@ location ^~ /<?php print $subdir; ?>/cdn/farfuture/ {
tcp_nopush off;
keepalive_requests 0;
try_files /index.php =404; ### check for existence of php file first
<?php if ($phpfpm_mode == 'port'): ?>
<?php if ($satellite_mode == 'boa'): ?>
fastcgi_pass unix:/var/run/www53.fpm.socket;
<?php elseif ($phpfpm_mode == 'port'): ?>
fastcgi_pass 127.0.0.1:9000;
<?php else: ?>
fastcgi_pass unix:/var/run/php5-fpm.sock;
......@@ -959,7 +974,9 @@ location @allowupdate_<?php print $subdir; ?> {
access_log off;
try_files /$real_fastcgi_script_name =404; ### check for existence of php file first
<?php if ($phpfpm_mode == 'port'): ?>
<?php if ($satellite_mode == 'boa'): ?>
fastcgi_pass unix:/var/run/www53.fpm.socket;
<?php elseif ($phpfpm_mode == 'port'): ?>
fastcgi_pass 127.0.0.1:9000;
<?php else: ?>
fastcgi_pass unix:/var/run/php5-fpm.sock;
......
......@@ -162,5 +162,8 @@ function drush_provision_post_hostmaster_migrate($site, $platform) {
'old_platform_name' => drush_get_option('old_platform'),
'new_platform_name' => drush_get_option('new_platform'),
));
// We need to re-verify @server_master via frontend to re-generate
// its drush alias and to update Nginx configuration files.
provision_backend_invoke('@hostmaster', 'hosting-task', array(@server_master, 'verify'), array('force' => TRUE));
}
......@@ -20,7 +20,7 @@ function drush_provision_drupal_provision_backup_validate($backup_file = NULL) {
drush_set_error('PROVISION_DRUPAL_SITE_NOT_FOUND');
}
// This is the actual drupal provisioning requirements.
// This is the actual drupal provisioning requirements.
if (!is_dir(d()->platform->server->backup_path)) {
drush_set_error('PROVISION_BACKUP_PATH_NOT_FOUND');
}
......@@ -126,7 +126,7 @@ function drush_provision_drupal_post_provision_backup() {
*/
function drush_provision_drupal_provision_backup_rollback() {
$backup_file = drush_get_option('backup_file');
if (file_exists($backup_file)) {
if (is_readable($backup_file) && is_file($backup_file)) {
provision_file()->unlink($backup_file)
->succeed('Removed stale backup file @path')
->fail('Failed deleting backup file @path');
......
......@@ -38,6 +38,19 @@ function drush_provision_drupal_pre_provision_clone_rollback($new_uri, $platform
function drush_provision_drupal_provision_clone($new_uri, $platform = null) {
drush_set_option('old_platform', d()->platform->name);
// If the site is cloned between platforms and not just in the same platform,
// we should update the info collected about source and target platform first.
if (!is_null(d($platform)->name) && (d($platform)->name != d()->platform->name)) {
provision_backend_invoke('@hostmaster', 'hosting-task', array(d()->platform->name, 'verify'), array('force' => TRUE));
sleep(5); // A small trick to avoid high load and race conditions.
provision_backend_invoke('@hostmaster', 'hosting-task', array(d($platform)->name, 'verify'), array('force' => TRUE));
sleep(5); // A small trick to avoid high load and race conditions.
}
// We should update also the info collected about the site before running clone.
$local_uri_verify = '@' . d()->uri;
provision_backend_invoke('@hostmaster', 'hosting-task', array($local_uri_verify, 'verify'), array('force' => TRUE));
sleep(5); // A small trick to avoid high load and race conditions.
$options = d()->options;
$options['uri'] = ltrim($new_uri, '@');
$hash_name = drush_get_option('#name') ? '#name' : 'name';
......@@ -54,6 +67,10 @@ function drush_provision_drupal_provision_clone($new_uri, $platform = null) {
$options['ssl_enabled'] = 0;
unset($options['ssl_key']);
// Do not copy CDN aliases to the cloned site --CDN vhost
$options['cdn'] = 0;
unset($options['cdn']);
if ($profile = drush_get_option('profile', FALSE)) {
$options['profile'] = $profile;
}
......@@ -68,7 +85,11 @@ function drush_provision_drupal_provision_clone($new_uri, $platform = null) {
provision_backend_invoke($new_uri, 'provision-deploy', array(drush_get_option('backup_file')), array('old_uri' => d()->uri));
if (!drush_get_error()) {
// Verify the newly cloned site.
provision_backend_invoke($new_uri, 'provision-verify');
sleep(5); // A small trick to avoid high load and race conditions.
// Verify again also original site via frontend to avoid issue #1004526
provision_backend_invoke('@hostmaster', 'hosting-task', array($local_uri_verify, 'verify'), array('force' => TRUE));
}
provision_reload_config('site', d()->site_path . '/drushrc.php');
......
......@@ -4,8 +4,40 @@
* Rebuild all the caches
*/
module_list(TRUE, FALSE);
module_rebuild_cache();
drush_log(dt('Rebuilt module cache'));
cache_clear_all('*', 'cache_form', TRUE); // This bin is excluded in drupal_flush_all_caches()
// but if not purged, it may break tasks with
// mysterious errors thanks to garbage collected.
drupal_flush_all_caches();
drush_log(dt('All caches flushed'));
// function drupal_flush_all_caches() {
// // Change query-strings on css/js files to enforce reload for all users.
// _drupal_flush_css_js();
//
// drupal_clear_css_cache();
// drupal_clear_js_cache();
//
// // If invoked from update.php, we must not update the theme information in the
// // database, or this will result in all themes being disabled.
// if (defined('MAINTENANCE_MODE') && MAINTENANCE_MODE == 'update') {
// _system_theme_data();
// }
// else {
// system_theme_data();
// }
//
// drupal_rebuild_theme_registry();
// menu_rebuild();
// node_types_rebuild();
// // Don't clear cache_form - in-progress form submissions may break.
// // Ordered so clearing the page cache will always be the last action.
// $core = array('cache', 'cache_block', 'cache_filter', 'cache_page');
// $cache_tables = array_merge(module_invoke_all('flush_caches'), $core);
// foreach ($cache_tables as $table) {
// cache_clear_all('*', $table, TRUE);
// }
// }
......@@ -4,5 +4,50 @@
* Rebuild all the caches
*/
cache_clear_all('*', 'cache_form', TRUE); // This bin is excluded in drupal_flush_all_caches()
// but if not purged, it may break tasks with
// mysterious errors thanks to garbage collected.
drupal_flush_all_caches();
drush_log(dt('All caches flushed'));
// function drupal_flush_all_caches() {
// // Change query-strings on css/js files to enforce reload for all users.
// _drupal_flush_css_js();
//
// registry_rebuild();
// drupal_clear_css_cache();
// drupal_clear_js_cache();
//
// // Rebuild the theme data. Note that the module data is rebuilt above, as
// // part of registry_rebuild().
// system_rebuild_theme_data();
// drupal_theme_rebuild();
//
// entity_info_cache_clear();
// node_types_rebuild();
// // node_menu() defines menu items based on node types so it needs to come
// // after node types are rebuilt.
// menu_rebuild();
//
// // Synchronize to catch any actions that were added or removed.
// actions_synchronize();
//
// // Don't clear cache_form - in-progress form submissions may break.
// // Ordered so clearing the page cache will always be the last action.
// $core = array(
// 'cache',
// 'cache_path',
// 'cache_filter',
// 'cache_bootstrap',
// 'cache_page',
// );
// $cache_tables = array_merge(module_invoke_all('flush_caches'), $core);
// foreach ($cache_tables as $table) {
// cache_clear_all('*', $table, TRUE);
// }
//
// // Rebuild the bootstrap module list. We do this here so that developers
// // can get new hook_boot() implementations registered without having to
// // write a hook_update_N() function.
// _system_update_bootstrap_status();
// }
......@@ -7,7 +7,7 @@ if ($db = $databases['default']['default']) {
drush_set_option('db_passwd', urldecode($db['password']), 'site');
drush_set_option('db_name', urldecode($db['database']), 'site');
drush_set_option('profile', variable_get('install_profile', 'default'), 'site');
drush_set_option('profile', variable_get('install_profile', 'standard'), 'site');
$language = language_default();
drush_set_option('language', $language->language, 'site');
}
......@@ -35,14 +35,18 @@ function install_verify_settings() {
// @todo why are we setting those variables if they are not
// reachable outside this scope?!
$url = parse_url(is_array($db_url) ? $db_url['default'] : $db_url);
$db_user = urldecode($url['user']);
$db_pass = urldecode($url['pass']);
$db_host = urldecode($url['host']);
$db_port = isset($url['port']) ? urldecode($url['port']) : '3306';
$db_path = ltrim(urldecode($url['path']), '/');
$settings_file = './'. conf_path() .'/settings.php';
return TRUE;
if (!empty($url['user']) && !empty($url['pass']) && !empty($url['host'])) {
$db_user = urldecode($url['user']);
$db_pass = urldecode($url['pass']);
$db_host = urldecode($url['host']);
$db_port = isset($url['port']) ? urldecode($url['port']) : '3306';
$db_path = ltrim(urldecode($url['path']), '/');
$settings_file = './'. conf_path() .'/settings.php';
return TRUE;
}
else {
return FALSE;
}
}
return FALSE;
}
......@@ -231,6 +235,7 @@ function install_main() {
db_query("INSERT INTO {system} (filename, name, type, owner, status, throttle, bootstrap, schema_version) VALUES('%s', '%s', '%s', '%s', %d, %d, %d, %d)", $system_path .'/system.module', 'system', 'module', '', 1, 0, 0, $system_version);
// Now that we've installed things properly, bootstrap the full Drupal environment
module_list(TRUE, FALSE);
module_rebuild_cache();
drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_FULL);
$modules = array_diff($modules, array('system'));
......@@ -296,6 +301,7 @@ function install_main() {
if (function_exists($function)) {
while (!in_array($task, array('profile-finished', 'finished'))) {
drush_log(dt("Running profile specific task : !task", array('!task' => $task)));
module_list(TRUE, FALSE);
module_rebuild_cache();
module_load_all();
// stop batch api from re-directing. ever.
......
......@@ -34,8 +34,14 @@ function drush_provision_drupal_post_provision_import() {
// Do not automatically save the drushrc at the end of the command.
drush_set_option('provision_save_config', false);
// We run this original verify via backend to avoid unexpected issues.
provision_backend_invoke(d()->name, 'provision-verify');
sleep(5); // A small trick to avoid high load and race conditions.
// We run this extra verify via frontend to avoid issue #1004526.
provision_backend_invoke('@hostmaster', 'hosting-task', array(d()->name, 'verify'), array('force' => TRUE));
drush_include_engine('drupal', 'cron_key');
provision_reload_config('site');
......
......@@ -81,11 +81,64 @@ function drush_provision_drupal_provision_migrate($platform, $new_uri = NULL) {
$options['uri'] = d()->uri;
// If the site is migrated between platforms and not just renamed,
// we should update the info collected about source and target platform first.
// Note that we have to exclude Hostmaster platform from this extra verify.
if (d()->profile != 'hostmaster') {
if (!is_null(d($platform)->name) && (d($platform)->name != d()->platform->name)) {
provision_backend_invoke('@hostmaster', 'hosting-task', array(d()->platform->name, 'verify'), array('force' => TRUE));
sleep(5); // A small trick to avoid high load and race conditions.
provision_backend_invoke('@hostmaster', 'hosting-task', array(d($platform)->name, 'verify'), array('force' => TRUE));
sleep(5); // A small trick to avoid high load and race conditions.
}
}
if (!is_null($new_uri) && ($new_uri != d()->uri)) {
$options = d()->options;
$options['uri'] = ltrim($new_uri, '@');
$hash_name = drush_get_option('#name') ? '#name' : 'name';
$options[$hash_name] = $new_uri;
$new_aliases = array();
$old_aliases = (is_array($options['aliases'])) ? $options['aliases'] : FALSE;
$pre_old_uri = ltrim(d()->uri, '@');
$pre_new_uri = ltrim($new_uri, '@');
$raw_old_uri = preg_replace('/^www\./', '', $pre_old_uri);
$raw_new_uri = preg_replace('/^www\./', '', $pre_new_uri);
$www_old_uri = "www." . $raw_old_uri;
$www_new_uri = "www." . $raw_new_uri;
if (is_array($old_aliases)) {
foreach ($old_aliases as $alias) {
if (!preg_match("/^www\./", $pre_old_uri) && preg_match("/^www\./", $pre_new_uri)) {
$new_aliases[] = str_replace($www_old_uri, $raw_new_uri, $alias);
}
elseif (preg_match("/^www\./", $pre_old_uri) && !preg_match("/^www\./", $pre_new_uri)) {
$new_aliases[] = str_replace($raw_old_uri, $www_new_uri, $alias);
}
elseif (!preg_match("/^www\./", $pre_old_uri) && !preg_match("/^www\./", $pre_new_uri)) {
$new_aliases[] = str_replace($www_old_uri, $www_new_uri, $alias);
}
elseif (preg_match("/^www\./", $pre_old_uri) && preg_match("/^www\./", $pre_new_uri)) {
$new_aliases[] = str_replace($raw_old_uri, $raw_new_uri, $alias);
}
}
$unique_aliases = array_unique($new_aliases); // Make sure there are no duplicates.
$options['aliases'] = array(); // Reset original aliases array.
$options['aliases'] = $unique_aliases; // Use rewritten aliases array.
}
// Warning: do not try to re-verify the original site here
// even with backend-only verify, because it would create
// (and never delete) duplicate vhost with old domain
// and all aliases included - see issue #1067702.
}
else {
// We have to exclude Hostmaster site from any extra verify steps.
if (d()->profile != 'hostmaster') {
// We should update also the info collected about the site before running migrate task.
// Doing this is safe only when the site is migrated with the same name - see issue #1067702.
$local_uri_verify = '@' . d()->uri;
provision_backend_invoke('@hostmaster', 'hosting-task', array($local_uri_verify, 'verify'), array('force' => TRUE));
sleep(5); // A small trick to avoid high load and race conditions.
}
}
$options['platform'] = $platform;
$options['root'] = d($platform)->root;
......@@ -135,8 +188,6 @@ function drush_provision_drupal_post_provision_migrate($platform, $new_uri = NUL
d()->service('http')->sync(d()->site_path);
}
if (!is_null($new_uri) && ($new_uri != d()->uri)) {
// remove the existing alias
$config = new Provision_Config_Drushrc_Alias(d()->name);
......
This diff is collapsed.
......@@ -9,14 +9,15 @@ function drush_provision_drupal_provision_verify_validate() {
if (d()->type === 'site') {
drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_SITE);
provision_prepare_environment();
_provision_drupal_create_settings_file();
provision_drupal_push_site();
drush_errors_on();
if (drush_drupal_major_version() < 8 && d()->profile != 'hostmaster') {
provision_backend_invoke(d()->name, 'registry-rebuild');
drush_log(dt('Completed registry-rebuild without --no-cache-clear option'));
}
drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_FULL);
}
}
......@@ -29,9 +30,9 @@ function drush_provision_drupal_pre_provision_verify() {
$config_root = dirname(d()->config_path);
provision_file()->create_dir($config_root, dt('Provision configuration root'), 0711);
provision_file()->create_dir(d()->config_path, dt('Provision configuration'), 0711);
provision_file()->create_dir(d()->clients_path, dt('Provision client home'), 0711);
provision_file()->create_dir(d()->clients_path, dt('Provision client home'), 0750);
if (d()->name == '@server_master') {
provision_file()->create_dir(d()->backup_path, dt('Backup'), 0700);
provision_file()->create_dir(d()->backup_path, dt('Backup'), 0750);
provision_file()->create_dir(d()->include_path, dt('Provision PHP configuration'), 0711);
if (!provision_file()->exists(d()->include_path . '/global.inc')->succeed('Global configuration file exists')->status()) {
// Create an empty global.inc so the include doesn't fail with
......@@ -75,14 +76,96 @@ function drush_provision_drupal_pre_provision_verify() {
->succeed('Drupal sites directory @path is writable by the provisioning script')
->fail('Drupal sites directory @path is not writable by the provisioning script', 'PROVISION_SITES_DIR_NOT_WRITABLE');
drush_set_option('sites', array_keys((array) provision_drupal_find_sites()), 'drupal');
drush_set_option('sites', array_keys((array) provision_drupal_find_sites()), 'drupal');
drush_log(dt("This platform is running @short_name @version", array('@short_name' => 'drupal', '@version' => VERSION)));
drush_set_option('packages', _scrub_object(provision_find_packages()), 'drupal');
// Determine latest BOA contrib directory name and add INI template if missing.
$pathAll = '/data/all/';
$pathDrc = d()->root . '/sites/all/drush';
$iniFile = d()->root . '/sites/all/modules/default.boa_platform_control.ini';
$iniTpl = '/data/conf/default.boa_platform_control.ini';
if (!provision_file()->exists($iniFile)->status() && provision_file()->exists($iniTpl)->status()) {
provision_file()->copy($iniTpl, $iniFile);
}
if (!preg_match("/\/static\//", d()->root)) {
if (d()->profile != 'hostmaster') {
provision_file()->chmod(d()->root . '/sites/all/modules', 02775)
->succeed('Changed permissions of <code>@path</code> to @perm')
->fail('Could not change permissions of <code>@path</code> to @perm');
provision_file()->chmod(d()->root . '/sites/all/themes', 02775)
->succeed('Changed permissions of <code>@path</code> to @perm')
->fail('Could not change permissions of <code>@path</code> to @perm');
provision_file()->chmod(d()->root . '/sites/all/libraries', 02775)
->succeed('Changed permissions of <code>@path</code> to @perm')
->fail('Could not change permissions of <code>@path</code> to @perm');
}
provision_file()->chmod(d()->root . '/sites/all', 0751)
->succeed('Changed permissions of <code>@path</code> to @perm')
->fail('Could not change permissions of <code>@path</code> to @perm');
provision_file()->chmod(d()->root . '/sites', 0751)
->succeed('Changed permissions of <code>@path</code> to @perm')
->fail('Could not change permissions of <code>@path</code> to @perm');
}
if (provision_file()->exists($pathDrc)->status()) {
provision_file()->chmod(d()->root . '/sites/all/drush', 0700)
->succeed('Changed permissions of <code>@path</code> to @perm')
->fail('Could not change permissions of <code>@path</code> to @perm');
}
if (provision_file()->exists($pathAll)->status() && preg_match("/\/static\//", d()->root)) {
$sortedDirs = array();
foreach(scandir($pathAll) as $dir) {
if(is_dir($pathAll . $dir)) {
array_push($sortedDirs, $dir);
}
}
$latestDir = max($sortedDirs);
drush_log(dt('Contrib latestDir: !latest', array('!latest' => $latestDir)), 'message');
if (is_numeric($latestDir)) {
$core6_contrib_dir = '/data/all/' . $latestDir . '/o_contrib';
$core7_contrib_dir = '/data/all/' . $latestDir . '/o_contrib_seven';
}
else {
$core6_contrib_dir = '/data/all/000/modules/o_contrib';
$core7_contrib_dir = '/data/all/000/modules/o_contrib_seven';
}
$core6_version_id = d()->root . '/modules/path_alias_cache';
$core6_contrib_symlink = d()->root . '/modules/o_contrib';
$core7_version_id = d()->root . '/modules/overlay';
$core7_contrib_symlink = d()->root . '/modules/o_contrib_seven';
// Make sure the core modules directory is writable, but only if it is a BOA system.
if (provision_file()->exists($core6_contrib_dir)->status() || provision_file()->exists($core7_contrib_dir)->status()) {
provision_file()->writable(d()->root . '/modules')
->succeed('Drupal core modules directory @path is writable by the provisioning script')
->fail('Drupal core modules directory @path is not writable by the provisioning script', 'PROVISION_MODULES_DIR_NOT_WRITABLE');
}
// Add symlink to BOA specific contrib in Pressflow 6.
if (provision_file()->exists($core6_contrib_dir)->status() && provision_file()->exists($core6_version_id)->status() && !provision_file()->exists($core6_contrib_symlink)->status()) {
provision_file()->symlink($core6_contrib_dir, $core6_contrib_symlink)
->succeed('Created symlink @path to @target')
->fail('Could not create symlink @path to @target: @reason');
}
// Add symlink to BOA specific contrib in Drupal 7.
if (provision_file()->exists($core7_contrib_dir)->status() && provision_file()->exists($core7_version_id)->status() && !provision_file()->exists($core7_contrib_symlink)->status()) {
provision_file()->symlink($core7_contrib_dir, $core7_contrib_symlink)
->succeed('Created symlink @path to @target')
->fail('Could not create symlink @path to @target: @reason');
}
}
provision_drupal_push_site();
}
elseif (d()->type === 'site') {
drush_set_option('packages', _scrub_object(provision_drupal_system_map()), 'site');
// This is the actual drupal provisioning requirements.
// This is the actual drupal provisioning requirements.
_provision_drupal_create_directories();
_provision_drupal_maintain_aliases();
_provision_drupal_ensure_htaccess_update();
......@@ -111,6 +194,13 @@ function drush_provision_drupal_post_provision_verify() {
_provision_client_create_symlink();
drush_include_engine('drupal', 'cron_key');
$iniFile = d()->root . '/sites/' . d()->uri . '/modules/default.boa_site_control.ini';
$iniTpl = '/data/conf/default.boa_site_control.ini';
if (!provision_file()->exists($iniFile)->status() && provision_file()->exists($iniTpl)->status()) {
provision_file()->copy($iniTpl, $iniFile);
}
}
}
......@@ -430,7 +430,7 @@ function provision_count_cpus() {
*
* We base our evaluation on the number of CPUs on the servers. If there are
* more than 5 processes waiting per CPU, we abort completely. If we ignore the
* number of available CPUs, we assume a critical limit is a load of 10.
* number of available CPUs, we assume a critical limit is a load of 50.
*
* @see sys_getloadavg()
*/
......@@ -443,8 +443,8 @@ function provision_load_critical($load = NULL, $threshold = NULL) {
$threshold = $ncpus * 5;
}
else {
// can't determine the number of CPU, we hardcode at load 10
$threshold = 10;
// can't determine the number of CPU, we hardcode at load 50
$threshold = 50;
}
}
return ($load[0] > $threshold);
......