Commit 0a8ae41b authored by Adrian Rossouw's avatar Adrian Rossouw Committed by adrian

#407334 - Refactor to use the drush_context API instead of passing a reference to the $args global

parent 1fc87b2b
<?php
function provision_mysql_provision_pre_backup(&$data, $url = NULL) {
function provision_mysql_provision_pre_backup($url = NULL) {
drush_log("Generating mysql dump for $url.", 'backup');
provision_shell_exec("mysqldump -u%s -p%s %s > sites/%s/database.sql", $data['db_user'], $data['db_passwd'], $data['db_name'], $url);
provision_shell_exec("mysqldump -u%s -p%s %s > sites/%s/database.sql", drush_get_option('db_user'), drush_get_option('db_passwd'), drush_get_option('db_name'), $url);
}
function provision_mysql_provision_pre_backup_rollback(&$data, $url = NULL) {
provision_path("unlink", PROVISION_SITES_PATH . "/$url/database.sql", TRUE, dt("Deleted mysql dump from sites directory"),
function provision_mysql_provision_pre_backup_rollback($url = NULL) {
provision_path("unlink", drush_get_option('sites_path') . "/$url/database.sql", TRUE, dt("Deleted mysql dump from sites directory"),
dt("Could not delete mysql dump from sites directory"));
}
function provision_mysql_provision_post_backup(&$data, $url = NULL) {
provision_mysql_provision_pre_backup_rollback($data, $url);
function provision_mysql_provision_post_backup($url = NULL) {
provision_mysql_provision_pre_backup_rollback($url);
}
......@@ -10,7 +10,9 @@ function provision_mysql_provision_delete_validate() {
*
* This will drop the database, revoke the privileges and flush the privileges.
*/
function provision_mysql_provision_delete(&$data, $url = NULL) {
return _provision_mysql_destroy_site_db($data['db_name'], $data['db_user'], $data['db_passwd'], $data['db_host']);
function provision_mysql_provision_delete($url = NULL) {
return _provision_mysql_destroy_site_db(
drush_get_option('db_name'), drush_get_option('db_user'),
drush_get_option('db_passwd'), drush_get_option('db_host'));
}
......@@ -4,26 +4,32 @@ function provision_mysql_provision_deploy_validate() {
provision_db_connect();
}
function provision_mysql_provision_deploy(&$data, $url) {
# generate a random password for use
$data['db_passwd'] = provision_password();
$data['db_name'] = _provision_mysql_suggest_db_name($data, $url);
$data['db_user'] = $data['db_name'];
function provision_mysql_provision_deploy($url) {
$db_type = drush_set_option('db_type', drush_get_option('db_type'), 'site');
$db_host = drush_set_option('db_host', drush_get_option('db_host'), 'site');
$db_passwd = drush_set_option('db_passwd', provision_password(), 'site');
$db_name = drush_set_option('db_name', _provision_mysql_suggest_db_name($url), 'site');
$db_user = drush_set_option('db_user', $db_name, 'site');
_provision_mysql_new_site_db($data['db_name'], $data['db_user'], $data['db_passwd'], $data['db_host']);
_provision_mysql_new_site_db($db_name, $db_user, $db_passwd, $db_host);
_provision_mysql_import_dump(PROVISION_SITES_PATH .'/'. $url .'/database.sql', $data['db_name'], $data['db_user'], $data['db_passwd'], $data['db_host']);
_provision_mysql_import_dump(
drush_get_option('sites_path') .'/'. $url .'/database.sql',
$db_name, $db_user, $db_passwd, $db_host );
}
function provision_mysql_provision_deploy_rollback(&$data, $url = NULL) {
_provision_mysql_destroy_site_db($data['db_name'], $data['db_user'], $data['db_passwd'], $data['db_host']);
function provision_mysql_provision_deploy_rollback($url = NULL) {
_provision_mysql_destroy_site_db(
drush_get_option('db_name'), drush_get_option('db_user'),
drush_get_option('db_passwd'), drush_get_option('db_host')
);
}
// Rollback doesn't apply here yet. Unless we trigger a deploy of the first dump
// made. Which could go on infinitely if something is really long.
function provision_mysql_provision_post_deploy(&$data, $url = NULL) {
provision_path('unlink', 'sites/'. $url .'/database.sql', TRUE,
function provision_mysql_provision_post_deploy($url = NULL) {
provision_path('unlink', drush_get_option('sites_path') .'/'. $url .'/database.sql', TRUE,
dt("Removed dump file @path after restoring from it"),
dt("Could not remove dump file @path"), DRUSH_PERM_ERROR);
}
......@@ -4,23 +4,19 @@ function provision_mysql_provision_install_validate() {
provision_db_connect();
}
function provision_mysql_provision_pre_install(&$data, $url = NULL) {
$data['db_type'] = ($data['db_type']) ? $data['db_type'] : PROVISION_DB_TYPE;
$data['db_host'] = ($data['db_host']) ? $data['db_host'] : PROVISION_DB_HOST;
function provision_mysql_provision_pre_install($url = NULL) {
$db_type = drush_set_option('db_type', drush_get_option('db_type'), 'site');
$db_host = drush_set_option('db_host', drush_get_option('db_host'), 'site');
$db_passwd = drush_set_option('db_passwd', provision_password(), 'site');
$db_name = drush_set_option('db_name', _provision_mysql_suggest_db_name($url), 'site');
$db_user = drush_set_option('db_user', $db_name, 'site');
# generate a random password for use
$data['db_passwd'] = provision_password();
$data['db_name'] = _provision_mysql_suggest_db_name($data, $url);
$data['db_user'] = $data['db_name'];
_provision_mysql_new_site_db($data['db_name'], $data['db_user'], $data['db_passwd'], $data['db_host']);
_provision_mysql_new_site_db($db_name, $db_user, $db_passwd, $db_host);
}
function provision_mysql_provision_pre_install_rollback(&$data, $url = NULL) {
_provision_mysql_destroy_site_db($data['db_name'], $data['db_user'], $data['db_passwd'], $data['db_host']);
unset($data['db_host']);
unset($data['db_type']);
unset($data['db_passwd']);
unset($data['db_user']);
unset($data['db_name']);
function provision_mysql_provision_pre_install_rollback($url = NULL) {
_provision_mysql_destroy_site_db(
drush_get_option('db_name'), drush_get_option('db_user'),
drush_get_option('db_passwd'), drush_get_option('db_host')
);
}
......@@ -18,7 +18,7 @@ function provision_db_connect() {
if (_provision_db_connection()) {
return TRUE;
}
$connection = @mysql_connect(PROVISION_DB_HOST, PROVISION_DB_USER, PROVISION_DB_PASSWD);
$connection = @mysql_connect(drush_get_option('master_db_host'), drush_get_option('master_db_user'), drush_get_option('master_db_passwd'));
if (!$connection) {
drush_set_error('PROVISION_MASTER_DB_FAILED', dt('Could not connect to the master database.'), 'error');
......
......@@ -62,7 +62,7 @@ function _provision_mysql_new_site_db($db_name, $db_user, $db_passwd, $db_host)
*/
function _provision_mysql_destroy_site_db($db_name, $db_user, $db_passwd, $db_host) {
if ( _provision_mysql_database_exists($data['db_name']) ) {
if ( _provision_mysql_database_exists($db_name) ) {
drush_log(dt("Dropping database @dbname", array('@dbname' => $db_name)));
if (!_provision_mysql_drop_database($db_name)) {
drush_log(dt("Failed to drop database @dbname", array('@dbname' => $db_name)), 'warning');
......@@ -147,9 +147,9 @@ function _provision_mysql_import_dump($dump_file, $db_name, $db_user, $db_passwd
* possible that sites will be running with derivative names on the same server,
* until the upgrade / restore process is completed.
*/
function _provision_mysql_suggest_db_name($data, $url) {
if ($data['site_id']) {
$id_suggest = 'site_'. $data['site_id'];
function _provision_mysql_suggest_db_name($url) {
if ($sid = drush_get_option('site_id')) {
$id_suggest = 'site_'. $sid;
$suggest[] = $id_suggest;
for ($i = 0; $i < 100; $i++) {
$suggest[] = $id_suggest .'_'. $i;
......
......@@ -4,43 +4,59 @@ function provision_mysql_provision_restore_validate() {
provision_db_connect();
}
function provision_mysql_provision_pre_restore(&$data, $url = NULL) {
// store a backup of the credentials of the site.
$data['old_db_name'] = $data['db_name'];
$data['old_db_passwd'] = $data['db_passwd'];
$data['old_db_user'] = $data['db_user'];
$data['old_db_host'] = $data['db_host'];
# generate a random password for use
$data['db_passwd'] = provision_password();
$data['db_name'] = _provision_mysql_suggest_db_name($data, $url);
$data['db_user'] = $data['db_name'];
_provision_mysql_new_site_db($data['db_name'], $data['db_user'], $data['db_passwd'], $data['db_host']);
function provision_mysql_provision_pre_restore($url = NULL) {
$db_type = drush_set_option('db_type', drush_get_option('db_type'));
$db_host = drush_set_option('db_host', drush_get_option('db_host'));
$db_passwd = drush_set_option('db_passwd', provision_password());
$db_name = drush_set_option('db_name', _provision_mysql_suggest_db_name($url));
$db_user = drush_set_option('db_user', $db_name);
_provision_mysql_new_site_db($db_name, $db_user, $db_passwd, $db_host);
}
function provision_mysql_provision_restore(&$data, $url) {
_provision_mysql_import_dump(PROVISION_SITES_PATH .'/'. $url .'/database.sql', $data['db_name'], $data['db_user'], $data['db_passwd'], $data['db_host']);
function provision_mysql_provision_restore($url) {
_provision_mysql_import_dump(
drush_get_option('sites_path') .'/'. $url .'/database.sql',
drush_get_option('db_name'), drush_get_option('db_user'),
drush_get_option('db_passwd'), drush_get_option('db_host')
);
}
function provision_mysql_provision_pre_restore_rollback(&$data, $url = NULL) {
_provision_mysql_destroy_site_db($data['db_name'], $data['db_user'], $data['db_passwd'], $data['db_host']);
function provision_mysql_provision_pre_restore_rollback($url = NULL) {
_provision_mysql_destroy_site_db(
drush_get_option('db_name'), drush_get_option('db_user'),
drush_get_option('db_passwd'), drush_get_option('db_host'));
$keys = array('db_name', 'db_passwd', 'db_user', 'db_host');
//Restore the original database credentials of the site.
// They were never truly lost, but the options in the 'process' context
// were overriding them. By unsetting the temporary options, the originals
// are automatically restored.
foreach ($keys as $key) {
$data[$key] = $data['old_'. $key];
drush_unset_option($key, 'process');
}
}
// Rollback doesn't apply here yet. Unless we trigger a restore of the first dump
// made. Which could go on infinitely if something is really long.
function provision_mysql_provision_post_restore(&$data, $url = NULL) {
print_r($data);
provision_path('unlink', 'sites/'. $url .'/database.sql', TRUE,
function provision_mysql_provision_post_restore($url = NULL) {
provision_path('unlink', drush_get_option('sites_path') . '/' . $url .'/database.sql', TRUE,
dt("Removed dump file @path after restoring from it"),
dt("Could not remove dump file @path"), DRUSH_PERM_ERROR);
#_provision_mysql_destroy_site_db($data['old_db_name'], $data['old_db_user'], $data['old_db_passwd'], $data['old_db_host']);
// We have now completed successfully, remove the old database.
_provision_mysql_destroy_site_db(
drush_get_option('db_name', null, 'site'), drush_get_option('db_user', null, 'site'),
drush_get_option('db_passwd', null, 'site'), drush_get_option('db_host', null, 'site')
);
// The new database credentials will be saved against the site now.
drush_set_option('db_name', drush_get_option('db_name'), 'site');
drush_set_option('db_type', drush_get_option('db_type'), 'site');
drush_set_option('db_user', drush_get_option('db_user'), 'site');
drush_set_option('db_host', drush_get_option('db_host'), 'site');
drush_set_option('db_passwd', drush_get_option('db_passwd'), 'site');
}
......@@ -20,3 +20,9 @@ function provision_mysql_provision_verify() {
}
}
function provision_mysql_provision_post_verify() {
if (PROVISION_CONTEXT_PLATFORM) {
drush_set_option('master_db', drush_get_option('master_db'), 'platform');
}
}
......@@ -14,7 +14,7 @@
* need to lookup the zid for the base zone of this site, and then call provision_dns_rr with the zid and site 'name'
* (ie: pull off the tld and second-level domain for the 'base' zone, and treat the rest as the 'name')
*/
function provision_dns_provision_delete(&$data, $url = NULL) {
function provision_dns_provision_delete($url = NULL) {
if ($url) {
# provision_dns_delete($url);
}
......
......@@ -10,7 +10,7 @@
/**
* Implementation of hook_provision_pre_install
**/
function provision_dns_provision_pre_install(&$data, $url = NULL) {
function provision_dns_provision_pre_install($url = NULL) {
# data should now contain zone info directly, rather than having to pull them from
if ($url) {
# $url_parts = _provision_dns_split_url($url);
......@@ -20,16 +20,16 @@ function provision_dns_provision_pre_install(&$data, $url = NULL) {
# }
# the zone object should be passed in..
# $zone = provision_dns_create_zone($url_parts['zone'], $data); # initialize zone for this domain (if it doesn't exist)
# provision_dns_create_record($url_parts['host'], $zone, $data); # creates the RR for the (sub)domain
# provision_dns_commit($data['dns_id']); # makes the changes live (ie: restart bind)
# $zone = provision_dns_create_zone($url_parts['zone']); # initialize zone for this domain (if it doesn't exist)
# provision_dns_create_record($url_parts['host'], $zone); # creates the RR for the (sub)domain
# provision_dns_commit(drush_get_option('dns_id')); # makes the changes live (ie: restart bind)
}
}
/**
* Implementation of hook_provision_pre_install_rollback
**/
function provision_dns_provision_pre_install_rollback(&$data, $url = NULL) {
function provision_dns_provision_pre_install_rollback($url = NULL) {
if ($url) {
# provision_dns_delete($url);
}
......@@ -38,6 +38,6 @@ function provision_dns_provision_pre_install_rollback(&$data, $url = NULL) {
/**
* Implementation of hook_provision_post_install
**/
function provision_dns_provision_post_install(&$data, $url = NULL) {
function provision_dns_provision_post_install($url = NULL) {
# commit and restart bind
}
......@@ -17,26 +17,25 @@ include_once('provision_dns.bind.inc');
*
* @param $domain
* The domain name/origin for the zone to be created.
* @param $data
* An array of data to populate the new zone. Most importantly, the 'dns_id'
* field must contain the nid of the DNS server which on which to privision this zone.
*
* @return
* The zone object, whether newly created, or already existing.
**/
function provision_dns_create_zone($domain, $data) {
function provision_dns_create_zone($domain) {
/*
$writable = provision_path("writable", PROVISION_NAMED_PATH, TRUE, NULL,
t("DNS configuration path @path is not writable"),
PROVISION_PERM_ERROR | PROVISION_FRAMEWORK_ERROR);
*/
# if ($zone = provision_dns_status('zone', array('domain' => $domain))) {
# drush_log("Notice", t("Loading zone file for url @url", array('@url' => $domain)));
# return $zone;
# } else {
drush_log("Notice", dt("Generating zone file for url @url on dns server @id", array('@url' => $domain, '@id' => $data['dns_id'])));
/**
drush_log("Notice", dt("Generating zone file for url @url on dns server @id", array('@url' => $domain, '@id' => drush_get_option('dns_id'))));
# Setup args array from defaults
$dns = node_load($data['dns_id']);
$zone_fields['dns_id'] = $data['dns_id'];
$dns = node_load(drush_get_option('dns_id'));
$zone_fields['dns_id'] = drush_get_option('dns_id');
$zone_fields['origin'] = $domain;
$zone_fields['serial'] = date('Ymd') . '01';
$ns_recs = explode("\n", $dns->ns);
......@@ -46,6 +45,7 @@ drush_log("notice", "provision_dns_create_zone ns_recs: ".$ns_recs[0].", ".$ns_r
$zone_fields['ns2'] = $ns_recs[1];
$zone_fields['mbox'] = $dns->mbox;
provision_dns_zone('add', $zone_fields);
*/
# $zone = provision_dns_status('zone', array('domain' => $domain));
# foreach ($ns_recs as $ns) {
# provision_dns_create_record('@', $zone, array('type' => 'NS', 'dns_ip' => trim($ns)));
......@@ -61,18 +61,15 @@ drush_log("notice", "provision_dns_create_zone ns_recs: ".$ns_recs[0].", ".$ns_r
* The name part of the record to be created.
* @param $zone
* The zone object in which to create the record.
* @param $data
* An array of data used to populate the record. Most importantly, the 'dns_ip' field should
* contain the IP address which the host record should point to.
*
* @return
* The record object, or FALSE if the record could not be created.
**/
function provision_dns_create_record($host, $zone, $data) {
drush_log(dt("Creating %type record for url @url", array('%type' => $data['type'], '@url' => $host)));
function provision_dns_create_record($host, $zone) {
drush_log(dt("Creating %type record for url @url", array('%type' => drush_get_option('type'), '@url' => $host)));
$rec['name'] = $host;
$rec['type'] = $data['type']?$data['type']:'A';
$rec['data'] = $data['dns_ip'];
$rec['type'] = drush_get_option('type');
$rec['data'] = drush_get_option('dns_ip');
return provision_dns_rr('add', $zone->zid, $rec);
}
......
......@@ -11,7 +11,7 @@
* Implementation of hook_provision_pre_restore
* This is a duplicate of the _pre_install hook
**/
function provision_dns_provision_pre_restore(&$data, $url = NULL) {
function provision_dns_provision_pre_restore($url = NULL) {
# re-install the zonefiles and/or resource records for the site?
# _provision_dns_provision_pre_restore($url, $data);
}
......@@ -20,17 +20,17 @@ function provision_dns_provision_pre_restore(&$data, $url = NULL) {
* Implementation of hook_provision_pre_restore_rollback
* This duplicates the _pre_install_rollback hook
**/
function provision_dns_provision_pre_restore_rollback(&$data, $url = NULL) {
function provision_dns_provision_pre_restore_rollback($url = NULL) {
# remove them again?
if ($url) {
# _provision_dns_delete($url);
}
}
function provision_dns_provision_post_restore(&$data, $url = NULL) {
function provision_dns_provision_post_restore($url = NULL) {
# restart bind?
}
function provision_dns_provision_post_restore_rollback(&$data, $url = NULL) {
function provision_dns_provision_post_restore_rollback($url = NULL) {
# restart bind
}
......@@ -12,7 +12,8 @@
*
* Can't be rolled back.
*/
function provision_dns_provision_verify(&$data, $url = NULL) {
/*
function provision_dns_provision_verify($url = NULL) {
if (!$url) {
// we are verifying a platform
# Where does this constant come from now?
......@@ -29,9 +30,9 @@ function provision_dns_provision_verify(&$data, $url = NULL) {
return;
}
# $zone = provision_dns_create_zone($url_parts['zone'], $data); # initializes the zone for the domain (if it doesn't exist)
# provision_dns_create_record($url_parts['host'], $zone, $data); # creates the RR for the (sub)domain
# provision_dns_commit($data['dns_id']); # makes the changes live (ie: restart bind)
# $zone = provision_dns_create_zone($url_parts['zone']); # initializes the zone for the domain (if it doesn't exist)
# provision_dns_create_record($url_parts['host'], $zone); # creates the RR for the (sub)domain
# provision_dns_commit(drush_get_option('dns_id')); # makes the changes live (ie: restart bind)
}
}
*/
......@@ -10,6 +10,6 @@
/**
* implementation of hook_provision_vhost_extra
*/
function provision_itk_provision_vhost_config($url, $data) {
return "# Configur ITK permissions\nAssignUserID ". $data['web_user'] . ' #' . $data['web_group'] . "\n";
function provision_itk_provision_vhost_config($url) {
return "# Configur ITK permissions\nAssignUserID ". drush_get_option('web_user') . ' #' . drush_get_option('web_group') . "\n";
}
......@@ -9,12 +9,12 @@
/**
* Make sure the site is installed and enabled, and that we have a valid target to back up to.
*/
function provision_drupal_provision_backup_validate(&$data, $url = NULL, $backup_file = NULL) {
function provision_drupal_provision_backup_validate($url = NULL, $backup_file = NULL) {
_provision_drupal_url_required();
_provision_drupal_valid_installed_site();
// This is the actual drupal provisioning requirements.
if (!is_dir(PROVISION_BACKUP_PATH)) {
if (!is_dir(drush_get_option('backup_path'))) {
drush_set_error(PROVISION_BACKUP_PATH_NOT_FOUND);
}
......@@ -23,29 +23,31 @@ function provision_drupal_provision_backup_validate(&$data, $url = NULL, $backup
dt("Backing site up to @path."),
dt("Back up file @path already exists."),
PROVISION_BACKUP_ALREADY_EXISTS)) {
$data['backup_file'] = $backup_file;
drush_get_option('backup_file', $backup_file);
}
}
if (!$backup_file) {
$suggested = PROVISION_BACKUP_PATH ."/$url-". date("Y-m-d", mktime()) .".tar";
$suggested = drush_get_option('backup_path') ."/$url-". date("Y-m-d", mktime()) .".tar";
// Use format of mysite.com-2008-01-02, if already existing, add number.
while (is_file($suggested .'.gz')) {
$count++;
$suggested = PROVISION_BACKUP_PATH ."/$url-". date("Y-m-d", mktime()) ."_$count.tar";
$suggested = drush_get_option('backup_path') ."/$url-". date("Y-m-d", mktime()) ."_$count.tar";
}
$data['backup_file'] = (!empty($file)) ? ereg_replace('.gz$', '', $file) : $suggested;
drush_set_option('backup_file', str_replace(".gz" , '', $suggested));
}
}
/**
* Implentation of hook_provision_backup()
*/
function provision_drupal_provision_backup(&$data, $url, $backup_file) {
function provision_drupal_provision_backup($url) {
$backup_file = drush_get_option('backup_file');
// Adds the site directory into the backup file
drush_log("Adding sites directory to $data[backup_file].gz", 'backup');
$result = provision_shell_exec("cd %s; tar -rf %s * ", "sites/$url", $data['backup_file']);
drush_log(dt("Adding sites directory to !backup_file", array('!backup_file' => $backup_file)), 'backup');
$result = provision_shell_exec("cd %s; tar -rf %s * ", drush_get_option('sites_path') . "/$url", $backup_file);
if (!$result) {
drush_set_error(PROVISION_BACKUP_FAILED, dt("Could not back up sites directory for drupal"));
......@@ -56,7 +58,9 @@ function provision_drupal_provision_backup(&$data, $url, $backup_file) {
/**
* Generate a backup tarbal for a site.
*/
function provision_drupal_provision_post_backup(&$data, $url, $backup_file = NULL) {
provision_shell_exec("gzip %s", $data['backup_file']);
$data['backup_file'] = $data['backup_file'] .'.gz';
function provision_drupal_provision_post_backup($url, $backup_file = NULL) {
$backup_file = drush_get_option('backup_file');
provision_shell_exec("gzip %s", $backup_file);
drush_set_option('backup_file', $backup_file . '.gz');
}
......@@ -12,7 +12,7 @@ function provision_drupal_provision_cron_verify() {
/**
* Drush command to run cron
*/
function _provision_cron(&$data, $url) {
function _provision_cron($url) {
_provision_drupal_rebuild_caches($url);
}
<?php
function provision_drupal_provision_delete_validate(&$data, $url = NULL, $backup_file = NULL) {
function provision_drupal_provision_delete_validate($url = NULL, $backup_file = NULL) {
_provision_drupal_valid_site();
}
......@@ -9,24 +9,24 @@ function provision_drupal_provision_delete_validate(&$data, $url = NULL, $backup
/**
* Before starting to delete the site, make a backup
*/
function provision_drupal_provision_pre_delete(&$data, $url, $backup_file) {
function provision_drupal_provision_pre_delete($url, $backup_file) {
// @TODO : fix the inline calling of provision_invoke
provision_invoke('backup', $data, $url, $backup_file);
provision_invoke('backup', $url, $backup_file);
}
/**
* Remove any directories for the site in sites
* This can't be rolled back. so won't even try.
*/
function provision_drupal_provision_delete(&$data, $url) {
if ($old_data = provision_load_site_data($url)) {
if (sizeof($old_aliases = $old_data['aliases'])) {
function provision_drupal_provision_delete($url) {
$old_aliases = drush_get_option('aliases', array(), 'site');
if (sizeof($old_aliases) == sizeof(drush_get_option('aliases'))) {
_provision_drupal_delete_aliases($old_aliases);
}
}
_provision_recursive_delete("sites/$url");
$data['installed'] = FALSE;
_provision_recursive_delete(drush_get_option('sites_path') . "/$url");
drush_set_option('installed', FALSE, 'site');
}
......@@ -23,7 +23,7 @@
/**
* Make sure we have a valid site being deployd, and that the file being deployd from exists
*/
function provision_drupal_provision_deploy_validate(&$data, $url = null, $backup_file = null) {
function provision_drupal_provision_deploy_validate($url = null, $backup_file = null) {
_provision_drupal_url_required();
_provision_drupal_valid_not_installed_site();
......@@ -32,46 +32,46 @@ function provision_drupal_provision_deploy_validate(&$data, $url = null, $backup
dt("Could not find backup file @path"),
PROVISION_BACKUP_NOT_FOUND);
if ($exists) {
$data['backup_file'] = $backup_file;
drush_set_option('backup_file', $backup_file);
}
}
/**
* Make a backup before making any changes, and add extract the file we are restoring from
*/
function provision_drupal_provision_pre_deploy(&$data, $url, $backup_file) {
$extracted = provision_path("extract", $data['backup_file'], PROVISION_SITES_PATH ."/$url",
function provision_drupal_provision_pre_deploy($url, $backup_file) {
$extracted = provision_path("extract", drush_get_option('backup_file'), drush_get_option('sites_path') ."/$url",
dt('Successfully extracted the contents of @path'),
dt('Failed to extract the contents of @path'),
PROVISION_BACKUP_EXTRACTION_FAILED);
if ($extracted) {
$old_data = provision_get_site_data($url);
$data['old_site_url'] = $old_data['site_url'];
$data = array_merge($old_data, $data);
// @TODO Clear up this properly.
// $old_data = provision_get_site_data($url);
// $data = array_merge($old_data, $data);
}
}
/**
* Remove the extracted site directory
*/
function provision_provision_pre_deploy_rollback(&$data, $url) {
_provision_recursive_delete(PROVISION_SITES_PATH ."/$url");
function provision_provision_pre_deploy_rollback($url) {
_provision_recursive_delete(drush_get_option('sites_path') ."/$url");
}
/**
* Switch the deploy directories around now that we have the new db installed
*/
function provision_drupal_provision_deploy(&$data, $url) {
function provision_drupal_provision_deploy($url) {
// make sure it has the latest site data available
_provision_drupal_create_settings_file($data, $url);
_provision_drupal_create_settings_file($url);
}
// Luckily this is reversable =)
function provision_drupal_provision_deploy_rollback(&$data, $url) {
provision_drupal_provision_deploy(&$data, $url);
function provision_drupal_provision_deploy_rollback($url) {
provision_drupal_provision_deploy($url);
}
function provision_drupal_provision_post_deploy(&$data, $url) {
provision_invoke('update', $data, $url);
provision_platform_include($data, dirname(__FILE__), 'deploy');
function provision_drupal_provision_post_deploy($url) {
provision_invoke('update', $url);
provision_platform_include(dirname(__FILE__), 'deploy');
}
......@@ -19,14 +19,14 @@ function provision_drupal_provision_disable_validate() {
/**
* Make a backup of the site before we mess with it
*/
function provision_drupal_provision_pre_disable(&$data, $url, $backup_file = null) {
provision_invoke("backup", $data, $url, $backup_file);
function provision_drupal_provision_pre_disable($url, $backup_file = null) {
provision_invoke("backup", $url, $backup_file);
}
/**
* Set the enabled property of the site to false
*/
function provision_drupal_provision_post_disable(&$data) {
$data['enabled'] = FALSE;
function provision_drupal_provision_post_disable() {
drush_set_option('enabled', FALSE, 'site');
}
......@@ -5,16 +5,16 @@ if (is_array($GLOBALS['db_url'])) {
}
if ($parts = @parse_url($db_url)) {
$data['db_type'] = $parts['scheme'];
$data['db_user'] = $parts['user'];
$data['db_host'] = $parts['host'];
$data['db_passwd'] = $parts['pass'];
$data['db_name'] = substr($parts['path'], 1);
drush_set_option('db_type', $parts['scheme'], 'site');
drush_set_option('db_user', $parts['user'], 'site');
drush_set_option('db_host', $parts['host'], 'site');
drush_set_option('db_passwd', $parts['pass'], 'site');
drush_set_option('db_name', substr($parts['path'], 1), 'site');
$data['profile'] = variable_get('install_profile', 'default');
drush_set_option('profile', variable_get('install_profile', 'default'), 'site');
$has_locale = db_result(db_query("SELECT status FROM {system} WHERE type='module' AND name='locale'"));
if ($has_locale) {
$locale = db_result(db_query("SELECT locale FROM {locales_meta} WHERE isdefault=1 AND enabled=1"));
}
$data['language'] = ($locale) ? ($locale) : 'en';
drush_set_option('language', $locale, 'site');
}
......@@ -4,10 +4,10 @@
* Rebuild all the caches
*/
$GLOBALS['url'] = $data['site_url'];
$GLOBALS['profile'] = $data['profile'];
$GLOBALS['install_locale'] = $data['language'];
$GLOBALS['client_email'] = $data['client_email'];
$GLOBALS['url'] = drush_get_option('site_url');
$GLOBALS['profile'] = drush_get_option('profile');
$GLOBALS['install_locale'] = drush_get_option('language');
$GLOBALS['client_email'] = drush_get_option('client_email');
require_once 'includes/install.inc';
......
<?php
if ($parts = @parse_url($GLOBALS['db_url'])) {
$data['db_type'] = $parts['scheme'];
$data['db_user'] = $parts['user'];
$data['db_host'] = $parts['host'];
$data['db_passwd'] = $parts['pass'];
$data['db_name'] = substr($parts['path'], 1);
drush_set_option('db_type', $parts['scheme'], 'site');
drush_set_option('db_user', $parts['user'], 'site');
drush_set_option('db_host', $parts['host'], 'site');
drush_set_option('db_passwd', $parts['pass'], 'site');
drush_set_option('db_name', substr($parts['path'], 1), 'site');
$data['profile'] = variable_get('install_profile', 'default');
drush_set_option('profile', variable_get('install_profile', 'default'), 'site');
$language = language_default();
$data['language'] = $language->language;
drush_set_option('language', $language->language, 'site');