From 53ca9f862aedd434307f87cd183e6c96af776170 Mon Sep 17 00:00:00 2001 From: Scott Koranda Date: Thu, 3 May 2018 10:08:51 -0500 Subject: [PATCH] More sophisticated and flexible creation of email config Added logic for a more sophisticated and flexible approach to the initial creation of the COmanange Registry email.php configuration file. --- .../docker-comanage-entrypoint | 38 +++++++++++++++++-- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/comanage-registry-internet2-tier/docker-comanage-entrypoint b/comanage-registry-internet2-tier/docker-comanage-entrypoint index 35a5725..b0cf49e 100755 --- a/comanage-registry-internet2-tier/docker-comanage-entrypoint +++ b/comanage-registry-internet2-tier/docker-comanage-entrypoint @@ -99,21 +99,53 @@ fi email_config="$COMANAGE_REGISTRY_DIR/local/Config/email.php" if [ ! -e "$email_config" ]; then + # If the deployer has injected an email for from then use it, + # otherwise set a default purely as a template that can edited + # easier later. + if [ -n "$COMANAGE_REGISTRY_EMAIL_FROM" ]; then + email_from="$COMANAGE_REGISTRY_EMAIL_FROM" + else + email_from="array('account@gmail.com' => 'Registry')" + fi + + # If the injected email from does not include a single quote (') + # then add them to make it a PHP string. + if [[ ! $email_from =~ .*"'".* ]]; then + email_from="'$email_from'" + fi + cat > "$email_config" < ${COMANAGE_REGISTRY_EMAIL_FROM:-array('account@gmail.com' => 'Registry')}, + 'from' => $email_from, 'transport' => '${COMANAGE_REGISTRY_EMAIL_TRANSPORT:-Smtp}', 'host' => '${COMANAGE_REGISTRY_EMAIL_HOST:-tls://smtp.gmail.com}', 'port' => ${COMANAGE_REGISTRY_EMAIL_PORT:-465}, - 'username' => '${COMANAGE_REGISTRY_EMAIL_ACCOUNT:-account@gmail.com}', - 'password' => '${COMANAGE_REGISTRY_EMAIL_ACCOUNT_PASSWORD:-password}' +EOF + + # If the deployer has injected a username then add it to the configuration. + if [ -n "$COMANAGE_REGISTRY_EMAIL_ACCOUNT" ]; then + cat >> "$email_config" < '$COMANAGE_REGISTRY_EMAIL_ACCOUNT', +EOF + fi + + # If the deployer has injected a password then add it to the configuration. + if [ -n "$COMANAGE_REGISTRY_EMAIL_ACCOUNT_PASSWORD" ]; then + cat >> "$email_config" < '$COMANAGE_REGISTRY_EMAIL_ACCOUNT_PASSWORD', +EOF + fi + + # Complete the PHP array. + cat >> "$email_config" <