verify.provision.inc 3.8 KB
Newer Older
1 2 3 4 5 6 7
<?php

/**
 * Provision verify command
 *
 * Disable an enabled and installed site
 */
8
function drush_provision_drupal_provision_verify_validate() {
drumm's avatar
drumm committed
9
  if (d()->type === 'site') {
10 11
    drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_SITE);
    provision_prepare_environment();
12

drumm's avatar
drumm committed
13 14 15
    _provision_drupal_create_settings_file();
    drush_errors_on();
    drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_FULL);
16 17
  }

18 19 20 21 22 23
}


/**
 * implementation of provision_verify
 */
24
function drush_provision_drupal_pre_provision_verify() {
drumm's avatar
drumm committed
25
  if (d()->type === 'server') {
drumm's avatar
drumm committed
26

27 28
    $config_root = dirname(d()->config_path);
    provision_file()->create_dir($config_root, dt('Provision configuration root'), 0711);
29
    provision_file()->create_dir(d()->config_path, dt('Provision configuration'), 0711);
30
    provision_file()->create_dir(d()->clients_path, dt('Provision client home'), 0711);
31
    if (d()->name == '@server_master') {
32
      provision_file()->create_dir(d()->backup_path, dt('Backup'), 0700);
33 34 35 36 37 38 39 40 41 42 43 44
      provision_file()->create_dir(d()->include_path, dt('Provision PHP configuration'), 0711);
      if (!provision_file()->exists(d()->include_path . '/global.inc')->succeed('Global configuration file exists')->status()) {
        // Create an empty global.inc so the include doesn't fail with
        // open_basedir restrictions
        $config = new provisionConfig_global_settings(d()->name);
        $config->write();
      }
    }
    else {
      if (provision_file()->exists(d()->include_path)) {
        d()->service('http')->sync(d()->include_path);
      }
45
    }
46
  }
drumm's avatar
drumm committed
47
  elseif (d()->type === 'platform') {
48 49
    // create a platform from a makefile, if it doesnt already exist and the makefile does.
    if (!provision_file()->exists(d()->root)->status() && !empty(d()->makefile)) {
mig5's avatar
mig5 committed
50
      drush_log(dt("Platform path does not exist, fetching from drush makefile"));
51 52 53 54 55
      $options = array('root' => null, 'uri' => null);
      // propagate working-copy args downward
      if (drush_get_option('working-copy')) {
        $options['working-copy'] = 1;
      }
56 57 58
      $options[] = d()->makefile;
      $options[] = d()->root;
      drush_backend_invoke("make", $options);
59 60 61
      if (drush_get_error()) {
        return drush_set_error("DRUSH_MAKE_FAILED", 
          "Could not download platform using drush make. No platform present");
62 63 64
      }
    }

Adrian Rossouw's avatar
Adrian Rossouw committed
65
    drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_ROOT);
66
    provision_file()->writable(d()->root . '/sites')
67 68
      ->succeed('Drupal sites directory @path is writable by the provisioning script')
      ->fail('Drupal sites directory @path is not writable by the provisioning script', 'PROVISION_SITES_DIR_NOT_WRITABLE');
69

70
    drush_set_option('sites', array_keys((array) provision_drupal_find_sites()), 'drupal'); 
71
    drush_log(dt("This platform is running @short_name @version", array('@short_name' => 'drupal', '@version' => VERSION)));
72
    drush_set_option('packages', _scrub_object(provision_find_packages()), 'drupal');
73
  }
drumm's avatar
drumm committed
74
  elseif (d()->type === 'site') {
75
    drush_set_option('packages', _scrub_object(provision_drupal_system_map()), 'site');
76 77 78
    // This is the actual drupal provisioning requirements. 
    _provision_drupal_create_directories();
    _provision_drupal_maintain_aliases();
79
    // Requires at least the database settings to complete.
80
   _provision_drupal_create_settings_file();
81 82 83
  }
}

84
class provisionConfig_global_settings extends Provision_Config {
85 86 87 88
  public $template = 'global_settings.tpl.php';
  public $description = 'Global settings.php file';

  function filename() {
89
    return $this->include_path . '/global.inc';
90 91
  }
}
92 93 94 95

/**
 * Implementation of hook_provision_post_verify
 */
96
function drush_provision_drupal_post_provision_verify() {
drumm's avatar
drumm committed
97
  if (d()->type === 'site') {
98
    _provision_drupal_rebuild_caches();
99
    drush_set_option('installed', TRUE, 'site');
100 101

    _provision_client_create_symlink();
102
    drush_include_engine('drupal', 'cron_key');
103 104 105
  }
}