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 () = Env
.registerFunction ("mailman_web_node",
32 fn [] => SOME (EString Config
.Mailman
.node
, dl
)
35 val () = Env
.registerFunction ("mailman_web_node_to_node",
39 val () = Defaults
.registerDefault
41 (TList (TBase
"mailman_web_node", dl
), dl
),
42 (fn () => (EList
[(EString Config
.Mailman
.node
, dl
)], dl
)))
44 val files
= ref ([] : TextIO.outstream list
)
45 val write
= ref (fn _
: string => ())
47 val () = Env
.action_one
"mailmanWebHost"
48 ("hostname", Env
.string)
51 val {write
, writeDom
, close
} = Domain
.domainsFile
{node
= Config
.Mailman
.node
,
62 val () = Env
.actionV_one
"mailmanVhost"
66 val nodes
= Env
.env (Env
.list Env
.string) (env
, "MailmanWebNodes")
68 val ssl
= Env
.env Apache
.ssl (env
, "SSL")
69 val user
= Env
.env Env
.string (env
, "User")
71 val fullHost
= host ^
"." ^ Domain
.currentDomain ()
72 val vhostId
= fullHost ^
(if Option
.isSome ssl
then ".ssl" else "")
73 val confFile
= fullHost ^
(if Option
.isSome ssl
then ".vhost_ssl" else ".vhost")
77 val file
= Domain
.domainFile
{node
= node
,
79 fun print s
= TextIO.output (file
, s
)
81 val ld
= Apache
.logDir
{user
= user
, node
= node
, vhostId
= vhostId
}
86 print
"<VirtualHost ";
87 print (Domain
.nodeIp node
);
93 print
" ServerName $LISTDOMAIN\n";
94 print
" ServerAdmin ";
97 print
" SuexecUserGroup list list\n";
101 print
"/error.log\n";
104 print
"/access.log combined\n";
106 print
" RewriteEngine on\n";
108 print
" # Default to showing listinfo page\n";
109 print
" RewriteRule ^/$ http://";
111 print
"/listinfo/\n";
113 print
" Alias /images/mailman /usr/share/images/mailman\n";
114 print
" Alias /pipermail /var/lib/mailman/archives/public\n";
116 print
" DocumentRoot /usr/lib/cgi-bin/mailman\n";
117 print
" <Directory /usr/lib/cgi-bin/mailman>\n";
118 print
" AllowOverride None\n";
119 print
" Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch\n";
120 print
" ForceType cgi-script\n";
121 print
" Order allow,deny\n";
122 print
" Allow from all\n";
123 print
" </Directory>\n";
125 print
" <Directory /usr/share/doc/mailman>\n";
126 print
" Order allow,deny\n";
127 print
" Allow from all\n";
128 print
" </Directory>\n";
130 Apache
.doPre
{user
= user
, nodes
= nodes
, id
= vhostId
, hostname
= fullHost
};
132 print
"</VirtualHost>\n";
134 TextIO.closeOut file
;
140 val mailmanChanged
= ref
false
142 val () = Slave
.registerPreHandler (fn () => mailmanChanged
:= false)
144 val () = Slave
.registerFileHandler (fn fs
=>
146 val spl
= OS
.Path
.splitDirFile (#file fs
)
149 "mailman" => mailmanChanged
:= true
153 val () = Slave
.registerPostHandler (fn () =>
154 if !mailmanChanged
then
155 (Slave
.concatTo (fn s
=> s
= "mailman")
156 Config
.Mailman
.mapFile
;
157 Slave
.enumerateTo (fn s
=> s
= "mailman") ":"
158 Config
.Mailman
.handleDomains
;
159 Slave
.shellF ([Config
.Mailman
.reload
],
160 fn cl
=> "Error reloading Mailman with " ^ cl
))
164 val () = Domain
.registerDescriber (Domain
.considerAll
165 [Domain
.Filename
{filename
= "mailman",
166 heading
= "Mailman web host mapping",