[core] allow sys-config settings to come from the environment
This commit is contained in:
parent
8fe54794d8
commit
fc6bb2d1b5
2 changed files with 12 additions and 2 deletions
|
@ -9,7 +9,8 @@ namespace Shimmie2;
|
||||||
* Shimmie will set the values to their defaults
|
* Shimmie will set the values to their defaults
|
||||||
*
|
*
|
||||||
* All of these can be over-ridden by placing a 'define' in
|
* All of these can be over-ridden by placing a 'define' in
|
||||||
* data/config/shimmie.conf.php
|
* data/config/shimmie.conf.php, or by setting an environment
|
||||||
|
* variable SHM_{$name} (eg SHM_DATABASE_DSN)
|
||||||
*
|
*
|
||||||
* Do NOT change them in this file. These are the defaults only!
|
* Do NOT change them in this file. These are the defaults only!
|
||||||
*
|
*
|
||||||
|
@ -20,6 +21,15 @@ namespace Shimmie2;
|
||||||
function _d(string $name, mixed $value): void
|
function _d(string $name, mixed $value): void
|
||||||
{
|
{
|
||||||
if (!defined($name)) {
|
if (!defined($name)) {
|
||||||
|
$env = getenv("SHM_{$name}");
|
||||||
|
if ($env !== false) {
|
||||||
|
try {
|
||||||
|
$value = json_decode($env);
|
||||||
|
}
|
||||||
|
catch(\Exception $e) {
|
||||||
|
$value = $env;
|
||||||
|
}
|
||||||
|
}
|
||||||
define($name, $value);
|
define($name, $value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ if (!file_exists("vendor/")) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!file_exists("data/config/shimmie.conf.php")) {
|
if (!file_exists("data/config/shimmie.conf.php") && !getenv("SHM_DATABASE_DSN")) {
|
||||||
require_once "core/install.php";
|
require_once "core/install.php";
|
||||||
install();
|
install();
|
||||||
exit;
|
exit;
|
||||||
|
|
Reference in a new issue