Skip to content
This repository was archived by the owner on Apr 11, 2025. It is now read-only.

Commit a4895fe

Browse files
committed
Merge branch '10-add-the-ability-to-use-secrets-for-credentials' into 'master'
Resolve #10 "Add the ability to use secrets for credentials" See merge request ix.ai/smtp!11
2 parents d957052 + 332c393 commit a4895fe

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

entrypoint.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,36 @@
11
#!/usr/bin/env bash
22
set -e
33

4+
# usage: file_env VAR [DEFAULT]
5+
# ie: file_env 'XYZ_DB_PASSWORD' 'example'
6+
# (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of
7+
# "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature)
8+
file_env() {
9+
local var="$1"
10+
local fileVar="${var}_FILE"
11+
local varName="${!var@}"
12+
local def="${2:-}"
13+
if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then
14+
echo >&2 "error: both ${varName} and ${fileVar} are set (but are mutually exclusive)"
15+
exit 1
16+
fi
17+
local val="$def"
18+
if [ "${!var:-}" ]; then
19+
val="${!var}"
20+
elif [ "${!fileVar:-}" ]; then
21+
val="$(< "${!fileVar}")"
22+
fi
23+
export "$var"="$val"
24+
unset "$fileVar"
25+
}
26+
27+
file_env GMAIL_USER
28+
file_env GMAIL_PASSWORD
29+
file_env SES_USER
30+
file_env SES_PASSWORD
31+
file_env SMARTHOST_USER
32+
file_env SMARTHOST_PASSWORD
33+
434
# Initialize localmacros as an empty file
535
echo -n "" > /etc/exim4/exim4.conf.localmacros
636

0 commit comments

Comments
 (0)