Skip to content

Commit

Permalink
Add the ability to use secrets for credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorentPoinsaut committed Mar 25, 2022
1 parent d957052 commit 4cbdb77
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,35 @@
#!/usr/bin/env bash
set -e

# 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
echo >&2 "error: both ${varName} and ${fileVarName} are set (but are exclusive)"
exit 1
fi
local val="$def"
if [ "${!var:-}" ]; then
val="${!var}"
elif [ "${!fileVar:-}" ]; then
val="$(< "${!fileVar}")"
fi
export "$var"="$val"
unset "$fileVar"
}

file_env GMAIL_USER
file_env GMAIL_PASSWORD
file_env SES_USER
file_env SES_PASSWORD
file_env SMARTHOST_USER
file_env SMARTHOST_PASSWORD

# Initialize localmacros as an empty file
echo -n "" > /etc/exim4/exim4.conf.localmacros

Expand Down

0 comments on commit 4cbdb77

Please sign in to comment.