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

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

5
function http_drush_init($url = null) {
drumm's avatar
drumm committed
6
  // todo same as db, consolidate
drumm's avatar
drumm committed
7
  $command = drush_get_command();
8
  $command = explode(" ", $command['command']);
drumm's avatar
drumm committed
9
  if (preg_match("/^provision-/", $command[0])) {
10
    _provision_context_init($url);
11

12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
    if (PROVISION_CONTEXT_SERVER) {
      if (!is_null(drush_get_option('init_http'))) {
        // Bootstrap for alias creation.
        include_once(drush_get_option('init_http') . '/'. drush_get_option('init_http') .'_service.inc');
        $class = 'provisionService_http_' . drush_get_option('init_http');
        provision_service('http', new $class());
      }
    }
    else {
      // todo should be constructed based on drush aliases
      include_once('apache/apache_service.inc');
      provision_service('http', new provisionService_http_apache());
    }
  }
}
27

28
29
30
31
32
class provisionService_http extends provisionService {
  /**
   * Set defaults
   */
  function __construct() {
33
34
    // Set up defines for platform
    $docroot = drush_get_option(array("r", "root"), $_SERVER['PWD']);
35

36
    $path = drush_set_default('publish_path', rtrim(($docroot) ? $docroot : $_SERVER['DOCUMENT_ROOT'], '/'));
37
    drush_set_default('sites_path', $path . '/sites');
38
    drush_set_default('publish_path', realpath(drush_get_option('publish_path')));
39
40
41

    $parts = explode("/", $path);
    array_pop($parts);
42
    drush_set_default('parent_path', implode("/" , $parts));
43

44
    $parent_path = drush_get_option('parent_path');
45
46
47
48
49
50
51
52
53
54
55
56
    drush_set_default('backup_path', $parent_path . '/backups');
    drush_set_default('config_path', $parent_path . '/config');

    $config_path = drush_get_option('config_path');
    drush_set_default('vhost_path', $config_path . '/vhost.d');
    drush_set_default('platform_conf_path', $config_path . '/platform.d');

    // Commands
    drush_set_default('restart_cmd', _provision_default_restart_cmd());

    // System account
    drush_set_default('web_group', _provision_default_web_group());
anarcat's avatar
anarcat committed
57
58
    $pw = posix_getpwuid(posix_geteuid());
    drush_set_default('script_user', $pw['name']);
59
60
61
62
63
64
65
66
67
68
69
70

    // Redirection urls
    drush_set_default('master_url', $GLOBALS['base_url']);
    $master_url = drush_get_option('master_url');
    drush_set_default('web_disable_url', $master_url .'/hosting/disabled');
    drush_set_default('web_maintenence_url', $master_url .'/hosting/maintenance');

    drush_set_default('web_ip', '127.0.0.1');
    drush_set_default('web_port', 80);

    drush_set_default('site_port', 80);
  }
71

72
73
74
  /**
   * Ask the web server to check for and load configuration changes.
   */
75
  function parse_configs() {
76
    return TRUE;
77
78
  }

79
80
81
  /**
   * Generate a site specific configuration file
   */
82
  function create_site_config($url) {
83
    return TRUE;
84
85
  }

86
87
88
  /**
   * Remove an existing site configuration file.
   */
89
  function delete_site_config($url) {
90
    return TRUE;
91
92
  }

93
94
95
  /**
   * Add a new platform specific configuration file.
   */
96
  function create_platform_config($url) {
97
    return TRUE;
98
99
  }

100
101
102
  /**
   * Remove an existing platform configuration file.
   */
103
  function delete_platform_config() {
104
    return TRUE;
105
106
  }

107
108
109
  /**
   * Create a new server specific configuration file.
   */
110
  function create_server_config() {
111
    return TRUE;
112
113
  }

114
115
116
  /**
   * Remove an existing server specific configuration file
   */
117
  function delete_server_config() {
118
    return TRUE;
119
  }
drumm's avatar
drumm committed
120
121
122
123
124

  /**
   * Write out server's drushrc alias file.
   */
  function write_alias() {
drumm's avatar
drumm committed
125
    return array(drush_get_option('init_http') => array('web_host', 'web_ports', 'web_group', 'restart_cmd'));
drumm's avatar
drumm committed
126
  }
127
}