migrate.hostmaster.inc 2.99 KB
Newer Older
1 2 3 4 5 6
<?php

/**
 * @file manual site migrate system
 */
function drush_provision_hostmaster_migrate_validate($site, $platform) {
7 8
  $data = drush_get_merged_options();
  // add a server record :
9
  $server = '@server_master';
10 11 12
  drush_backend_invoke_args("provision-save", array($server), array(
    'context_type' => 'server',
    'aegir_root' => dirname(rtrim($data['config_path'], '/')),
13
    'script_user' => $data['script_user'],
14 15 16 17 18 19 20 21 22
   // apache 
    'http_service_type' => 'apache',
    'web_group' => $data['web_group'],
    'master_url' => $data['master_url'],
    'restart_cmd' => $data['restart_cmd'],
   // mysql
    'db_service_type' => 'mysql',
    'master_db' => $data['master_db'],
  ));
23

24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
  provision_backend_invoke($server, 'provision-verify');
  drush_set_option('server_name', $server);

  $old_platform = '@platform_' . preg_replace("/[!\W]/", "", basename(rtrim($data['publish_path'], '/')));
  drush_backend_invoke_args("provision-save", array($old_platform), array(
    'context_type' => 'platform',
    'server' => $server,
    'web_server' => $server,
    'root' => $data['publish_path'],
  ));
  provision_backend_invoke($old_platform, 'provision-verify');
  drush_set_option('old_platform', $old_platform);

  $new_platform = '@platform_' . preg_replace("/[!\W]/", "", basename(rtrim($platform, '/')));
  drush_backend_invoke_args("provision-save", array($new_platform), array(
    'context_type' => 'platform',
    'server' => $server,
    'web_server' => $server,
    'root' => $platform,
43
    'makefile' => dirname(__FILE__) . '/aegir.make',
44 45 46 47
  ));
  provision_backend_invoke($new_platform, 'provision-verify');
  drush_set_option('new_platform', $new_platform);

48
  $site_name = '@hostmaster';
49 50 51 52 53 54 55 56 57
  drush_backend_invoke_args("provision-save", array($site_name), array(
    'context_type' => 'site',
    'platform' => $old_platform,
    'db_server' => $server,
    'uri' => $site,
    'profile' => 'hostmaster',
  ));
  provision_backend_invoke($site_name, 'provision-verify');
  drush_set_option('site_name', $site_name);
58 59
}

60

61
function drush_provision_pre_hostmaster_migrate($site, $platform) {
62
  if (!drush_confirm("This command will replace your crontab entry. continue?")) {
63
    return drush_set_error('PROVISION_CANCEL_MIGRATE', 'Cancelling');
64 65 66 67 68
  }
  // wipe out cron entry
  exec('crontab -r');

  // we can't rely on the park command to exist in pre-0.4 alpha 2 releases
69
  provision_backend_invoke(drush_get_option('site_name'), 'hostmaster-pause');
70 71
}

72
function drush_provision_hostmaster_migrate($site, $platform) {
Adrian Rossouw's avatar
Adrian Rossouw committed
73
  provision_backend_invoke(drush_get_option('site_name'), 'provision-migrate', array(drush_get_option('new_platform')));
74 75 76
}

function drush_provision_post_hostmaster_migrate($site, $platform) {
77 78
  // we pass the context names we generated to the task so we can enforce that the names
  // stay the same.
Adrian Rossouw's avatar
Adrian Rossouw committed
79
  provision_backend_invoke(drush_get_option('site_name'), 'hostmaster-resume', array(), array( 
80 81
    'old_platform_name' => drush_get_option('old_platform'),
    'new_platform_name' => drush_get_option('new_platform'),
Adrian Rossouw's avatar
Adrian Rossouw committed
82
  ));
83 84
}