http.drush.inc 3.7 KB
Newer Older
1 2 3 4
<?php

include_once(dirname(__FILE__) . '/../provision.service.inc');

5 6

function http_provision_services() {
drumm's avatar
drumm committed
7
  return array('http' => NULL);
8
}
9

10 11

// Base http service class. 
12
class provisionService_http extends provisionService {
13
  public $service = 'http';
14 15
  protected $ssl_enabled = FALSE;
}
16

17
class provisionService_http_public extends provisionService_http {
18
  protected $has_port = TRUE;
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
   
  function default_port() {
    return 80;
  }

  function config_data($config = null, $class = null) {
    $data = parent::config_data($config, $class);

    $data['http_port'] = $this->server->http_port;

    if (!is_null($this->application_name)) {
      $data['http_confd_path'] = $this->server->http_confd_path;
      $data['http_platformd_path'] = $this->server->http_platformd_path;
      $data['http_vhostd_path'] = $this->server->http_vhostd_path;
    }

    // TODO: move away from drush_get_context entirely.
    if ($config == 'site') {
      $data = array_merge($data, drush_get_context_site('site'));
    }

    return $data;
  }
drumm's avatar
drumm committed
42

43 44
  function init() {
    parent::init();
45
    // System account
46
    if ($this->server->name == '@server_master') {
47 48 49
      $this->server->setProperty('web_group', _provision_default_web_group());
    }
    else {
50
      $this->server->web_group = d('@server_master')->web_group;
51
    }
52 53

    // Redirection urls
54 55
    $this->server->setProperty('web_disable_url', $this->server->master_url .'/hosting/disabled');
    $this->server->setProperty('web_maintenence_url', $this->server->master_url .'/hosting/maintenance');
56 57


58 59 60 61 62 63
    if (!is_null($this->application_name)) {
      $app_dir = "{$this->server->config_path}/{$this->application_name}";
      $this->server->http_confd_path = "{$app_dir}/conf.d";
      $this->server->http_platformd_path = "{$app_dir}/platform.d";
      $this->server->http_vhostd_path = "{$app_dir}/vhost.d";
    }
64 65
  }

66

67 68 69 70 71 72 73 74 75
  static function option_documentation() {
    return array(
      '--web_group' => 'server with http: OS group for permissions; working default will be attepted',
      '--web_disable_url' => 'server with http: URL disabled sites are redirected to; default {master_url}/hosting/disabled',
      '--web_maintenence_url' => 'server with http: URL maintenance sites are redirected to; default {master_url}/hosting/maintenance',
    );
  }


76
  function verify() {
77
    if ($this->context->type === 'server') {
78 79 80 81 82 83 84 85 86 87 88 89 90 91
      if (!is_null($this->application_name)) {
        provision_file()->create_dir($this->server->http_confd_path, dt("Webserver custom configuration"), 0700);
        $this->sync($this->server->http_confd_path);

        provision_file()->create_dir($this->server->http_platformd_path, dt("Webserver platform configuration"), 0700);
        $this->sync($this->server->http_platformd_path, array(
          'exclude' => $this->server->http_platformd_path . '/*',  // Make sure remote directory is created
        )); 

        provision_file()->create_dir($this->server->http_vhostd_path , dt("Webserver virtual host configuration"), 0700);
        $this->sync($this->server->http_vhostd_path, array(
          'exclude' => $this->server->http_vhostd_path . '/*',  // Make sure remote directory is created
        )); 
      } 
92 93
    }

94
    $this->create_config($this->context->type);
95 96 97
    $this->parse_configs();
  }

98 99 100
  /**
   * Ask the web server to check for and load configuration changes.
   */
101
  function parse_configs() {
102
    return TRUE;
103 104
  }

105 106 107 108 109 110 111
  /**
   * Support the ability to cloak the database credentials using environment variables.
   */
  function cloaked_db_creds() {
    return FALSE;
  }

112 113 114 115 116 117
  /**
   * Return a list of servers that will need database access.
   */
  function grant_server_list() {
    return array(
      $this->server,
118
      $this->context->platform->server,
119 120
    );
  }
121

122
}