From 8b81e556e443f75c89fe760cfb0d10fa346d5205 Mon Sep 17 00:00:00 2001 From: Anderson Entwistle <46688047+aentwist@users.noreply.github.com> Date: Wed, 15 Mar 2023 00:56:49 -0400 Subject: [PATCH] feat: make database configuration environment variables independent Add utility function for environment variable / from file support. Signed-off-by: Anderson Entwistle <46688047+aentwist@users.noreply.github.com> --- .config/autoconfig.php | 32 ++++++++++---------------------- .config/smtp.config.php | 12 ++++-------- .config/util.php | 27 +++++++++++++++++++++++++++ README.md | 2 -- 4 files changed, 41 insertions(+), 32 deletions(-) create mode 100644 .config/util.php diff --git a/.config/autoconfig.php b/.config/autoconfig.php index 92ad2a1c..efe13615 100644 --- a/.config/autoconfig.php +++ b/.config/autoconfig.php @@ -1,37 +1,25 @@ 'smtp', @@ -8,15 +11,8 @@ if (getenv('SMTP_HOST') && getenv('MAIL_FROM_ADDRESS') && getenv('MAIL_DOMAIN')) 'mail_smtpauth' => getenv('SMTP_NAME') && (getenv('SMTP_PASSWORD') || (getenv('SMTP_PASSWORD_FILE') && file_exists(getenv('SMTP_PASSWORD_FILE')))), 'mail_smtpauthtype' => getenv('SMTP_AUTHTYPE') ?: 'LOGIN', 'mail_smtpname' => getenv('SMTP_NAME') ?: '', + 'mail_smtppassword' => getFileEnv('SMTP_PASSWORD', ''), 'mail_from_address' => getenv('MAIL_FROM_ADDRESS'), 'mail_domain' => getenv('MAIL_DOMAIN'), ); - - if (getenv('SMTP_PASSWORD_FILE') && file_exists(getenv('SMTP_PASSWORD_FILE'))) { - $CONFIG['mail_smtppassword'] = trim(file_get_contents(getenv('SMTP_PASSWORD_FILE'))); - } elseif (getenv('SMTP_PASSWORD')) { - $CONFIG['mail_smtppassword'] = getenv('SMTP_PASSWORD'); - } else { - $CONFIG['mail_smtppassword'] = ''; - } } diff --git a/.config/util.php b/.config/util.php new file mode 100644 index 00000000..6c73e5b5 --- /dev/null +++ b/.config/util.php @@ -0,0 +1,27 @@ + diff --git a/README.md b/README.md index 20a9cecf..4cc779ed 100644 --- a/README.md +++ b/README.md @@ -388,8 +388,6 @@ secrets: Currently, this is only supported for `NEXTCLOUD_ADMIN_PASSWORD`, `NEXTCLOUD_ADMIN_USER`, `MYSQL_DATABASE`, `MYSQL_PASSWORD`, `MYSQL_USER`, `POSTGRES_DB`, `POSTGRES_PASSWORD`, `POSTGRES_USER`, `REDIS_HOST_PASSWORD`, `SMTP_PASSWORD`, `OBJECTSTORE_S3_KEY`, and `OBJECTSTORE_S3_SECRET`. -If you set any group of values (i.e. all of `MYSQL_DATABASE_FILE`, `MYSQL_USER_FILE`, `MYSQL_PASSWORD_FILE`, `MYSQL_HOST`), the script will not use the corresponding group of environment variables (`MYSQL_DATABASE`, `MYSQL_USER`, `MYSQL_PASSWORD`, `MYSQL_HOST`). - # Make your Nextcloud available from the internet Until here, your Nextcloud is just available from your docker host. If you want your Nextcloud available from the internet adding SSL encryption is mandatory.