1 (* HCoop
Domtool (http
://hcoop
.sourceforge
.net
/)
2 * Copyright (c
) 2006, Adam Chlipala
4 * This program is free software
; you can redistribute it
and/or
5 * modify it under the terms
of the GNU General Public License
6 * as published by the Free Software Foundation
; either version
2
7 * of the License
, or (at your option
) any later version
.
9 * This program is distributed
in the hope that it will be useful
,
10 * but WITHOUT ANY WARRANTY
; without even the implied warranty
of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE
. See the
12 * GNU General Public License for more details
.
14 * You should have received a copy
of the GNU General Public License
15 * along
with this program
; if not
, write to the Free Software
16 * Foundation
, Inc
., 51 Franklin Street
, Fifth Floor
, Boston
, MA
02110-1301, USA
.
19 (* Mailman mailing list handling
*)
21 structure Mailman
:> MAILMAN
= struct
25 val () = Env
.type_one
"mailman_web_node"
27 (fn node
=> Apache
.webNode node
orelse node
= Config
.Mailman
.node
)
29 val dl
= ErrorMsg
.dummyLoc
31 val () = Defaults
.registerDefault
33 (TList (TBase
"mailman_web_node", dl
), dl
),
34 (fn () => (EList
[(EString Config
.Mailman
.node
, dl
)], dl
)))
36 val files
= ref ([] : TextIO.outstream list
)
37 val write
= ref (fn _
: string => ())
39 val () = Env
.action_one
"mailmanWebHost"
40 ("hostname", Env
.string)
43 val {write
, writeDom
, close
} = Domain
.domainsFile
{node
= Config
.Mailman
.node
,
54 val () = Env
.actionV_one
"mailmanVhost"
58 val nodes
= Env
.env (Env
.list Env
.string) (env
, "MailmanWebNodes")
60 val ssl
= Env
.env Apache
.ssl (env
, "SSL")
61 val user
= Env
.env Env
.string (env
, "User")
63 val fullHost
= host ^
"." ^ Domain
.currentDomain ()
64 val vhostId
= fullHost ^
(if Option
.isSome ssl
then ".ssl" else "")
65 val confFile
= fullHost ^
(if Option
.isSome ssl
then ".vhost_ssl" else ".vhost")
69 val file
= Domain
.domainFile
{node
= node
,
71 fun print s
= TextIO.output (file
, s
)
73 val ld
= Apache
.logDir
{user
= user
, node
= node
, vhostId
= vhostId
}
78 print
"<VirtualHost ";
79 print (Domain
.nodeIp node
);
85 print
" ServerName $LISTDOMAIN\n";
86 print
" ServerAdmin ";
89 print
" SuexecUserGroup list list\n";
96 print
"/access.log combined\n";
98 print
" RewriteEngine on\n";
100 print
" # Default to showing listinfo page\n";
101 print
" RewriteRule ^/$ http://";
103 print
"/listinfo/\n";
105 print
" Alias /images/mailman /usr/share/images/mailman\n";
106 print
" Alias /pipermail /var/lib/mailman/archives/public\n";
108 print
" DocumentRoot /usr/lib/cgi-bin/mailman\n";
109 print
" <Directory /usr/lib/cgi-bin/mailman>\n";
110 print
" AllowOverride None\n";
111 print
" Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch\n";
112 print
" ForceType cgi-script\n";
113 print
" Order allow,deny\n";
114 print
" Allow from all\n";
115 print
" </Directory>\n";
117 print
" <Directory /usr/share/doc/mailman>\n";
118 print
" Order allow,deny\n";
119 print
" Allow from all\n";
120 print
" </Directory>\n";
121 print
"</VirtualHost>\n";
127 val mailmanChanged
= ref
false
129 val () = Slave
.registerPreHandler (fn () => mailmanChanged
:= false)
131 val () = Slave
.registerFileHandler (fn fs
=>
133 val spl
= OS
.Path
.splitDirFile (#file fs
)
136 "mailman" => mailmanChanged
:= true
140 val () = Slave
.registerPostHandler (fn () =>
141 if !mailmanChanged
then
142 (Slave
.concatTo (fn s
=> s
= "mailman")
143 Config
.Mailman
.mapFile
;
144 Slave
.enumerateTo (fn s
=> s
= "mailman") ":"
145 Config
.Mailman
.handleDomains
;
146 Slave
.shellF ([Config
.Mailman
.reload
],
147 fn cl
=> "Error reloading Mailman with " ^ cl
))
151 val () = Domain
.registerDescriber (Domain
.considerAll
152 [Domain
.Filename
{filename
= "mailman",
153 heading
= "Mailman web host mapping",