Sync changes in current working tree
[clinton/scripts.git] / change-list-url
1 #!/bin/bash
2 #
3 # Change a mailing list's web page URL.
4 #
5 # This must be run as root.
6
7 MMDIR=/var/lib/mailman
8 BINDIR=$MMDIR/bin
9 LISTDIR=$MMDIR/lists
10 WORKDIR=/tmp/mmdir
11
12 function usage() {
13 echo "Usage: change-list-url LIST WEBURL [BASEURL]"
14 }
15
16 # Argument check
17 if test -z "$2"; then
18 echo "Not enough arguments"
19 usage
20 exit 1
21 elif test -n "$4"; then
22 echo "Too many arguments"
23 usage
24 exit 1
25 else
26 LIST=$1
27 WEBURL=$2
28 BASEURL=$3
29 fi
30
31 # Check list existence
32 if test ! -d $LISTDIR/$LIST; then
33 echo "List $LIST does not exist"
34 exit 1
35 fi
36
37 # Make working directory
38 if test ! -d $WORKDIR; then
39 mkdir -p $WORKDIR
40 chown list:list $WORKDIR
41 chmod ug=rwX,o= $WORKDIR
42 fi
43
44 # Change URL
45 echo "web_page_url = '$WEBURL'" > $WORKDIR/$LIST.cfg
46 if test -n "$BASEURL"; then
47 echo "host_name = '$BASEURL'" >> $WORKDIR/$LIST.cfg
48 fi
49 chown list:list $WORKDIR/$LIST.cfg
50 sudo -u list $BINDIR/config_list -i $WORKDIR/$LIST.cfg $LIST
51 rm -f $WORKDIR/$LIST.cfg
52
53 echo
54 echo "Changed web page URL for $LIST to $WEBURL"
55 if test -n "$BASEURL"; then
56 echo " and also base URL to $BASEURL"
57 fi
58
59 echo "Updating mailman definitions for Exim ..."
60 /afs/hcoop.net/common/etc/scripts/mailman-update-exim-db