From 0ce84a3b5d14da831011d0489b5a0f335c562cdc Mon Sep 17 00:00:00 2001 From: Ernesto Alfonso Date: Sat, 28 Oct 2023 23:21:34 -0400 Subject: [PATCH] docker/add-user.sh: Support getting email and password from env variables This patch extends docker/add-user.sh to support getting the email and password from environment variables. That way, docker/add-user.sh can be used in scripts. https://github.com/albertito/chasquid/pull/43 Amended-by: Alberto Bertogli Minor edits to the commit message. --- docker/add-user.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/docker/add-user.sh b/docker/add-user.sh index 8bf78be..b2aedf6 100755 --- a/docker/add-user.sh +++ b/docker/add-user.sh @@ -7,16 +7,19 @@ set -e -read -r -p "Email (full user@domain format): " EMAIL +if test -z "${EMAIL:-}"; then + read -r -p "Email (full user@domain format): " EMAIL +fi if ! echo "${EMAIL}" | grep -q @; then echo "Error: email should have '@'." exit 1 fi - -read -r -p "Password: " -s PASSWORD -echo +if test -z "${PASSWORD:-}"; then + read -r -p "Password: " -s PASSWORD + echo +fi DOMAIN=$(echo echo "${EMAIL}" | cut -d '@' -f 2)