verify.provision.inc 3.59 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_provision_verify() {
drumm's avatar
drumm committed
25
  if (d()->type === 'server') {
26
    provision_file()->create_dir(d()->config_path, dt('Provision configuration'), 0711);
27 28
    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()) {
29 30
      // Create an empty global.inc so the include doesn't fail with
      // open_basedir restrictions
31
      $config = new provisionConfig_global_settings(d()->name);
32
      $config->write();
33
    }
34
    d()->service('http')->sync(d()->include_path);
drumm's avatar
drumm committed
35

36
    if (d()->name == '@server_localhost') {
37
      provision_file()->create_dir(d()->backup_path, dt('Backup'), 0700);
38
    }
39
  }
drumm's avatar
drumm committed
40
  elseif (d()->type === 'platform') {
41
    provision_file()->writable(d()->root . '/sites')
42 43
      ->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');
44

45
    drush_set_option('sites', array_keys((array) provision_drupal_find_sites()), 'drupal'); 
46
    drush_log(dt("This platform is running @short_name @version", array('@short_name' => 'drupal', '@version' => VERSION)));
47
    drush_set_option('packages', _scrub_object(provision_find_packages()), 'drupal');
48
  }
drumm's avatar
drumm committed
49
  elseif (d()->type === 'site') {
50
    drush_set_option('packages', _scrub_object(provision_drupal_system_map()), 'site');
51 52 53
    // This is the actual drupal provisioning requirements. 
    _provision_drupal_create_directories();
    _provision_drupal_maintain_aliases();
54
    // Requires at least the database settings to complete.
55
   _provision_drupal_create_settings_file();
56 57 58
  }
}

59 60 61 62 63
class provisionConfig_global_settings extends provisionConfig {
  public $template = 'global_settings.tpl.php';
  public $description = 'Global settings.php file';

  function filename() {
64
    return $this->include_path . '/global.inc';
65 66 67 68 69
  }

  function process() {
  }
}
70 71 72 73

/**
 * Implementation of hook_provision_post_verify
 */
74
function drush_provision_drupal_post_provision_verify() {
drumm's avatar
drumm committed
75
  if (d()->type === 'site') {
76
    _provision_drupal_rebuild_caches();
77
    drush_set_option('aliases', drush_get_option('aliases'), 'site');
78
    drush_set_option('redirection', drush_get_option('redirection'), 'site');
79
    drush_set_option('installed', TRUE, 'site');
80 81 82
  }
}

83
/**
anarcat's avatar
anarcat committed
84 85 86 87 88 89 90 91
 * Inject the relevant .htacces configuration into the global apache
 * configuration
 *
 * This basically loads the regular .htacess but adds an AllowOverride
 * none so the .htaccess are ignored, as a performance improvement.
 *
 * @see platform/provision_drupal_htaccess.tpl.php
 * @see hook_provision_apache_dir_config()
92 93
 */
function provision_drupal_provision_apache_dir_config($data = null) {
94
  $htaccess = <<<EOF
95
<IfModule mod_rewrite.c>
96
  RewriteEngine on
97 98 99 100
  # allow files to be accessed without /sites/fqdn/
  RewriteRule ^files/(.*)$ /sites/%{HTTP_HOST}/files/$1 [L]
</IfModule>

101 102
EOF;

103
  $htaccess .= file_get_contents(d()->root . '/.htaccess');
104 105
  $htaccess .= <<<EOF

106 107
# Do not read the platform's .htaccess
AllowOverride none
anarcat's avatar
anarcat committed
108

109
EOF;
anarcat's avatar
anarcat committed
110
  # the trailing newline above is necessary
111
  return $htaccess;
112
}