This repository was archived by the owner on Mar 5, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 394
/
Copy pathblt.settings.php
260 lines (231 loc) · 9.08 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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
<?php
/**
* @file
* Setup BLT utility variables, include required files.
*/
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use Symfony\Component\HttpFoundation\Request;
use Drupal\Core\DrupalKernel;
/**
* 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.
******************************************************************************/
/**
* CI envs.
*/
$is_travis_env = isset($_ENV['TRAVIS']);
$is_pipelines_env = isset($_ENV['PIPELINE_ENV']);
$is_probo_env = isset($_ENV['PROBO_ENVIRONMENT']);
$is_tugboat_env = isset($_ENV['TUGBOAT_URL']);
$is_ci_env = $is_travis_env || $is_pipelines_env || $is_probo_env || $is_tugboat_env;
/**
* Acquia envs.
*
* Note that the values of environmental 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_ah_ode_env = (preg_match('/^ode[0-9]*$/', $ah_env));
$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;
/**
* Pantheon envs.
*/
$is_pantheon_env = isset($_ENV['PANTHEON_ENVIRONMENT']);
$pantheon_env = $is_pantheon_env ? $_ENV['PANTHEON_ENVIRONMENT'] : NULL;
$is_pantheon_dev_env = $pantheon_env == 'dev';
$is_pantheon_stage_env = $pantheon_env == 'test';
$is_pantheon_prod_env = $pantheon_env == 'live';
/**
* Local envs.
*/
$is_local_env = !$is_ah_env && !$is_pantheon_env;
/**
* Common variables.
*/
$is_dev_env = $is_ah_dev_env || $is_pantheon_dev_env;
$is_stage_env = $is_ah_stage_env || $is_pantheon_stage_env;
$is_prod_env = $is_ah_prod_env || $is_pantheon_prod_env;
/**
* Site directory detection.
*/
try {
$site_path = DrupalKernel::findSitePath(Request::createFromGlobals());
}
catch (BadRequestHttpException $e) {
$site_path = 'sites/default';
}
$site_dir = str_replace('sites/', '', $site_path);
// ACSF uses a pseudo-multisite architecture that places all site files under
// sites/g/files, which isn't useful for our purposes.
if ($is_acsf) {
$site_dir = 'default';
}
/*******************************************************************************
* Acquia Cloud settings.
*
* These includes are intentionally loaded before all others because we do not
* have control over their contents. By loading all other includes after this,
* we have the opportunity to override any configuration values provided by the
* hosted files. This is not necessary for files that we control.
******************************************************************************/
if ($is_ah_env) {
if (!$is_acsf && file_exists('/var/www/site-php')) {
if ($site_dir == 'default') {
require "/var/www/site-php/{$_ENV['AH_SITE_GROUP']}/{$_ENV['AH_SITE_GROUP']}-settings.inc";
}
// Includes multisite settings for given site.
elseif (file_exists("/var/www/site-php/{$_ENV['AH_SITE_GROUP']}/$site_dir-settings.inc")) {
require "/var/www/site-php/{$_ENV['AH_SITE_GROUP']}/$site_dir-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;
}
// Includes secrets file for given site.
$site_secrets_file = sprintf("/mnt/gfs/%s.%s/$site_dir/secrets.settings.php", $_ENV['AH_SITE_GROUP'], $_ENV['AH_SITE_ENVIRONMENT']);
if (file_exists($site_secrets_file)) {
require $site_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);
}
/**
* Include custom global settings files.
*
* This is intended for to provide an opportunity for applications to override
* any previous configuration at a global or multisite level.
*
* This is being included before the CI and site specific files so all available
* settings are able to be overridden in the includes.settings.php file below.
*/
if ($settings_files = glob(DRUPAL_ROOT . "/sites/settings/*.settings.php")) {
foreach ($settings_files as $settings_file) {
require $settings_file;
}
}
/*******************************************************************************
* Environment-specific includes.
******************************************************************************/
/**
* Load CI env includes.
*/
// Load Acquia Pipeline settings.
if ($is_pipelines_env) {
require __DIR__ . '/pipelines.settings.php';
}
// Load Travis CI settings.
elseif ($is_travis_env) {
require __DIR__ . '/travis.settings.php';
}
// Load Tugboat settings.
elseif ($is_tugboat_env) {
require __DIR__ . '/tugboat.settings.php';
}
// Load Probo settings.
elseif ($is_probo_env) {
require __DIR__ . '/probo.settings.php';
}
/**
* Include optional site specific includes file.
*
* This is intended for to provide an opportunity for applications to override
* any previous configuration.
*
* 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.
*
* This is intended to provide an opportunity for local environments to override
* any previous configuration.
*
* 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 settings for all sites.
if (file_exists(DRUPAL_ROOT . "/sites/settings/local.settings.php")) {
require DRUPAL_ROOT . "/sites/settings/local.settings.php";
}
// Load local settings for given single.
if (file_exists(DRUPAL_ROOT . "/sites/$site_dir/settings/local.settings.php")) {
require DRUPAL_ROOT . "/sites/$site_dir/settings/local.settings.php";
}
}