resume.hosting.inc

Drush include for the Hosting module's hosting resume command.

Functions

Namesort descending Description
drush_hosting_resume Drush command to resume the Aegir frontend site.

File

resume.hosting.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Drush include for the Hosting module's hosting resume command.
  5. */
  6. include_once 'hosting.inc';
  7. /**
  8. * Drush command to resume the Aegir frontend site.
  9. */
  10. function drush_hosting_resume() {
  11. drush_log('bootstrapping drupal');
  12. drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_FULL);
  13. $server_name = drush_get_option('server_name');
  14. $old_platform = drush_get_option('old_platform_name');
  15. $new_platform = drush_get_option('new_platform_name');
  16. $node = hosting_context_load(d()->name);
  17. // fix the old platform first
  18. $platform_id = db_query('SELECT nid FROM {hosting_platform} WHERE publish_path = :publish_path', array(':publish_path' => d($old_platform)->root))->fetchField();
  19. if ($platform_id) {
  20. hosting_context_register($platform_id, ltrim($old_platform, '@'));
  21. }
  22. else {
  23. 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');
  24. }
  25. // if the new platform doesn't exist, create it.
  26. $platform_root = d()->root;
  27. if (!($platform_id = db_query('SELECT nid FROM {hosting_platform} WHERE publish_path = :publish_path', array(':publish_path' => $platform_root))->fetchField())) {
  28. drush_log(dt('Platform not found for path %path, adding platform node', array('%path' => $platform_root)));
  29. // inherit settings from current platform node
  30. $platform = node_load($node->platform);
  31. $platform->type = 'platform';
  32. unset($platform->nid);
  33. unset($platform->vid);
  34. $platform->publish_path = $platform_root;
  35. $platform->verified = 0;
  36. $platform->title = basename(rtrim($platform_root, '/'));
  37. node_save($platform);
  38. $platform_id = $platform->nid;
  39. }
  40. else {
  41. drush_log(dt('Platform found for path %path: #%id', array('%path' => $platform_root, '%id' => $platform_id)));
  42. $platform = node_load($platform_id);
  43. }
  44. hosting_context_register($platform_id, ltrim($new_platform, '@'));
  45. drush_log('fixing platform for site node');
  46. $node->verified = 0;
  47. $node->platform = $platform_id;
  48. node_save($node);
  49. provision_backend_invoke(d()->name, 'hosting-setup');
  50. }