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 @@
include_once(dirname(__FILE__) . '/../provision.service.inc');
function db_drush_init() {
function db_drush_init($url) {
include_once('mysql/mysql_service.inc');
$command = drush_get_command();
$command = explode(" ", $command['command']);
if (preg_match("/^provision-/", $command[0])) {
_provision_context_init($url);
// TODO - remove this shit
$master_db = drush_get_option('master_db');
......@@ -37,6 +38,7 @@ function db_drush_init() {
$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", 'home.drush');
}
drush_set_default('master_db_user', $user);
......
......@@ -17,7 +17,10 @@ function drush_db_provision_verify() {
function drush_db_post_provision_verify() {
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 {
if (drush_get_option('platform', null)) {
$this->create_platform_config();
}
}
elseif (PROVISION_CONTEXT_SERVER) {
$this->create_server_config();
}
else {
elseif (PROVISION_CONTEXT_SITE) {
$this->create_site_config($url);
}
......
......@@ -6,14 +6,24 @@ function drush_http_provision_verify($url = null) {
function drush_http_post_provision_verify($url = null) {
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('web_host', drush_get_option('web_host', '127.0.0.1'), 'drupal');
drush_set_option('web_ip', drush_get_option('web_ip', ''), 'drupal');
drush_set_option('web_group', drush_get_option('web_group'), 'drupal');
drush_set_option('script_user', drush_get_option('script_user'), 'drupal');
drush_set_option('restart_cmd', drush_get_option('restart_cmd'), 'drupal');
drush_set_option('backup_path', drush_get_option('backup_path'), 'drupal');
drush_set_option('config_path', drush_get_option('config_path'), 'drupal');
drush_unset_option('master_url', 'drupal');
drush_unset_option('web_host', 'drupal');
drush_unset_option('web_ip', 'drupal');
drush_unset_option('web_group', 'drupal');
drush_unset_option('script_user', 'drupal');
drush_unset_option('restart_cmd', '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,9 +50,21 @@ function provision_drupal_drush_engine_drupal() {
function provision_drupal_drush_init($url = NULL) {
$command = drush_get_command();
$command = explode(" ", $command['command']);
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');
......@@ -60,9 +72,13 @@ function provision_drupal_drush_init($url = NULL) {
drush_set_default('aliases', array());
}
define('PROVISION_CONTEXT_SITE', ($url) ? TRUE : FALSE);
define('PROVISION_CONTEXT_PLATFORM', !PROVISION_CONTEXT_SITE);
}
define('PROVISION_CONTEXT_SERVER', $context == 'server');
define('PROVISION_CONTEXT_PLATFORM', $context == 'platform');
define('PROVISION_CONTEXT_SITE', $context == 'site');
}
/**
......@@ -85,12 +101,15 @@ function provision_drupal_drush_exit($url = NULL) {
provision_save_site_data($url);
}
}
else {
elseif (PROVISION_CONTEXT_PLATFORM) {
// Generate a drushrc.php for the platform unless it's being deleted
if (!preg_match("/^provision-delete/", $command[0])) {
provision_save_platform_data();
}
}
elseif (PROVISION_CONTEXT_SERVER) {
provision_save_server_data();
}
}
}
......
......@@ -43,7 +43,7 @@ function drush_provision_drupal_provision_verify($url = null) {
drush_set_option('packages', _scrub_object(provision_find_packages()), 'drupal');
_provision_drupal_create_directories('all');
}
else {
elseif (PROVISION_CONTEXT_SITE) {
drush_set_option('packages', _scrub_object(provision_drupal_system_map()), 'site');
// This is the actual drupal provisioning requirements.
_provision_drupal_create_directories($url);
......
......@@ -115,7 +115,7 @@ function provision_drush_command() {
$items['provision-verify'] = array(
'arguments' => array('domain.com' => dt('The domain of the site to verify).')),
'description' => 'Verify that the provisioning framework is correctly installed.',
'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_ROOT,
'bootstrap' => DRUSH_BOOTSTRAP_DRUSH,
);
$items['provision-restore'] = array(
......
......@@ -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".
*/
......
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