-
Notifications
You must be signed in to change notification settings - Fork 6
/
resume.hosting.inc
61 lines (53 loc) · 2.18 KB
/
resume.hosting.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
/**
* @file
* Drush include for the Hosting module's hosting resume command.
*/
include_once 'hosting.inc';
/**
* Drush command to resume the Aegir frontend site.
*/
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');
}