Skip to content

Commit d76149e

Browse files
committed
Update autoconfig.php.tpl, redis.config.php.tpl, and smtp.config.php.tpl
Synchronizes default config.php files from nextcloud/docker to add file env vars: - Redis: Adds REDIS_HOST_PASSWORD_FILE, cleans up formatting to match upstream - Autoconfig: Adds MYSQL_DATABASE_FILE, MYSQL_USER_FILE, MYSQL_PASSWORD_FILE, POSTGRES_DB_FILE, POSTGRES_USER_FILE, and POSTGRES_PASSWORD_FILE - smtp: adds SMTP_PASSWORD_FILE Signed-off-by: jessebot <jessebot@linux.com>
1 parent bf6cc4a commit d76149e

3 files changed

Lines changed: 31 additions & 7 deletions

File tree

charts/nextcloud/files/defaultConfigs/autoconfig.php.tpl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,27 @@ if (getenv('SQLITE_DATABASE')) {
44
$AUTOCONFIG["dbtype"] = "sqlite";
55
$AUTOCONFIG["dbname"] = getenv('SQLITE_DATABASE');
66
$autoconfig_enabled = true;
7+
} elseif (getenv('MYSQL_DATABASE_FILE') && getenv('MYSQL_USER_FILE') && getenv('MYSQL_PASSWORD_FILE') && getenv('MYSQL_HOST')) {
8+
$AUTOCONFIG['dbtype'] = 'mysql';
9+
$AUTOCONFIG['dbname'] = trim(file_get_contents(getenv('MYSQL_DATABASE_FILE')));
10+
$AUTOCONFIG['dbuser'] = trim(file_get_contents(getenv('MYSQL_USER_FILE')));
11+
$AUTOCONFIG['dbpass'] = trim(file_get_contents(getenv('MYSQL_PASSWORD_FILE')));
12+
$AUTOCONFIG['dbhost'] = getenv('MYSQL_HOST');
13+
$autoconfig_enabled = true;
714
} elseif (getenv('MYSQL_DATABASE') && getenv('MYSQL_USER') && getenv('MYSQL_PASSWORD') && getenv('MYSQL_HOST')) {
815
$AUTOCONFIG["dbtype"] = "mysql";
916
$AUTOCONFIG["dbname"] = getenv('MYSQL_DATABASE');
1017
$AUTOCONFIG["dbuser"] = getenv('MYSQL_USER');
1118
$AUTOCONFIG["dbpass"] = getenv('MYSQL_PASSWORD');
1219
$AUTOCONFIG["dbhost"] = getenv('MYSQL_HOST');
1320
$autoconfig_enabled = true;
21+
} elseif (getenv('POSTGRES_DB_FILE') && getenv('POSTGRES_USER_FILE') && getenv('POSTGRES_PASSWORD_FILE') && getenv('POSTGRES_HOST')) {
22+
$AUTOCONFIG['dbtype'] = 'pgsql';
23+
$AUTOCONFIG['dbname'] = trim(file_get_contents(getenv('POSTGRES_DB_FILE')));
24+
$AUTOCONFIG['dbuser'] = trim(file_get_contents(getenv('POSTGRES_USER_FILE')));
25+
$AUTOCONFIG['dbpass'] = trim(file_get_contents(getenv('POSTGRES_PASSWORD_FILE')));
26+
$AUTOCONFIG['dbhost'] = getenv('POSTGRES_HOST');
27+
$autoconfig_enabled = true;
1428
} elseif (getenv('POSTGRES_DB') && getenv('POSTGRES_USER') && getenv('POSTGRES_PASSWORD') && getenv('POSTGRES_HOST')) {
1529
$AUTOCONFIG["dbtype"] = "pgsql";
1630
$AUTOCONFIG["dbname"] = getenv('POSTGRES_DB');
Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
<?php
22
if (getenv('REDIS_HOST')) {
3-
$CONFIG = array (
3+
$CONFIG = array(
44
'memcache.distributed' => '\OC\Memcache\Redis',
55
'memcache.locking' => '\OC\Memcache\Redis',
66
'redis' => array(
77
'host' => getenv('REDIS_HOST'),
8-
'port' => getenv('REDIS_HOST_PORT') ?: 6379,
9-
{{- if .Values.redis.auth.enabled }}
10-
'password' => getenv('REDIS_HOST_PASSWORD'),
11-
{{- end }}
8+
'password' => getenv('REDIS_HOST_PASSWORD_FILE') ? trim(file_get_contents(getenv('REDIS_HOST_PASSWORD_FILE'))) : (string) getenv('REDIS_HOST_PASSWORD'),
129
),
1310
);
11+
12+
if (getenv('REDIS_HOST_PORT') !== false) {
13+
$CONFIG['redis']['port'] = (int) getenv('REDIS_HOST_PORT');
14+
} elseif (getenv('REDIS_HOST')[0] != '/') {
15+
$CONFIG['redis']['port'] = 6379;
16+
}
1417
}

charts/nextcloud/files/defaultConfigs/smtp.config.php.tpl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,18 @@ if (getenv('SMTP_HOST') && getenv('MAIL_FROM_ADDRESS') && getenv('MAIL_DOMAIN'))
55
'mail_smtphost' => getenv('SMTP_HOST'),
66
'mail_smtpport' => getenv('SMTP_PORT') ?: (getenv('SMTP_SECURE') ? 465 : 25),
77
'mail_smtpsecure' => getenv('SMTP_SECURE') ?: '',
8-
'mail_smtpauth' => getenv('SMTP_NAME') && getenv('SMTP_PASSWORD'),
8+
'mail_smtpauth' => getenv('SMTP_NAME') && (getenv('SMTP_PASSWORD') || getenv('SMTP_PASSWORD_FILE')),
99
'mail_smtpauthtype' => getenv('SMTP_AUTHTYPE') ?: 'LOGIN',
1010
'mail_smtpname' => getenv('SMTP_NAME') ?: '',
11-
'mail_smtppassword' => getenv('SMTP_PASSWORD') ?: '',
1211
'mail_from_address' => getenv('MAIL_FROM_ADDRESS'),
1312
'mail_domain' => getenv('MAIL_DOMAIN'),
1413
);
14+
15+
if (getenv('SMTP_PASSWORD_FILE')) {
16+
$CONFIG['mail_smtppassword'] = trim(file_get_contents(getenv('SMTP_PASSWORD_FILE')));
17+
} elseif (getenv('SMTP_PASSWORD')) {
18+
$CONFIG['mail_smtppassword'] = getenv('SMTP_PASSWORD');
19+
} else {
20+
$CONFIG['mail_smtppassword'] = '';
21+
}
1522
}

0 commit comments

Comments
 (0)