summaryrefslogtreecommitdiff
path: root/amavis
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2010-11-08 18:09:10 +0100
committerJonas Smedegaard <dr@jones.dk>2010-11-08 18:09:10 +0100
commiteb6d2f48024b69bda08bb765d8f5cd2618c187b9 (patch)
treea29930d5f5dfcac2c05f014893a12b55a1947811 /amavis
parenta2470847c7b923b344939d2cd02a2313158e09ce (diff)
Make directories overridable by environment variables.
Diffstat (limited to 'amavis')
-rwxr-xr-xamavis/mklists.sh29
1 files changed, 17 insertions, 12 deletions
diff --git a/amavis/mklists.sh b/amavis/mklists.sh
index f7db451..7a7b4fd 100755
--- a/amavis/mklists.sh
+++ b/amavis/mklists.sh
@@ -12,8 +12,13 @@ set -e
# Let's standardize sort
export LC_ALL=C
-realmsdir='/etc/local-REDPILL'
-domainconfdir='/etc/local-ORG/amavis'
+basedir=${basedir:-/etc}
+REDPILL=${REDPILL:-REDPILL}
+ORG=${ORG:-ORG}
+realmsdir=${realmsdir:-$basedir/local-$REDPILL}
+domaindir=${domaindir:-$basedir/local-$ORG}
+domainconfdir=${domainconfdir:-$domaindir/amavis}
+localdir=${localdir:-$basedir/local}
if ! [ -d "$realmsdir" ]; then
echo "WARNING: Realms directory \"$realmsdir\" does not exist."
fi
@@ -25,15 +30,15 @@ catfilefromownrealm() {
file="$1"
[ -d "$realmsdir" ] || exit 0
- thisrealm="$(cat /etc/local-ORG/realm || dnsdomainname | tr '[a-z]' '[A-Z]')"
+ thisrealm="$(cat "$domaindir/realm" || dnsdomainname | tr '[a-z]' '[A-Z]')"
- if [ -r /etc/local/"$file"_exceptions ]; then
- grep -vFf /etc/local/"$file"_exceptions "$realmsdir/$thisrealm/$file"
+ if [ -r "$localdir/${file}_exceptions" ]; then
+ grep -vFf "$localdir/${file}_exceptions" "$realmsdir/$thisrealm/$file"
else
cat "$realmsdir/$thisrealm/$file"
fi
- if [ -r /etc/local/"$file"_additions ]; then
- cat /etc/local/"$file"_additions
+ if [ -r "$localdir/${file}_additions" ]; then
+ cat "$localdir/${file}_additions"
fi
}
@@ -43,19 +48,19 @@ 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 "$domaindir/realm" || dnsdomainname | tr '[a-z]' '[A-Z]')"
for realm in $realms; do
if [ "$thisrealm" != "$realm" ]; then
- if [ -r /etc/local/$"file"_additions ]; then
- grep -vFf /etc/local/"$file"_additions "$realmsdir/$realm/$file"
+ if [ -r "$localdir/${file}_additions" ]; then
+ grep -vFf "$localdir/${file}_additions" "$realmsdir/$realm/$file"
else
cat "$realmsdir/$realm/$file"
fi
fi
done
- if [ -r /etc/local/"$file"_exceptions ]; then
- cat /etc/local/"$file"_exceptions
+ if [ -r "$localdir/${file}_exceptions" ]; then
+ cat "$localdir/${file}_exceptions"
fi
}