Add function to load secret/password from file for security (#25)

New feature: Load SMTP password from file to avoid using env variables.
This commit is contained in:
dabde
2020-06-19 23:52:21 +02:00
committed by Juan Luis Baptiste
parent 1e0e3be0b6
commit 39ac3ab672
3 changed files with 12 additions and 2 deletions

3
run.sh
View File

@@ -13,6 +13,9 @@ function add_config_value() {
postconf -e "${key} = ${value}"
}
# Read password from file to avoid unsecure env variables
if [ -n "${SMTP_PASSWORD_FILE}" ]; then [ -f "${SMTP_PASSWORD_FILE}" ] && read SMTP_PASSWORD < ${SMTP_PASSWORD_FILE} || echo "SMTP_PASSWORD_FILE defined, but file not existing, skipping."; fi
[ -z "${SMTP_SERVER}" ] && echo "SMTP_SERVER is not set" && exit 1
[ -z "${SMTP_USERNAME}" ] && echo "SMTP_USERNAME is not set" && exit 1
[ -z "${SMTP_PASSWORD}" ] && echo "SMTP_PASSWORD is not set" && exit 1