create-user: create ~/.domtool link as admin and chown
[hcoop/scripts.git] / listnew
1 #!/bin/bash -e
2 #
3 # Make a new mailing list. Run as root on deleuze.
4 #
5 # Usage: listnew LISTNAME LISTDOMAIN LISTURL USER INITIAL_PASSWORD
6
7 BIN=/var/lib/mailman/bin
8
9 function usage() {
10 echo "Usage: listnew list_name domain list_url user initial_password"
11 }
12
13 if test -n "$6"; then
14 echo "Too many arguments"
15 usage
16 exit 1
17 elif test -z "$5"; then
18 echo "Not enough arguments"
19 usage
20 exit 1
21 elif test "$UID" != "0"; then
22 echo "This program must be run as root"
23 usage
24 exit 1
25 else
26 LIST_NAME=$1
27 LIST_DOMAIN=$2
28 LIST_URL=$3
29 LIST_USER=$4
30 LIST_PASS=$5
31 fi
32
33 # If DOMAIN is hcoop.net, force it to be lists.hcoop.net.
34 if test "$LIST_DOMAIN" = "hcoop.net"; then
35 LIST_DOMAIN=lists.hcoop.net
36 fi
37
38 sudo -u list $BIN/newlist \
39 $LIST_NAME@$LIST_DOMAIN $LIST_USER@hcoop.net $LIST_PASS </dev/null
40
41 # By default, use our list admin website for the public interface.
42 # This can be changed after the user has set up their mailMan
43 # directive. We do this because the default is
44 # http://lists.hcoop.net, without SSL, which makes list admin not work
45 # at all.
46 /afs/hcoop.net/common/etc/scripts/change-list-url $LIST_NAME $LIST_URL
47
48 echo "Sucessfully created list $LIST_NAME"