From f63d40ddb70a9578cd34af242ea43ef92e97833c Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Mon, 29 Jul 2024 16:16:05 +0100 Subject: [PATCH] Add optional environment variables configuration option and force timezone to use UTC (#68) * Add optional env vars config * Force timezone to UTC * Reword --- DOCS.md | 9 +++++++++ config.json | 9 +++++++-- rootfs/etc/services.d/ghostfolio/run | 11 ++++++++++- translations/en.yaml | 3 +++ 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/DOCS.md b/DOCS.md index 1ca6c45..f769843 100644 --- a/DOCS.md +++ b/DOCS.md @@ -33,6 +33,15 @@ The configuration is self-explanatory, but essentially we need details about acc - `silent`: (Optional) Hide all output except errors in the log file. Default: `false`. +- `env_vars`: (Optional) Set additional environment variables for Ghostfolio which aren't currently exposed by the configuration options in this add-on. + + Each entry is made up of a name and value: + + - `name`: The case-sensitive environment variable name. + - `value`: The value to be set in the environment variable. + + Note: These will also overwrite any environment variable set using the configuration options above. + Remember to restart the add-on when the configuration is changed. To use this add-on with a reverse proxy, like [Nginx Proxy Manager][rev-proxy], you will need to enable "Show disabled ports" in the Network section of the add-on configuration and set a port. diff --git a/config.json b/config.json index a07b0d5..2f15bc8 100644 --- a/config.json +++ b/config.json @@ -23,7 +23,8 @@ "database_pass": null, "database_port": 5432, "database_host": null, - "database_name": "ghostfolio" + "database_name": "ghostfolio", + "env_vars": [] }, "schema": { "database_user": "str", @@ -35,7 +36,11 @@ "api_key_coingecko_pro": "str?", "access_token_salt": "str?", "jwt_secret_key": "str?", - "silent": "bool?" + "silent": "bool?", + "env_vars": [{ + "name": "str?", + "value": "str?" + }] }, "codenotary": "colin@symr.io", "image": "ghcr.io/lildude/ha-addon-ghostfolio-{arch}" diff --git a/rootfs/etc/services.d/ghostfolio/run b/rootfs/etc/services.d/ghostfolio/run index 88c210a..b2a6c35 100644 --- a/rootfs/etc/services.d/ghostfolio/run +++ b/rootfs/etc/services.d/ghostfolio/run @@ -41,9 +41,18 @@ REDIS_HOST=localhost REDIS_PORT=6379 NODE_ENV=production DATABASE_URL="postgresql://$POSTGRES_USER:$POSTGRES_PASS@$POSTGRES_HOST:$POSTGRES_PORT/$POSTGRES_DB?connect_timeout=300&sslmode=prefer" +TZ=UTC # Force timezone to prevent https://github.com/ghostfolio/ghostfolio/issues/2669 which is probably due to https://github.com/brianc/node-postgres/issues/2141 export ACCESS_TOKEN_SALT JWT_SECRET_KEY POSTGRES_HOST POSTGRES_DB POSTGRES_PASS POSTGRES_PORT POSTGRES_USER \ - API_KEY_COINGECKO_DEMO API_KEY_COINGECKO_PRO REDIS_HOST REDIS_PORT NODE_ENV DATABASE_URL + API_KEY_COINGECKO_DEMO API_KEY_COINGECKO_PRO REDIS_HOST REDIS_PORT NODE_ENV DATABASE_URL TZ + +# These are optional and applied last so we can override those set above if needed. +for env_var in $(bashio::config 'env_vars|keys'); do + name=$(bashio::config "env_vars[${env_var}].name") + value=$(bashio::config "env_vars[${env_var}].value") + bashio::log.debug "Setting Env Variable ${name} to ${value}" + export "${name}=${value}" +done bashio::log.info "Starting Ghostfolio" cd /ghostfolio/apps/api diff --git a/translations/en.yaml b/translations/en.yaml index 30f0e28..f884b28 100644 --- a/translations/en.yaml +++ b/translations/en.yaml @@ -29,3 +29,6 @@ configuration: silent: name: Silent mode description: Hide all output except errors in the log file. + env_vars: + name: Environment Variables + description: Set additional environment variables for Ghostfolio which aren't currently exposed by the configuration options in this add-on.