summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2020-10-10 22:20:16 +0200
committerJonas Smedegaard <dr@jones.dk>2020-10-10 22:20:16 +0200
commit6fd0fbfaf8c5d7e34080b9c3f25c1dc0df564696 (patch)
treed5a164a998ccd30ebbf4d1a44d8aec26b40fe89d
parent308a01512eb9f9484c3ed38e7e964f7c198a1055 (diff)
generalize overridable variables $REDPILL $REALM
-rwxr-xr-xpostfix/postfix.sh14
1 files 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