forked from acquia/blt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblt.settings.php
164 lines (143 loc) · 6.23 KB
/
blt.settings.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<?php
/*******************************************************************************
* Setup BLT utility variables.
******************************************************************************/
try {
$site_path = \Drupal\Core\DrupalKernel::findSitePath(\Symfony\Component\HttpFoundation\Request::createFromGlobals());
}
catch (\Symfony\Component\HttpKernel\Exception\BadRequestHttpException $e) {
$site_path = 'sites/default';
}
$site_dir = str_replace('sites/', '', $site_path);
/**
* Host detection.
*/
if (!empty($_SERVER['HTTP_X_FORWARDED_HOST'])) {
$forwarded_host = $_SERVER['HTTP_X_FORWARDED_HOST'];
}
elseif(!empty($_SERVER['HTTP_HOST'])) {
$forwarded_host = $_SERVER['HTTP_HOST'];
}
else {
$forwarded_host = NULL;
}
$server_protocol = empty($_SERVER['HTTPS']) ? 'http' : 'https';
$forwarded_protocol = !empty($_ENV['HTTP_X_FORWARDED_PROTO']) ? $_ENV['HTTP_X_FORWARDED_PROTO'] : $server_protocol;
/**
* Environment detection.
*
* Note that the values of enviromental variables are set differently on Acquia
* Cloud Free tier vs Acquia Cloud Professional and Enterprise.
*/
$ah_env = isset($_ENV['AH_SITE_ENVIRONMENT']) ? $_ENV['AH_SITE_ENVIRONMENT'] : NULL;
$ah_group = isset($_ENV['AH_SITE_GROUP']) ? $_ENV['AH_SITE_GROUP'] : NULL;
$is_ah_env = (bool) $ah_env;
$is_ah_prod_env = ($ah_env == 'prod' || $ah_env == '01live');
$is_ah_stage_env = ($ah_env == 'test' || $ah_env == '01test' || $ah_env == 'stg');
$is_ah_dev_cloud = (!empty($_SERVER['HTTP_HOST']) && strstr($_SERVER['HTTP_HOST'], 'devcloud'));
$is_ah_dev_env = (preg_match('/^dev[0-9]*$/', $ah_env) || $ah_env == '01dev');
$is_acsf = (!empty($ah_group) && file_exists("/mnt/files/$ah_group.$ah_env/files-private/sites.json"));
$acsf_db_name = $is_acsf ? $GLOBALS['gardens_site_settings']['conf']['acsf_db_name'] : NULL;
$is_local_env = !$is_ah_env;
/*******************************************************************************
* Acquia Cloud settings.
******************************************************************************/
if ($is_ah_env) {
if (!$is_acsf && file_exists('/var/www/site-php') && $site_dir == 'default') {
require "/var/www/site-php/{$_ENV['AH_SITE_GROUP']}/{$_ENV['AH_SITE_GROUP']}-settings.inc";
}
// Store API Keys and things outside of version control.
// @see settings/sample-secrets.settings.php for sample code.
$secrets_file = sprintf('/mnt/gfs/%s.%s/secrets.settings.php', $_ENV['AH_SITE_GROUP'], $_ENV['AH_SITE_ENVIRONMENT']);
if (file_exists($secrets_file)) {
require $secrets_file;
}
}
/*******************************************************************************
* BLT includes & BLT default configuration.
******************************************************************************/
// Includes caching configuration.
require __DIR__ . '/cache.settings.php';
// Includes configuration management settings.
require __DIR__ . '/config.settings.php';
// Includes logging configuration.
require __DIR__ . '/logging.settings.php';
// Includes filesystem configuration.
require __DIR__ . '/filesystem.settings.php';
// Prevent APCu memory exhaustion.
$settings['container_yamls'][] = __DIR__ . '/apcu_fix.yml';
// Include simplesamlphp settings if the file exists.
if (file_exists(__DIR__ . '/simplesamlphp.settings.php')) {
require __DIR__ . '/simplesamlphp.settings.php';
}
/**
* Salt for one-time login links, cancel links, form tokens, etc.
*
* This variable will be set to a random value by the installer. All one-time
* login links will be invalidated if the value is changed. Note that if your
* site is deployed on a cluster of web servers, you must ensure that this
* variable has the same value on each server.
*
* For enhanced security, you may set this variable to the contents of a file
* outside your document root; you should also ensure that this file is not
* stored with backups of your database.
*
* Example:
* @code
* $settings['hash_salt'] = file_get_contents('/home/example/salt.txt');
* @endcode
*/
$settings['hash_salt'] = file_get_contents(DRUPAL_ROOT . '/../salt.txt');
/**
* Deployment identifier.
*
* Drupal's dependency injection container will be automatically invalidated and
* rebuilt when the Drupal core version changes. When updating contributed or
* custom code that changes the container, changing this identifier will also
* allow the container to be invalidated as soon as code is deployed.
*/
$settings['deployment_identifier'] = \Drupal::VERSION;
$deploy_id_file = DRUPAL_ROOT . '/../deployment_identifier';
if (file_exists($deploy_id_file)) {
$settings['deployment_identifier'] = file_get_contents($deploy_id_file);
}
/*******************************************************************************
* Environment-specific includes.
******************************************************************************/
/**
* Include optional site specific includes file.
*
* This is being included before the local file so all available settings are
* able to be overridden in the local.settings.php file below.
*/
if (file_exists(DRUPAL_ROOT . "/sites/$site_dir/settings/includes.settings.php")) {
require DRUPAL_ROOT . "/sites/$site_dir/settings/includes.settings.php";
}
/**
* Load local development override configuration, if available.
*
* Use local.settings.php to override variables on secondary (staging,
* development, etc) installations of this site. Typically used to disable
* caching, JavaScript/CSS compression, re-routing of outgoing emails, and
* other things that should not happen on development and testing sites.
*
* Keep this code block at the end of this file to take full effect.
*/
if ($is_local_env) {
// Load local machine settings.
if (file_exists(DRUPAL_ROOT . "/sites/$site_dir/settings/local.settings.php")) {
require DRUPAL_ROOT . "/sites/$site_dir/settings/local.settings.php";
}
// Load Acquia Pipeline settings.
if (getenv('PIPELINE_ENV') && file_exists(__DIR__ . '/pipelines.settings.php')) {
require __DIR__ . '/pipelines.settings.php';
}
// Load Travis CI settings.
elseif (getenv('TRAVIS') && file_exists(__DIR__ . '/travis.settings.php')) {
require __DIR__ . '/travis.settings.php';
}
// Load Tugboat settings.
elseif (getenv('TUGBOAT_URL') && file_exists(__DIR__ . '/tugboat.settings.php')) {
require __DIR__ . '/tugboat.settings.php';
}
}