From bc5a70c4c697c9ad277840e72989ee2a770e60e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20BENO=C3=8ET?= Date: Thu, 2 Jan 2025 14:21:51 +0100 Subject: [PATCH] feat: read most of the admin config from env vars --- game/admin/config.inc | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/game/admin/config.inc b/game/admin/config.inc index d5b361c..e8b7ddb 100644 --- a/game/admin/config.inc +++ b/game/admin/config.inc @@ -1,18 +1,36 @@ '127.0.0.1', - 'database' => 'legacyworlds', - 'user' => 'legacyworlds', - 'password' => 'password for the standard database user', - 'adminUser' => 'legacyworlds_admin', - 'adminPassword' => 'password for the administrative database user', + 'host' => getenv('LW_DB_HOST') ?: '127.0.0.1', + 'database' => getenv('LW_DB_NAME') ?: 'legacyworlds', + 'user' => getenv('LW_DB_USER_NAME') ?: 'legacyworlds', + 'password' => readSecret('LW_DB_USER_PASS'), + 'adminUser' => getenv('LW_DB_ADMIN_NAME') ?: 'legacyworlds_admin', + 'adminPassword' => readSecret('LW_DB_ADMIN_PASS'), 'ctrlFifo' =>'/tmp/.lwFifo', 'ctrlPath' =>'/tmp/.lwControl' ); -function __dbConnect($admin = false) { +function __dbConnect(bool $admin = false): \PgSql\Connection|bool { global $aConfig; $h = $aConfig['host']; $d = $aConfig['database'];