Skip to content

Commit

Permalink
Merge pull request #6 from Fllavian/default-driver
Browse files Browse the repository at this point in the history
feat: add support for default driver environment variable
  • Loading branch information
shyim authored Nov 9, 2024
2 parents 9586ec0 + c58049e commit 1f19584
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
24 changes: 20 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 14 additions & 0 deletions rootfs/var/www/html/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]"',
Expand Down

0 comments on commit 1f19584

Please sign in to comment.