Commit 609c156d authored by Adrian Rossouw's avatar Adrian Rossouw

Server verify .. _WARNING_ this will break your install.

almost all the variables that used to be set in the platform/drushrc.php are now removed.
you need to verify your server first (done by not specifying a --root, or being in a drupal dir when you run the command).

We need to bootstrap the values from hosting somehow too...
parent ccb00503
...@@ -11,13 +11,14 @@ ...@@ -11,13 +11,14 @@
include_once(dirname(__FILE__) . '/../provision.service.inc'); include_once(dirname(__FILE__) . '/../provision.service.inc');
function db_drush_init() { function db_drush_init($url) {
include_once('mysql/mysql_service.inc'); include_once('mysql/mysql_service.inc');
$command = drush_get_command(); $command = drush_get_command();
$command = explode(" ", $command['command']); $command = explode(" ", $command['command']);
if (preg_match("/^provision-/", $command[0])) { if (preg_match("/^provision-/", $command[0])) {
_provision_context_init($url);
// TODO - remove this shit // TODO - remove this shit
$master_db = drush_get_option('master_db'); $master_db = drush_get_option('master_db');
...@@ -37,6 +38,7 @@ function db_drush_init() { ...@@ -37,6 +38,7 @@ function db_drush_init() {
$pass = drush_prompt(dt("Database password")); $pass = drush_prompt(dt("Database password"));
system('stty echo'); system('stty echo');
print "\n"; # add a cr since the user's didn't echo print "\n"; # add a cr since the user's didn't echo
drush_set_option('master_db', "$scheme://$user:$pass@$host", 'home.drush');
} }
drush_set_default('master_db_user', $user); drush_set_default('master_db_user', $user);
......
...@@ -17,7 +17,10 @@ function drush_db_provision_verify() { ...@@ -17,7 +17,10 @@ function drush_db_provision_verify() {
function drush_db_post_provision_verify() { function drush_db_post_provision_verify() {
if (PROVISION_CONTEXT_PLATFORM) { if (PROVISION_CONTEXT_PLATFORM) {
drush_set_option('master_db', drush_get_option('master_db'), 'drupal'); drush_unset_option('master_db', 'drupal');
}
if (PROVISION_CONTEXT_SERVER) {
drush_set_option('master_db', drush_get_option('master_db'), 'home.drush');
} }
} }
...@@ -47,10 +47,11 @@ class provisionService_http_apache extends provisionService_http { ...@@ -47,10 +47,11 @@ class provisionService_http_apache extends provisionService_http {
if (drush_get_option('platform', null)) { if (drush_get_option('platform', null)) {
$this->create_platform_config(); $this->create_platform_config();
} }
}
elseif (PROVISION_CONTEXT_SERVER) {
$this->create_server_config(); $this->create_server_config();
} }
else { elseif (PROVISION_CONTEXT_SITE) {
$this->create_site_config($url); $this->create_site_config($url);
} }
......
...@@ -6,14 +6,24 @@ function drush_http_provision_verify($url = null) { ...@@ -6,14 +6,24 @@ function drush_http_provision_verify($url = null) {
function drush_http_post_provision_verify($url = null) { function drush_http_post_provision_verify($url = null) {
if (PROVISION_CONTEXT_PLATFORM) { if (PROVISION_CONTEXT_PLATFORM) {
drush_set_option('master_url', drush_get_option('master_url'), 'drupal');
drush_set_option('publish_path', realpath(drush_get_option('publish_path')), 'drupal'); drush_set_option('publish_path', realpath(drush_get_option('publish_path')), 'drupal');
drush_set_option('web_host', drush_get_option('web_host', '127.0.0.1'), 'drupal'); drush_unset_option('master_url', 'drupal');
drush_set_option('web_ip', drush_get_option('web_ip', ''), 'drupal'); drush_unset_option('web_host', 'drupal');
drush_set_option('web_group', drush_get_option('web_group'), 'drupal'); drush_unset_option('web_ip', 'drupal');
drush_set_option('script_user', drush_get_option('script_user'), 'drupal'); drush_unset_option('web_group', 'drupal');
drush_set_option('restart_cmd', drush_get_option('restart_cmd'), 'drupal'); drush_unset_option('script_user', 'drupal');
drush_set_option('backup_path', drush_get_option('backup_path'), 'drupal'); drush_unset_option('restart_cmd', 'drupal');
drush_set_option('config_path', drush_get_option('config_path'), 'drupal'); drush_unset_option('backup_path', 'drupal');
drush_unset_option('config_path', 'drupal');
}
elseif (PROVISION_CONTEXT_SERVER) {
drush_set_option('master_url', drush_get_option('master_url'), 'home.drush');
drush_set_option('web_host', drush_get_option('web_host', '127.0.0.1'), 'home.drush');
drush_set_option('web_ip', drush_get_option('web_ip', ''), 'home.drush');
drush_set_option('web_group', drush_get_option('web_group'), 'home.drush');
drush_set_option('script_user', drush_get_option('script_user'), 'home.drush');
drush_set_option('restart_cmd', drush_get_option('restart_cmd'), 'home.drush');
drush_set_option('backup_path', drush_get_option('backup_path'), 'home.drush');
drush_set_option('config_path', drush_get_option('config_path'), 'home.drush');
} }
} }
...@@ -50,19 +50,35 @@ function provision_drupal_drush_engine_drupal() { ...@@ -50,19 +50,35 @@ function provision_drupal_drush_engine_drupal() {
function provision_drupal_drush_init($url = NULL) { function provision_drupal_drush_init($url = NULL) {
$command = drush_get_command(); $command = drush_get_command();
$command = explode(" ", $command['command']); $command = explode(" ", $command['command']);
if (preg_match("/^provision-/", $command[0])) { if (preg_match("/^provision-/", $command[0])) {
_provision_context_init($url);
}
}
function _provision_context_init($url) {
$context = 'server';
if (drush_bootstrap_validate(DRUSH_BOOTSTRAP_DRUPAL_ROOT)) {
// i don't think i should be bootstrapping here yet ... but i have no choice yet.
drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_ROOT);
$context = 'platform';
if ($url) {
$context = 'site';
drush_set_option('uri' , 'http://' . $url);
drush_set_default('site_url', $url);
drush_set_default('profile', 'default');
drush_set_default('language', 'en');
drush_set_default('aliases', array());
}
if ($url) {
drush_set_option('uri' , 'http://' . $url);
drush_set_default('site_url', $url);
drush_set_default('profile', 'default');
drush_set_default('language', 'en');
drush_set_default('aliases', array());
} }
define('PROVISION_CONTEXT_SITE', ($url) ? TRUE : FALSE); define('PROVISION_CONTEXT_SERVER', $context == 'server');
define('PROVISION_CONTEXT_PLATFORM', !PROVISION_CONTEXT_SITE); define('PROVISION_CONTEXT_PLATFORM', $context == 'platform');
} define('PROVISION_CONTEXT_SITE', $context == 'site');
} }
/** /**
...@@ -85,12 +101,15 @@ function provision_drupal_drush_exit($url = NULL) { ...@@ -85,12 +101,15 @@ function provision_drupal_drush_exit($url = NULL) {
provision_save_site_data($url); provision_save_site_data($url);
} }
} }
else { elseif (PROVISION_CONTEXT_PLATFORM) {
// Generate a drushrc.php for the platform unless it's being deleted // Generate a drushrc.php for the platform unless it's being deleted
if (!preg_match("/^provision-delete/", $command[0])) { if (!preg_match("/^provision-delete/", $command[0])) {
provision_save_platform_data(); provision_save_platform_data();
} }
} }
elseif (PROVISION_CONTEXT_SERVER) {
provision_save_server_data();
}
} }
} }
......
...@@ -43,7 +43,7 @@ function drush_provision_drupal_provision_verify($url = null) { ...@@ -43,7 +43,7 @@ function drush_provision_drupal_provision_verify($url = null) {
drush_set_option('packages', _scrub_object(provision_find_packages()), 'drupal'); drush_set_option('packages', _scrub_object(provision_find_packages()), 'drupal');
_provision_drupal_create_directories('all'); _provision_drupal_create_directories('all');
} }
else { elseif (PROVISION_CONTEXT_SITE) {
drush_set_option('packages', _scrub_object(provision_drupal_system_map()), '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($url); _provision_drupal_create_directories($url);
......
...@@ -115,7 +115,7 @@ function provision_drush_command() { ...@@ -115,7 +115,7 @@ function provision_drush_command() {
$items['provision-verify'] = array( $items['provision-verify'] = array(
'arguments' => array('domain.com' => dt('The domain of the site to verify).')), 'arguments' => array('domain.com' => dt('The domain of the site to verify).')),
'description' => 'Verify that the provisioning framework is correctly installed.', 'description' => 'Verify that the provisioning framework is correctly installed.',
'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_ROOT, 'bootstrap' => DRUSH_BOOTSTRAP_DRUSH,
); );
$items['provision-restore'] = array( $items['provision-restore'] = array(
......
...@@ -47,6 +47,16 @@ function provision_save_platform_data() { ...@@ -47,6 +47,16 @@ function provision_save_platform_data() {
} }
} }
/**
* Save modified options to the drushrc.php file
*/
function provision_save_server_data() {
if (!drush_get_error()) {
$config = new provisionConfig_drushrc_server();
$config->write();
}
}
/** /**
* @} End of "defgroup sitedata". * @} End of "defgroup sitedata".
*/ */
......
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