mirror of
https://github.com/nextcloud/docker.git
synced 2025-02-28 20:54:53 +01:00
autoconfig: Allow mixing _FILE variables
We do not always need to configure variables as either a file or not for all variables. Instead, allow us to mix-match variable storage. This allows us to keep all non-critical variables in regular (env) variables, but keep the password in a (secret) file only location. Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
This commit is contained in:
parent
f2c8cb599e
commit
94bff07f59
1 changed files with 40 additions and 22 deletions
|
@ -6,32 +6,50 @@ if (getenv('SQLITE_DATABASE')) {
|
||||||
$AUTOCONFIG['dbtype'] = 'sqlite';
|
$AUTOCONFIG['dbtype'] = 'sqlite';
|
||||||
$AUTOCONFIG['dbname'] = getenv('SQLITE_DATABASE');
|
$AUTOCONFIG['dbname'] = getenv('SQLITE_DATABASE');
|
||||||
$autoconfig_enabled = true;
|
$autoconfig_enabled = true;
|
||||||
} elseif (getenv('MYSQL_DATABASE_FILE') && getenv('MYSQL_USER_FILE') && getenv('MYSQL_PASSWORD_FILE') && getenv('MYSQL_HOST')) {
|
} else if ((getenv('MYSQL_DATABASE_FILE') || getenv('MYSQL_DATABASE')) &&
|
||||||
|
(getenv('MYSQL_USER_FILE') || getenv('MYSQL_USER')) &&
|
||||||
|
(getenv('MYSQL_PASSWORD_FILE') || getenv('MYSQL_PASSWORD')) &&
|
||||||
|
getenv('MYSQL_HOST')) {
|
||||||
$AUTOCONFIG['dbtype'] = 'mysql';
|
$AUTOCONFIG['dbtype'] = 'mysql';
|
||||||
|
|
||||||
|
if (getenv('MYSQL_DATABASE_FILE'))
|
||||||
$AUTOCONFIG['dbname'] = trim(file_get_contents(getenv('MYSQL_DATABASE_FILE')));
|
$AUTOCONFIG['dbname'] = trim(file_get_contents(getenv('MYSQL_DATABASE_FILE')));
|
||||||
$AUTOCONFIG['dbuser'] = trim(file_get_contents(getenv('MYSQL_USER_FILE')));
|
elseif (getenv('MYSQL_DATABASE'))
|
||||||
$AUTOCONFIG['dbpass'] = trim(file_get_contents(getenv('MYSQL_PASSWORD_FILE')));
|
|
||||||
$AUTOCONFIG['dbhost'] = getenv('MYSQL_HOST');
|
|
||||||
$autoconfig_enabled = true;
|
|
||||||
} elseif (getenv('MYSQL_DATABASE') && getenv('MYSQL_USER') && getenv('MYSQL_PASSWORD') && getenv('MYSQL_HOST')) {
|
|
||||||
$AUTOCONFIG['dbtype'] = 'mysql';
|
|
||||||
$AUTOCONFIG['dbname'] = getenv('MYSQL_DATABASE');
|
$AUTOCONFIG['dbname'] = getenv('MYSQL_DATABASE');
|
||||||
|
|
||||||
|
if (getenv('MYSQL_USER_FILE'))
|
||||||
|
$AUTOCONFIG['dbuser'] = trim(file_get_contents(getenv('MYSQL_USER_FILE')));
|
||||||
|
elseif (getenv('MYSQL_USER'))
|
||||||
$AUTOCONFIG['dbuser'] = getenv('MYSQL_USER');
|
$AUTOCONFIG['dbuser'] = getenv('MYSQL_USER');
|
||||||
|
|
||||||
|
if (getenv('MYSQL_PASSWORD_FILE'))
|
||||||
|
$AUTOCONFIG['dbpass'] = trim(file_get_contents(getenv('MYSQL_PASSWORD_FILE')));
|
||||||
|
elseif (getenv('MYSQL_PASSWORD'))
|
||||||
$AUTOCONFIG['dbpass'] = getenv('MYSQL_PASSWORD');
|
$AUTOCONFIG['dbpass'] = getenv('MYSQL_PASSWORD');
|
||||||
|
|
||||||
$AUTOCONFIG['dbhost'] = getenv('MYSQL_HOST');
|
$AUTOCONFIG['dbhost'] = getenv('MYSQL_HOST');
|
||||||
$autoconfig_enabled = true;
|
$autoconfig_enabled = true;
|
||||||
} elseif (getenv('POSTGRES_DB_FILE') && getenv('POSTGRES_USER_FILE') && getenv('POSTGRES_PASSWORD_FILE') && getenv('POSTGRES_HOST')) {
|
} elseif ((getenv('POSTGRES_DB_FILE') || getenv('POSTGRES_DB')) &&
|
||||||
|
(getenv('POSTGRES_USER_FILE') || getenv('POSTGRES_USER')) &&
|
||||||
|
(getenv('POSTGRES_PASSWORD_FILE') || getenv('POSTGRES_PASSWORD')) &&
|
||||||
|
getenv('POSTGRES_HOST')) {
|
||||||
$AUTOCONFIG['dbtype'] = 'pgsql';
|
$AUTOCONFIG['dbtype'] = 'pgsql';
|
||||||
|
|
||||||
|
if (getenv('POSTGRES_DB_FILE'))
|
||||||
$AUTOCONFIG['dbname'] = trim(file_get_contents(getenv('POSTGRES_DB_FILE')));
|
$AUTOCONFIG['dbname'] = trim(file_get_contents(getenv('POSTGRES_DB_FILE')));
|
||||||
$AUTOCONFIG['dbuser'] = trim(file_get_contents(getenv('POSTGRES_USER_FILE')));
|
elseif (getenv('POSTGRES_DB'))
|
||||||
$AUTOCONFIG['dbpass'] = trim(file_get_contents(getenv('POSTGRES_PASSWORD_FILE')));
|
|
||||||
$AUTOCONFIG['dbhost'] = getenv('POSTGRES_HOST');
|
|
||||||
$autoconfig_enabled = true;
|
|
||||||
} elseif (getenv('POSTGRES_DB') && getenv('POSTGRES_USER') && getenv('POSTGRES_PASSWORD') && getenv('POSTGRES_HOST')) {
|
|
||||||
$AUTOCONFIG['dbtype'] = 'pgsql';
|
|
||||||
$AUTOCONFIG['dbname'] = getenv('POSTGRES_DB');
|
$AUTOCONFIG['dbname'] = getenv('POSTGRES_DB');
|
||||||
|
|
||||||
|
if (getenv('POSTGRES_USER_FILE'))
|
||||||
|
trim(file_get_contents(getenv('POSTGRES_USER_FILE')));
|
||||||
|
elseif (getenv('POSTGRES_USER'))
|
||||||
$AUTOCONFIG['dbuser'] = getenv('POSTGRES_USER');
|
$AUTOCONFIG['dbuser'] = getenv('POSTGRES_USER');
|
||||||
|
|
||||||
|
if (getenv('POSTGRES_PASSWORD_FILE'))
|
||||||
|
$AUTOCONFIG['dbpass'] = trim(file_get_contents(getenv('POSTGRES_PASSWORD_FILE')));
|
||||||
|
elseif (getenv('POSTGRES_PASSWORD'))
|
||||||
$AUTOCONFIG['dbpass'] = getenv('POSTGRES_PASSWORD');
|
$AUTOCONFIG['dbpass'] = getenv('POSTGRES_PASSWORD');
|
||||||
|
|
||||||
$AUTOCONFIG['dbhost'] = getenv('POSTGRES_HOST');
|
$AUTOCONFIG['dbhost'] = getenv('POSTGRES_HOST');
|
||||||
$autoconfig_enabled = true;
|
$autoconfig_enabled = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue