Use existing FILE__ notation

This commit is contained in:
Colin Hebert
2022-12-29 11:45:25 +01:00
parent e56575b088
commit 0145930d55
2 changed files with 2 additions and 28 deletions

View File

@@ -1,29 +1,3 @@
#!/bin/bash
# usage: file_env VAR [DEFAULT]
# ie: file_env 'XYZ_DB_PASSWORD' 'example'
# (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of
# "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature)
file_env() {
local var="$1"
local fileVar="${var}_FILE"
local def="${2:-}"
if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then
mysql_error "Both $var and $fileVar are set (but are exclusive)"
fi
local val="$def"
if [ "${!var:-}" ]; then
val="${!var}"
elif [ "${!fileVar:-}" ]; then
val="$(< "${!fileVar}")"
fi
export "$var"="$val"
unset "$fileVar"
}
apk add --update gettext
file_env 'GOTIFY_TOKEN'
file_env 'CLOUDFLARE_TOKEN'
envsubst < /config/ddclient.conf.tpl > /ddclient.conf

View File

@@ -33,9 +33,9 @@ services:
image: linuxserver/ddclient
environment:
GOTIFY_ADDRESS: http://gotify
GOTIFY_TOKEN_FILE: /run/secrets/gotify_token
FILE__GOTIFY_TOKEN: /run/secrets/gotify_token
CLOUDFLARE_DOMAIN: ${DDCLIENT_CLOUDFLARE_DOMAIN-test.dedicated.contact}
CLOUDFLARE_TOKEN_FILE: /run/secrets/cloudflare_token
FILE__CLOUDFLARE_TOKEN: /run/secrets/cloudflare_token
networks:
- gotify
volumes: