From c58049ecb9af1e7f0ff11f08380664e28368f9b4 Mon Sep 17 00:00:00 2001 From: Fllavian <> Date: Sat, 9 Nov 2024 14:01:48 +0100 Subject: [PATCH] feat: add support for default driver environment variable --- README.md | 24 ++++++++++++++++++++---- rootfs/var/www/html/index.php | 14 ++++++++++++++ 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 909748e..14b265a 100644 --- a/README.md +++ b/README.md @@ -92,10 +92,26 @@ docker run -p 8080:8080 -e ADMINER_DEFAULT_SERVER=mysql ghcr.io/shyim/adminerevo You can set following environment variable sto configure the login screen: -- `ADMINER_DEFAULT_SERVER` - default connection host -- `ADMINER_DEFAULT_USER` - default connection user -- `ADMINER_DEFAULT_PASSWORD` - default connection password -- `ADMINER_DEFAULT_DB` - default connection database +| Environment Variable | Description | +| -------------------- | ----------- | +| `ADMINER_DEFAULT_DRIVER` | default connection driver | +| `ADMINER_DEFAULT_SERVER` | default connection host | +| `ADMINER_DEFAULT_USER` | default connection user | +| `ADMINER_DEFAULT_PASSWORD` | default connection password | +| `ADMINER_DEFAULT_DB` | default connection database | + +The supported driver values are: + +| Value | Driver | +| ----- | ------ | +| `server` | MySQL | +| `sqlite` | SQLite 3 | +| `sqlite2` | SQLite 2 | +| `pgsql` | PostgreSQL | +| `oracle` | Oracle (beta) | +| `mssql` | MS SQL (beta) | +| `mongo` | MongoDB (beta) | +| `elastic` | Elasticsearch (beta) | ## Supported Drivers diff --git a/rootfs/var/www/html/index.php b/rootfs/var/www/html/index.php index 63f802c..fba01f1 100644 --- a/rootfs/var/www/html/index.php +++ b/rootfs/var/www/html/index.php @@ -11,6 +11,20 @@ function _callParent($function, $args) { $return = \Adminer::loginForm(); $form = ob_get_clean(); + if (getenv('ADMINER_DEFAULT_DRIVER') != 'server') { + $form = str_replace( + 'option value="server" selected', + 'option value="server"', + $form + ); + + $form = str_replace( + 'option value="'.(getenv('ADMINER_DEFAULT_DRIVER')).'"', + 'option value="'.(getenv('ADMINER_DEFAULT_DRIVER')).'" selected', + $form + ); + } + $form = str_replace( 'name="auth[server]" value="" title="hostname[:port]"', 'name="auth[server]" value="'.(getenv('ADMINER_DEFAULT_SERVER') ?: 'db').'" title="hostname[:port]"',