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