verify.provision.inc 3.61 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($url = null) {
9
  if ($url) {
10 11
    drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_SITE);
    provision_prepare_environment();
12 13 14 15

      _provision_drupal_create_settings_file($url);
     drush_errors_on();
     drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_FULL);
16 17
  }

18 19 20 21 22 23 24 25
  // This will not have an effect if you are running it on a platform, just tests that if a site is provided it is an existing one
  _provision_drupal_valid_site();
}


/**
 * implementation of provision_verify
 */
26
function drush_provision_drupal_provision_verify($url = null) {
27
  if (PROVISION_CONTEXT_PLATFORM) {
28 29 30
    provision_service('file')->create_dir(drush_get_option('config_path'), dt('Provision configuration'), 0711);
    provision_service('file')->create_dir(drush_get_option('config_path') . '/includes', dt('Provision PHP configuration'), 0711);
    if (!provision_service('file')->path('exists', drush_get_option('config_path') .  '/includes/global.inc', TRUE, dt("Global configuration file exists"))) {
31 32
      # create an empty global.inc so the include doesn't fail with
      # open_basedir restrictions
33
      if (!$file = provision_service('file')->path('fopen', drush_get_option('config_path') .  '/includes/global.inc', 'a')) {
34 35 36 37 38 39
        drush_set_error('PROVISION_FRAMEWORK_ERROR', dt('Cannot create global settings configuration'));
      } else {
        fwrite($file, "<?php # global settings.php");
        fclose($file);
      }
    }
40 41
    provision_service('file')->create_dir(drush_get_option('backup_path'), dt('Backup'), 0700);
    provision_service('file')->path("writable", drush_get_option('sites_path'), TRUE, dt("Drupal sites directory is writable by the provisioning script"),
42
      dt("Drupal sites directory is not writable by the provisioning script"), 'PROVISION_SITES_DIR_NOT_WRITABLE');
43

44
    drush_set_option('sites', array_keys((array) provision_drupal_find_sites()), 'drupal'); 
45
    drush_log(dt("This platform is running @short_name @version", array('@short_name' => 'drupal', '@version' => VERSION)));
46
    drush_set_option('packages', _scrub_object(provision_find_packages()), 'drupal');
47
    _provision_drupal_create_directories('all');
48 49
  }
  else {
50
    drush_set_option('packages', _scrub_object(provision_drupal_system_map()), 'site');
51
      // This is the actual drupal provisioning requirements. 
52 53
    _provision_drupal_create_directories($url);
    _provision_drupal_maintain_aliases($url);
54
    // Requires at least the database settings to complete.
55
   _provision_drupal_create_settings_file($url);
56 57 58 59 60 61 62
  }
}


/**
 * Implementation of hook_provision_post_verify
 */
63
function drush_provision_drupal_post_provision_verify($url = NULL) {
64
  if (PROVISION_CONTEXT_SITE) {
65
    _provision_drupal_rebuild_caches($url);
66
    drush_set_option('aliases', drush_get_option('aliases'), 'site');
67
    drush_set_option('redirection', drush_get_option('redirection'), 'site');
68
    drush_set_option('installed', TRUE, 'site');
69 70 71
  }
}

72
/**
anarcat's avatar
anarcat committed
73 74 75 76 77 78 79 80
 * 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()
81 82
 */
function provision_drupal_provision_apache_dir_config($data = null) {
83 84
  $htaccess = file_get_contents(dirname(__FILE__) . "/provision_drupal_htaccess.tpl.php");
  $htaccess .= <<<EOF
anarcat's avatar
anarcat committed
85

86 87
# Do not read the platform's .htaccess
AllowOverride none
anarcat's avatar
anarcat committed
88

89
EOF;
anarcat's avatar
anarcat committed
90
  # the trailing newline above is necessary
91
  return $htaccess;
92
}