1f0c0e80 |
1 | #!/bin/bash |
2 | # |
940e23ca |
3 | # mailman-update-exim-db: Make an associated list mapping list names |
4 | # and the domain that they are associated with. |
1f0c0e80 |
5 | # |
6 | # This table is then used by Exim to verify that the list name and |
7 | # domain are correct. |
8 | # |
940e23ca |
9 | # This script is meant to be called from a cron job, and run as root. |
1f0c0e80 |
10 | |
11 | MMDIR=/var/lib/mailman |
12 | LISTDIR=$MMDIR/lists |
13 | BINDIR=$MMDIR/bin |
14 | TABLE=/etc/exim4/mailmandb |
de85b0a6 |
15 | TABLE_EXT=/etc/exim4/mailmandb-ext |
1f0c0e80 |
16 | |
17 | # Use return as separator, never space or tab. |
18 | IFS=" |
19 | " |
20 | |
21 | # Create table with the right permissions or clear it. |
22 | if test ! -f $TABLE; then |
23 | touch $TABLE |
24 | chown root:mail $TABLE |
25 | chmod u=rw,g=r,o= $TABLE |
26 | else |
27 | : > $TABLE |
28 | fi |
29 | |
30 | # Iterate through available lists |
31 | for i in $(find $LISTDIR -mindepth 1 -maxdepth 1 -type d -print); do |
32 | LIST=$(basename $i) |
5912f6af |
33 | DOMAIN=$(sudo -u list $BINDIR/config_list -o - $LIST | \ |
1f0c0e80 |
34 | grep -E "^host_name = '.+'" 2>/dev/null | \ |
35 | sed -r -e "s/host_name = '(.+)'/\\1/") |
36 | if test -n "$LIST" && test -n "$DOMAIN"; then |
de85b0a6 |
37 | echo "$LIST@$DOMAIN: true" >> $TABLE |
1f0c0e80 |
38 | fi |
39 | done |
de85b0a6 |
40 | |
41 | # Add extras file, for aliases of domains and whatnot |
42 | if test -f $TABLE_EXT; then |
43 | cat $TABLE_EXT >> $TABLE |
44 | fi |