Commit 9f516b40 authored by Adrian Rossouw's avatar Adrian Rossouw Committed by adrian

Added script to change file paths in sites table. We can now handle site migrations

parent 6ed3de96
......@@ -45,7 +45,9 @@ function provision_drupal_provision_pre_deploy(&$data, $url, $backup_file) {
dt('Failed to extract the contents of @path'),
PROVISION_PERM_ERROR, PROVISION_FRAMEWORK_ERROR);
if ($extracted) {
$data = array_merge(provision_get_site_data($url), $data);
$old_data = provision_get_site_data($url);
$data['old_site_url'] = $old_data['site_url'];
$data = array_merge($old_data, $data);
}
}
......@@ -71,4 +73,6 @@ function provision_drupal_provision_deploy_rollback(&$data, $url) {
function provision_drupal_provision_post_deploy(&$data, $url) {
provision_invoke('update', $data, $url);
$cmd = sprintf("php %s/drupal_deploy.php %s %s", dirname(__FILE__), $url, $data['old_site_url']);
provision_exec($cmd, $data);
}
<?php
// $Id$
require_once(dirname(__FILE__) . '/../provision.inc');
if (sizeof($argv) == 3) {
// Fake the necessary HTTP headers that Drupal needs:
$new_url = $argv[1];
$data = provision_external_init($argv[1]);
$old_url = $argv[2];
}
else {
provision_set_error(PROVISION_FRAMEWORK_ERROR);
provision_log("error", "USAGE: drupal_deply.php new_url old_url\n");
provision_output($data);
}
/**
* @file
* Handle site migration tasks for redeployed sites.
* This is primarily to handle the rename of the sites
* directories.
*/
provision_log('notice',
pt('Changed paths from sites/@old_url to sites/@new_url',
array('@old_url' => $old_url, '@new_url' => $new_url)));
db_query("UPDATE {files} SET filepath=replace(filepath, 'sites/%', 'sites/%')", $old_url, $new_url);
db_query("UPDATE {users} SET picture = replace(picture, 'sites/%s', 'sites/%s')", $old_url, $new_url);
variable_set('files_directory_path', "sites/$new_url/files");
variable_set('files_directory_temp', "sites/$new_url/files/tmp");
$data = array();
provision_output($data);
......@@ -8,7 +8,7 @@ if ($argv[1]) {
}
else {
provision_set_error(PROVISION_FRAMEWORK_ERROR);
provision_log("error", "USAGE: update.php url\n");
provision_log("error", "USAGE: drupal_update.php url\n");
provision_output($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