function drush_hosting_resume in Hosting 7.4
Same name and namespace in other branches
- 6.2 resume.hosting.inc \drush_hosting_resume()
- 7.3 resume.hosting.inc \drush_hosting_resume()
Drush command to resume the Aegir frontend site.
File
- ./
resume.hosting.inc, line 13
Code
function drush_hosting_resume() {
drush_log('bootstrapping drupal');
drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_FULL);
$server_name = drush_get_option('server_name');
$old_platform = drush_get_option('old_platform_name');
$new_platform = drush_get_option('new_platform_name');
$node = hosting_context_load(d()->name);
// Fix the old platform first.
$platform_id = db_query('SELECT nid FROM {hosting_platform} WHERE publish_path = :publish_path AND status = :status', array(
':publish_path' => d($old_platform)->root,
':status' => HOSTING_PLATFORM_ENABLED,
))
->fetchField();
if ($platform_id) {
hosting_context_register($platform_id, ltrim($old_platform, '@'));
}
else {
drush_log(dt('Old platform not found in path %path, not setting context %context', array(
'%path' => d($old_platform)->root,
'%context' => ltrim($old_platform, '@'),
)), 'warning');
}
// If the new platform doesn't exist, create it.
$platform_root = d()->root;
if (!($platform_id = db_query('SELECT nid FROM {hosting_platform} WHERE publish_path = :publish_path', array(
':publish_path' => $platform_root,
))
->fetchField())) {
drush_log(dt('Platform not found for path %path, adding platform node', array(
'%path' => $platform_root,
)));
// Inherit settings from current platform node.
$platform = node_load($node->platform);
$platform->type = 'platform';
unset($platform->nid);
unset($platform->vid);
$platform->publish_path = $platform_root;
$platform->verified = 0;
$platform->title = basename(rtrim($platform_root, '/'));
node_save($platform);
$platform_id = $platform->nid;
}
else {
drush_log(dt('Platform found for path %path: #%id', array(
'%path' => $platform_root,
'%id' => $platform_id,
)));
$platform = node_load($platform_id);
}
hosting_context_register($platform_id, ltrim($new_platform, '@'));
drush_log('fixing platform for site node');
$node->verified = 0;
$node->platform = $platform_id;
node_save($node);
provision_backend_invoke(d()->name, 'hosting-setup');
}