From 6fd0fbfaf8c5d7e34080b9c3f25c1dc0df564696 Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Sat, 10 Oct 2020 22:20:16 +0200 Subject: generalize overridable variables $REDPILL $REALM --- postfix/postfix.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/postfix/postfix.sh b/postfix/postfix.sh index 5c2d5b8..5dc4606 100755 --- a/postfix/postfix.sh +++ b/postfix/postfix.sh @@ -29,12 +29,14 @@ exit1() { exit 1 } +REDPILL=${REDPILL:-REDPILL} +REALM=${REALM:-ORG} + TLS_CERT=${TLS_CERT:-/etc/ssl/certs/postfix.pem} TLS_KEY=${TLS_KEY:-/etc/ssl/private/postfix.pem} -realmsdir='/etc/local-REDPILL' -configdirs='/etc/local /etc/local-ORG /etc/local-REDPILL /etc/local-COMMON' -confdir='/etc/postfix' +realmsdir="/etc/local-$REDPILL" +confdir="/etc/postfix" if ! [ -d "$realmsdir" ]; then warn "Realms directory \"$realmsdir\" does not exist." fi @@ -104,7 +106,7 @@ catfilefromownrealm() { file="$1" [ -d "$realmsdir" ] || exit 0 - thisrealm="$(cat /etc/local-ORG/realm || dnsdomainname | tr '[a-z]' '[A-Z]')" + thisrealm="$(cat "/etc/local-$REALM/realm" || dnsdomainname | tr '[a-z]' '[A-Z]')" cat "$realmsdir/$thisrealm/$file" } @@ -116,7 +118,7 @@ catallfilesfromotherrealms() { [ -f "$realmsdir/realms" ] || exit 0 realms="$(cat "$realmsdir/realms" | sed 's/#.*//')" - thisrealm="$(cat /etc/local-ORG/realm || dnsdomainname | tr '[a-z]' '[A-Z]')" + thisrealm="$(cat "/etc/local-$REALM/realm" || dnsdomainname | tr '[a-z]' '[A-Z]')" for realm in $realms; do if [ "$thisrealm" != "$realm" ]; then @@ -130,7 +132,7 @@ catfirstfile() { file="$1" context="${2:-postfix}" configdir='' - for dir in $configdirs; do + for dir in /etc/local "/etc/local-$REALM" "/etc/local-$REDPILL" /etc/local-COMMON; do if [ -d "$dir/$context" ] && [ -f "$dir/$context/$file" ]; then configdir="$dir/$context" break -- cgit v1.2.3