From 1e38669aa0a1e61fcfb9b2323a016b2cb5abe715 Mon Sep 17 00:00:00 2001 From: Rodolfo Berrios <20590102+rodber@users.noreply.github.com> Date: Sat, 20 Nov 2021 12:42:49 -0300 Subject: [PATCH] close #105 --- app/loader.php | 12 ++++++++---- app/settings-env.php | 24 ++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 4 deletions(-) create mode 100644 app/settings-env.php diff --git a/app/loader.php b/app/loader.php index d6e10c0..5a19b1d 100644 --- a/app/loader.php +++ b/app/loader.php @@ -25,14 +25,18 @@ if (!defined('access') or !access) { } // settings.php workaround -if (!is_readable(dirname(__FILE__) . '/settings.php')) { - if (!@fopen(dirname(__FILE__) . '/settings.php', 'w')) { +if (!is_readable(__DIR__ . '/settings.php')) { + if (!@fopen(__DIR__ . '/settings.php', 'w')) { die("Chevereto can't create the app/settings.php file. You must manually create this file."); } } - +if(getenv('CHEVERETO_SERVICING') == 'docker') { + require_once __DIR__ . '/settings-env.php'; +} // G thing -(file_exists(dirname(dirname(__FILE__)) . '/lib/G/G.php')) ? require_once(dirname(dirname(__FILE__)) . '/lib/G/G.php') : die("Can't find lib/G/G.php"); +(file_exists(dirname(__FILE__, 2) . '/lib/G/G.php')) + ? require_once dirname(__FILE__, 2) . '/lib/G/G.php' + : die("Can't find lib/G/G.php"); // Require at least X memory to do the thing $min_memory = '256M'; diff --git a/app/settings-env.php b/app/settings-env.php new file mode 100644 index 0000000..9705902 --- /dev/null +++ b/app/settings-env.php @@ -0,0 +1,24 @@ + getenv('CHEVERETO_DB_DRIVER'), + 'db_host' => getenv('CHEVERETO_DB_HOST'), + 'db_name' => getenv('CHEVERETO_DB_NAME'), + 'db_pass' => getenv('CHEVERETO_DB_PASS'), + 'db_pdo_attrs' => json_decode(getenv('CHEVERETO_DB_PDO_ATTRS'), true), + 'db_port' => (int) getenv('CHEVERETO_DB_PORT'), + 'db_table_prefix' => getenv('CHEVERETO_DB_TABLE_PREFIX'), + 'db_user' => getenv('CHEVERETO_DB_USER'), + 'debug_level' => (int) getenv('CHEVERETO_DEBUG_LEVEL'), + 'disable_php_pages' => (bool) getenv('CHEVERETO_DISABLE_PHP_PAGES'), + 'disable_update_http' => (bool) getenv('CHEVERETO_DISABLE_UPDATE_HTTP'), + 'disable_update_cli' => (bool) getenv('CHEVERETO_DISABLE_UPDATE_CLI'), + 'error_log' => getenv('CHEVERETO_ERROR_LOG'), + 'hostname_path' => getenv('CHEVERETO_HOSTNAME_PATH'), + 'hostname' => getenv('CHEVERETO_HOSTNAME'), + 'https' => (bool) getenv('CHEVERETO_HTTPS'), + 'image_formats_available' => json_decode(getenv('CHEVERETO_IMAGE_FORMATS_AVAILABLE'), true), + 'image_library' => getenv('CHEVERETO_IMAGE_LIBRARY'), + 'session.save_handler' => getenv('CHEVERETO_SESSION_SAVE_HANDLER'), + 'session.save_path' => getenv('CHEVERETO_SESSION_SAVE_PATH'), +]; \ No newline at end of file