diff options
Diffstat (limited to 'amavis/mklists.sh')
-rwxr-xr-x | amavis/mklists.sh | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/amavis/mklists.sh b/amavis/mklists.sh new file mode 100755 index 0000000..7a5a370 --- /dev/null +++ b/amavis/mklists.sh @@ -0,0 +1,49 @@ +#!/bin/sh +# +# /etc/local-COMMON/amavis/mklists.sh +# Copyright 2007 Jonas Smedegaard <dr@jones.dk> +# +# $Id: mklists.sh,v 1.1 2007-09-25 12:22:10 jonas Exp $ +# +# Resolve own mail domains and MX backup domains + +set -e + +# Let's standardize sort +export LC_ALL=C + +realmsdir='/etc/local-REDPILL' +domainconfdir='/etc/local-ORG/amavis' +if ! [ -d "$realmsdir" ]; then + echo "WARNING: Realms directory \"$realmsdir\" does not exist." +fi +if ! [ -d "$domainconfdir" ]; then + echo "WARNING: Domain config directory \"$domainconfdir\" does not exist." +fi + +catfilefromownrealm() { + file="$1" + [ -d "$realmsdir" ] || exit 0 + + thisrealm="$(cat /etc/local-ORG/realm || dnsdomainname | tr '[a-z]' '[A-Z]')" + + cat "$realmsdir/$thisrealm/$file" +} + +catallfilesfromotherrealms() { + file="$1" + [ -d "$realmsdir" ] || exit 0 + [ -f "$realmsdir/realms" ] || exit 0 + + realms="$(cat "$realmsdir/realms" | sed 's/#.*//')" + thisrealm="$(cat /etc/local-ORG/realm || dnsdomainname | tr '[a-z]' '[A-Z]')" + + for realm in $realms; do + if [ "$thisrealm" != "$realm" ]; then + cat "$realmsdir/$realm/$file" + fi + done +} + +catfilefromownrealm maildomains | sort > "$domainconfdir/local_domains" +catallfilesfromotherrealms maildomains | sort > "$domainconfdir/nonlocal_domains" |