This repository has been archived by the owner on Jun 25, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
update-config.php
95 lines (76 loc) · 3.05 KB
/
update-config.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
#!/usr/bin/env php
<?php
require('/www/lib/jelix/utils/jIniFileModifier.class.php');
/**
* lizmapConfig.ini.php
*/
$lizmapConfig = new jIniFileModifier('/www/lizmap/var/config/lizmapConfig.ini.php');
$lizmapConfig->setValue('wmsServerURL', getenv('LIZMAP_WMSSERVERURL'), 'services');
$lizmapConfig->setValue('cacheRedisHost', getenv('LIZMAP_CACHEREDISHOST'), 'services');
foreach(array(
'cacheRedisPort' => 'LIZMAP_CACHEREDISPORT',
'cacheExpiration' => 'LIZMAP_CACHEEXPIRATION',
'debugMode' => 'LIZMAP_DEBUGMODE',
'cacheStorageType' => 'LIZMAP_CACHESTORAGETYPE',
'cacheRedisDb' => 'LIZMAP_CACHEREDISDB',
'cacheRedisKeyPrefix' => 'LIZMAP_CACHEREDISKEYPREFIX',
) as $key => $envValue
) {
if (getenv($envValue) !== false) {
$lizmapConfig->setValue($key, getenv($envValue), 'services');
}
}
$lizmapConfig->save();
/**
* localconfig.ini.php
*/
$localConfig = new jIniFileModifier('/www/lizmap/var/config/localconfig.ini.php');
// Set up WPS configuration
if (getenv("LIZMAP_WPS_URL") !== false) {
$localConfig->setValue('wps.access', 2, 'modules');
$localConfig->setValues(array(
'wps_rootUrl' => getenv('LIZMAP_WPS_URL'),
'ows_url' => getenv('LIZMAP_WMSSERVERURL'),
'wps_rootDirectories' => "/srv/projects",
// Redis config
'redis_port' => getenv('LIZMAP_CACHEREDISPORT') ?: 6379,
'redis_host' => getenv('LIZMAP_CACHEREDISHOST') ?: 'redis',
'redis_db' => getenv('LIZMAP_CACHEREDISDB') ?: 1,
'redis_key_prefix' => "wpslizmap"
),
'wps');
} else {
$localConfig->setValue('wps.access', 0, 'modules');
}
// Set urlengine config
if (getenv('LIZMAP_PROXYURL_PROTOCOL') !== false) {
$localConfig->setValue('checkHttpsOnParsing', false, 'urlengine');
$localConfig->setValue('forceProxyProtocol', getenv('LIZMAP_PROXYURL_PROTOCOL'), 'urlengine');
// By default, use the 443 https port
if (getenv('LIZMAP_PROXYURL_HTTPS_PORT') !== false) {
$config['forceHTTPSPort'] = getenv('LIZMAP_PROXYURL_HTTPS_PORT');
$localConfig->setValue('forceHTTPSPort', getenv('LIZMAP_PROXYURL_HTTPS_PORT'));
}
else {
$localConfig->setValue('forceHTTPSPort', 443);
}
}
if (getenv('LIZMAP_PROXYURL_DOMAIN') !== false) {
$localConfig->setValue('domainName', getenv('LIZMAP_PROXYURL_DOMAIN'), 'urlengine');
}
if (getenv('LIZMAP_PROXYURL_BASEPATH') !== false) {
$localConfig->setValue('basePath', getenv('LIZMAP_PROXYURL_BASEPATH'), 'urlengine');
}
if (getenv('LIZMAP_PROXYURL_BACKENDBASEPATH') !== false) {
$localConfig->setValue('backendBasePath', getenv('LIZMAP_PROXYURL_BACKENDBASEPATH'), 'urlengine');
}
if (getenv('LIZMAP_THEME') !== false) {
$localConfig->setValue('theme', getenv('LIZMAP_THEME'));
}
// Update mail config
$mailConfigFile = '/srv/etc/mailconfig.ini';
if (file_exists($mailConfigFile)) {
$mailConfig = parse_ini_file($mailConfigFile, true);
$localConfig->setValues($mailConfig['mailer'], 'mailer');
}
$localConfig->save();