Commit 1b2b5f51 authored by Adrian Rossouw's avatar Adrian Rossouw Committed by adrian

add dependency on cvs_deploy module to properly retreive the version for all packages

parent 65aaab5b
......@@ -195,3 +195,7 @@ function provision_mysql_provision_verify() {
}
provision_set_active_db();
}
function provision_mysql_restore($url, $backup_file, &$data) {
}
......@@ -232,7 +232,6 @@ function _provision_drupal_switch_active_site($url = null) {
# This is just for backup, to be able to restore to the old DRUSH system.
extract($backups, EXTR_OVERWRITE);
provision_set_active_db();
}
}
......@@ -327,7 +326,21 @@ function provision_drupal_provision_verify($url, &$data) {
}
$profiles = file_scan_directory('./profiles', '\.profile$', array('.', '..', 'CVS', '.svn'), 0, TRUE, 'name', 0);
$data['profiles'] = $profiles;
$data['modules'] = module_rebuild_cache();
$modules = module_rebuild_cache();
foreach ($modules as $modulename => $file) {
$project = array();
$project['filename'] = $file->filename;
$project['name'] = $file->name;
if (empty($project['project'])) {
$project['project'] = cvs_deploy_get_project_name($project);
}
_cvs_deploy_version_alter($file->info['version'], $project);
$name = ($project['project']) ? $project['project'] : $modulename;
$modules[$name] = $file;
}
$data['modules'] = $modules;
}
function provision_drupal_restore($url, $backup_file, &$data) {
provision_shell_exec("tar -zxf %s -C sites/%s", $backup_file, $url); # checkout over old sites dir.
}
name = Provision
description = Allows for the automated provisioning of hosted Drupal sites, via the command line
package = Provision
dependencies = drush provision_drupal provision_mysql provision_apache
\ No newline at end of file
dependencies = drush provision_drupal provision_mysql provision_apache cvs_deploy
......@@ -28,7 +28,7 @@
* Uses hook_provision_pre_upgrade(), hook_provision_upgrade() and hook_provision_post_upgrade() hooks,
* and allows clean roll back if any errors occur. Will include stringent checking of module versions,
* and allow unit tests to be run.
* rollback - Revert to a previous backup of the site.
* restore - Revert to a previous backup of the site.
* rename - Change the url of a site. This requires moving of files, and numerous other issues.
* delete - Generates a back up of the site, and then removes all references to it.
*/
......@@ -272,12 +272,20 @@ function provision_drush_command() {
'arguments' => array('domain.com' => t('The domain of the site to disable (only if disabled).')),
'description' => 'Disable a site.'
);
$items['provision verify'] = array(
'callback' => '_provision_verify',
# 'arguments' => array('domain.com' => t('The domain of the site to disable (only if disabled).')),
'description' => 'Verify that the provisioning framework is correctly installed.'
);
$items['provision restore'] = array(
'callback' => '_provision_restore',
'description' => 'Restore the site to a previous backup. This will also generate a backup of the site as it was.',
'arguments' => array('domain.com' => t('The domain of the site to be restored'),
'site_backup.tar.gz' => t('The backup to restore the site to.'))
);
/*
// Not implemented yet.
$items['provision delete'] = array(
......@@ -285,11 +293,6 @@ function provision_drush_command() {
'description' => 'Delete a site.'
);
$items['provision rollback'] = array(
'callback' => '_provision_rollback',
'description' => 'Roll back the site to a previous backup.'
);
$items['provision deploy'] = array(
'callback' => '_provision_deploy',
'description' => 'Deploy a backup made on another provisioning platform on this one.'
......@@ -473,6 +476,19 @@ function _provision_backup($url) {
provision_output($url, $data);
}
$data = provision_get_site_data($url);
$args = func_get_args();
array_shift($args);
$file = array_shift($args);
_provision_backup_site($url, $data, $file);
provision_save_site_data($url, $data);
provision_output($url, $data);
}
/**
* Generate a backup tarbal for a site.
*/
function _provision_backup_site($url, &$data, $file = null) {
$backup_path = _provision_backup_path();
// This is the actual drupal provisioning requirements.
if (!is_dir($backup_path)) {
......@@ -480,9 +496,7 @@ function _provision_backup($url) {
provision_set_error(PROVISION_PERM_ERROR);
provision_output($url, $data);
}
$args = func_get_args();
array_shift($args);
$file = array_shift($args);
if (is_file($file)) {
provision_log("File specified already exists.");
provision_set_error(PROVISION_PERM_ERROR);
......@@ -500,9 +514,6 @@ function _provision_backup($url) {
$rolled_back = provision_invoke("backup", $url, $data);
provision_shell_exec("gzip %s", $data['backup_file']);
$data['backup_file'] = $data['backup_file'] . '.gz';
provision_save_site_data($url, $data);
provision_output($url, $data);
}
/**
......@@ -609,3 +620,14 @@ function _provision_verify($url = '') {
}
provision_output($url, $data);
}
function _provision_restore($site, $backup_file) {
if (!_provision_drupal_site_exists($url)) {
provision_log("Error", "Site has not been installed yet.");
provision_set_error(PROVISION_SITE_NOT_FOUND);
provision_output($url, $data);
}
$data = provision_get_site_data($url);
_provision_backup_site($url, $data); # Backup site for posterity, before rolling back.
provision_save_site_data($url, $data);
}
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