From: mwolson_admin Date: Wed, 14 Nov 2007 22:46:33 +0000 (-0500) Subject: mailman-update-exim-db: New script that builds a Mailman lookup table for Exim X-Git-Url: http://git.hcoop.net/clinton/scripts.git/commitdiff_plain/1f0c0e80eb81b82a0b67a51dc9759c2c08691e07?hp=2b00ea8c307cc134543f19bae3a1a1910bdda87c mailman-update-exim-db: New script that builds a Mailman lookup table for Exim --- diff --git a/mailman-update-exim-db b/mailman-update-exim-db new file mode 100755 index 0000000..ed84d21 --- /dev/null +++ b/mailman-update-exim-db @@ -0,0 +1,38 @@ +#!/bin/bash +# +# mailman-update-table: Make an associated list mapping list names and +# the domain that they are associated with. +# +# This table is then used by Exim to verify that the list name and +# domain are correct. +# +# This script is meant to be called from a cron job. + +MMDIR=/var/lib/mailman +LISTDIR=$MMDIR/lists +BINDIR=$MMDIR/bin +TABLE=/etc/exim4/mailmandb + +# Use return as separator, never space or tab. +IFS=" +" + +# Create table with the right permissions or clear it. +if test ! -f $TABLE; then + touch $TABLE + chown root:mail $TABLE + chmod u=rw,g=r,o= $TABLE +else + : > $TABLE +fi + +# Iterate through available lists +for i in $(find $LISTDIR -mindepth 1 -maxdepth 1 -type d -print); do + LIST=$(basename $i) + DOMAIN=$(su list -c "$BINDIR/config_list -o - $LIST" | \ + grep -E "^host_name = '.+'" 2>/dev/null | \ + sed -r -e "s/host_name = '(.+)'/\\1/") + if test -n "$LIST" && test -n "$DOMAIN"; then + echo "$LIST: $DOMAIN" >> $TABLE + fi +done