5 # Create the mailing-lists from the database
6 # Roland Mas <lolando@debian.org>
11 use File::Temp qw/ :mktemp /;
13 use vars qw/ $dbh $sys_lists_host $sys_users_host / ;
19 require ("/usr/lib/gforge/lib/include.pl") ; # Include all the predefined functions
20 require ("/etc/gforge/local.pl") ;
24 $dbh->{AutoCommit} = 0;
25 $dbh->{RaiseError} = 1;
27 my ($query, $sth, @array, @lines, $line) ;
29 $query = "SELECT mail_group_list.group_list_id,
30 mail_group_list.list_name,
32 mail_group_list.password,
33 mail_group_list.description
34 FROM mail_group_list, users
35 WHERE mail_group_list.status = 1
36 AND mail_group_list.list_admin = users.user_id" ; # Status = 1: list just created on the website
37 $sth = $dbh->prepare ($query) ;
39 while (my @myarray = $sth->fetchrow_array ()) {
40 push @lines, \@myarray ;
44 foreach $line (@lines) {
46 my ($group_list_id, $listname, $user_name, $password, $description) ;
49 ($group_list_id, $listname, $user_name, $password, $description)= @array ;
50 my $cmd = "/usr/sbin/newlist -q $listname $user_name\@$sys_users_host $password >/dev/null 2>&1" ;
51 #print "cmd = <$cmd>\n" ;
54 $query = "UPDATE mail_group_list SET status = 2 where group_list_id = group_list_id" ; # Status = 2: list created on Mailman
55 $sth = $dbh->prepare ($query) ;
59 $tmp = mktemp ("/tmp/XXXXXX") ;
60 $cmd = "/usr/lib/mailman/bin/config_list -o $tmp $listname" ;
61 #print "cmd = <$cmd>\n" ;
62 # Commented out on Matt Hope <dopey@debian.org> advice
63 # To be revised by Roland Mas
65 open CONFIG, ">>$tmp" ;
66 print CONFIG "description = \"$description\"\n" ;
67 print CONFIG "host_name = '$sys_lists_host'\n" ;
69 $cmd = "/usr/lib/mailman/bin/config_list -i $tmp $listname" ;
70 #print "cmd = <$cmd>\n" ;
74 $cmd= "/usr/lib/mailman/bin/withlist -l -r fix_url $listname -u $sys_lists_host" ;
75 #print "cmd = <$cmd>\n" ;
78 $query = "UPDATE mail_group_list SET status = 3 where group_list_id = group_list_id" ; # Status = 3: list configured on Mailman
79 $sth = $dbh->prepare ($query) ;
83 #debug "Committing." ;
87 # There should be a commit at the end of every block above.
88 # If there is not, then it might be symptomatic of a problem.
89 # For safety, we roll back.
94 warn "Transaction aborted because $@" ;
95 debug "Transaction aborted because $@" ;
97 debug "Please report this bug on the Debian bug-tracking system." ;
98 debug "Please include the previous messages as well to help debugging." ;
108 print STDERR "$v\n" ;