Full regeneration
[hcoop/domtool2.git] / src / plugins / apache.sml
CommitLineData
8a7c40fa
AC
1(* HCoop Domtool (http://hcoop.sourceforge.net/)
2 * Copyright (c) 2006, Adam Chlipala
3 *
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.
8 *
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.
13 *
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.
17 *)
18
19(* Apache HTTPD handling *)
20
21structure Apache :> APACHE = struct
22
23open Ast
24
60695e99
AC
25val _ = Env.type_one "web_node"
26 Env.string
27 (fn node =>
28 List.exists (fn x => x = node) Config.Apache.webNodes_all
be1bea4c 29 orelse (Domain.hasPriv "www"
60695e99
AC
30 andalso List.exists (fn x => x = node) Config.Apache.webNodes_admin))
31
ce01b51a
AC
32val _ = Env.registerFunction ("web_node_to_node",
33 fn [e] => SOME e
34 | _ => NONE)
35
f8dfbbcc
AC
36val _ = Env.type_one "proxy_port"
37 Env.int
e95a129e
AC
38 (fn n => n > 1024)
39
40val _ = Env.type_one "proxy_target"
41 Env.string
42 (fn s =>
43 let
44 fun default () = List.exists (fn s' => s = s') Config.Apache.proxyTargets
45 in
46 case String.fields (fn ch => ch = #":") s of
47 ["http", "//localhost", rest] =>
48 (case String.fields (fn ch => ch = #"/") rest of
49 port :: _ =>
50 (case Int.fromString port of
51 NONE => default ()
52 | SOME n => n > 1024 orelse default ())
53 | _ => default ())
54 | _ => default ()
55 end)
f8dfbbcc
AC
56
57val _ = Env.type_one "rewrite_arg"
58 Env.string
59 (CharVector.all Char.isAlphaNum)
60
2882ee37
AC
61fun validLocation s =
62 size s > 0 andalso size s < 1000 andalso CharVector.all
63 (fn ch => Char.isAlphaNum ch
64 orelse ch = #"-"
65 orelse ch = #"_"
66 orelse ch = #"."
67 orelse ch = #"/") s
68
69val _ = Env.type_one "location"
70 Env.string
71 validLocation
72
8a7c40fa
AC
73val dl = ErrorMsg.dummyLoc
74
aa56e112 75val _ = Defaults.registerDefault ("WebNodes",
60695e99
AC
76 (TList (TBase "web_node", dl), dl),
77 (fn () => (EList (map (fn s => (EString s, dl)) Config.Apache.webNodes_default), dl)))
8a7c40fa 78
aa56e112
AC
79val _ = Defaults.registerDefault ("SSL",
80 (TBase "bool", dl),
81 (fn () => (EVar "false", dl)))
8a7c40fa 82
aa56e112
AC
83val _ = Defaults.registerDefault ("User",
84 (TBase "your_user", dl),
85 (fn () => (EString (Domain.getUser ()), dl)))
8a7c40fa 86
aa56e112
AC
87val _ = Defaults.registerDefault ("Group",
88 (TBase "your_group", dl),
89 (fn () => (EString (Domain.getUser ()), dl)))
8a7c40fa 90
aa56e112
AC
91val _ = Defaults.registerDefault ("DocumentRoot",
92 (TBase "your_path", dl),
de7fde3d 93 (fn () => (EString (Config.homeBase ^ "/" ^ Domain.getUser () ^ "/" ^ Config.Apache.public_html), dl)))
8a7c40fa 94
aa56e112
AC
95val _ = Defaults.registerDefault ("ServerAdmin",
96 (TBase "email", dl),
97 (fn () => (EString (Domain.getUser () ^ "@" ^ Config.defaultDomain), dl)))
8a7c40fa 98
f8dfbbcc
AC
99
100val redirect_code = fn (EVar "temp", _) => SOME "temp"
101 | (EVar "permanent", _) => SOME "permanent"
102 | (EVar "seeother", _) => SOME "seeother"
103 | (EVar "redir300", _) => SOME "300"
104 | (EVar "redir301", _) => SOME "301"
105 | (EVar "redir302", _) => SOME "302"
106 | (EVar "redir303", _) => SOME "303"
107 | (EVar "redir304", _) => SOME "304"
108 | (EVar "redir305", _) => SOME "305"
109 | (EVar "redir307", _) => SOME "307"
110 | _ => NONE
111
112val flag = fn (EVar "redirect", _) => SOME "R"
113 | (EVar "forbidden", _) => SOME "F"
114 | (EVar "gone", _) => SOME "G"
115 | (EVar "last", _) => SOME "L"
116 | (EVar "chain", _) => SOME "C"
117 | (EVar "nosubreq", _) => SOME "NS"
118 | (EVar "nocase", _) => SOME "NC"
119 | (EVar "qsappend", _) => SOME "QSA"
120 | (EVar "noescape", _) => SOME "NE"
121 | (EVar "passthrough", _) => SOME "PT"
122 | (EApp ((EVar "mimeType", _), e), _) =>
123 Option.map (fn s => "T=" ^ s) (Env.string e)
124 | (EApp ((EVar "redirectWith", _), e), _) =>
125 Option.map (fn s => "R=" ^ s) (redirect_code e)
126 | (EApp ((EVar "skip", _), e), _) =>
127 Option.map (fn n => "S=" ^ Int.toString n) (Env.int e)
128 | (EApp ((EApp ((EVar "env", _), e1), _), e2), _) =>
129 (case Env.string e1 of
130 NONE => NONE
131 | SOME s1 => Option.map (fn s2 => "E=" ^ s1 ^ ":" ^ s2)
132 (Env.string e2))
133
134 | _ => NONE
135
e95a129e
AC
136val cond_flag = fn (EVar "cond_nocase", _) => SOME "NC"
137 | (EVar "ornext", _) => SOME "OR"
138 | _ => NONE
139
d441e69f
AC
140val apache_option = fn (EVar "execCGI", _) => SOME "ExecCGI"
141 | (EVar "includesNOEXEC", _) => SOME "IncludesNOEXEC"
142 | (EVar "indexes", _) => SOME "Indexes"
143 | _ => NONE
144
9d7fa346
AC
145val autoindex_width = fn (EVar "autofit", _) => SOME "*"
146 | (EApp ((EVar "characters", _), n), _) =>
147 Option.map Int.toString (Env.int n)
148 | _ => NONE
149
150val autoindex_option = fn (EApp ((EVar "descriptionWidth", _), w), _) =>
151 Option.map (fn w => ("DescriptionWidth", SOME w))
152 (autoindex_width w)
153 | (EVar "fancyIndexing", _) => SOME ("FancyIndexing", NONE)
154 | (EVar "foldersFirst", _) => SOME ("FoldersFirst", NONE)
155 | (EVar "htmlTable", _) => SOME ("HTMLTable", NONE)
156 | (EVar "iconsAreLinks", _) => SOME ("IconsAreLinks", NONE)
157 | (EApp ((EVar "iconHeight", _), n), _) =>
158 Option.map (fn w => ("IconHeight", SOME (Int.toString w)))
159 (Env.int n)
160 | (EApp ((EVar "iconWidth", _), n), _) =>
161 Option.map (fn w => ("IconWidth", SOME (Int.toString w)))
162 (Env.int n)
163 | (EVar "ignoreCase", _) => SOME ("IgnoreCase", NONE)
164 | (EVar "ignoreClient", _) => SOME ("IgnoreClient", NONE)
165 | (EApp ((EVar "nameWidth", _), w), _) =>
166 Option.map (fn w => ("NameWidth", SOME w))
167 (autoindex_width w)
168 | (EVar "scanHtmlTitles", _) => SOME ("ScanHTMLTitles", NONE)
169 | (EVar "suppressColumnSorting", _) => SOME ("SuppressColumnSorting", NONE)
170 | (EVar "suppressDescription", _) => SOME ("SuppressDescription", NONE)
171 | (EVar "suppressHtmlPreamble", _) => SOME ("SuppressHTMLPreamble", NONE)
172 | (EVar "suppressIcon", _) => SOME ("SuppressIcon", NONE)
173 | (EVar "suppressLastModified", _) => SOME ("SuppressLastModified", NONE)
174 | (EVar "suppressRules", _) => SOME ("SuppressRules", NONE)
175 | (EVar "suppressSize", _) => SOME ("SuppressSize", NONE)
176 | (EVar "trackModified", _) => SOME ("TrackModified", NONE)
177 | (EVar "versionSort", _) => SOME ("VersionSort", NONE)
178 | (EVar "xhtml", _) => SOME ("XHTML", NONE)
179
180 | _ => NONE
f8dfbbcc 181
8a7c40fa 182val vhostsChanged = ref false
8e965b2d 183val logDeleted = ref false
8a7c40fa
AC
184
185val () = Slave.registerPreHandler
8e965b2d
AC
186 (fn () => (vhostsChanged := false;
187 logDeleted := false))
8a7c40fa 188
7db53a0b
AC
189fun findVhostUser fname =
190 let
191 val inf = TextIO.openIn fname
192
193 fun loop () =
194 case TextIO.inputLine inf of
195 NONE => NONE
196 | SOME line =>
197 case String.tokens Char.isSpace line of
198 ["SuexecUserGroup", user, _] => SOME user
199 | _ => loop ()
200 in
201 loop ()
202 before TextIO.closeIn inf
203 end
204
8a7c40fa 205val () = Slave.registerFileHandler (fn fs =>
7a2b27f0
AC
206 let
207 val spl = OS.Path.splitDirFile (#file fs)
208 in
209 if String.isSuffix ".vhost" (#file spl)
210 orelse String.isSuffix ".vhost_ssl" (#file spl) then
211 case findVhostUser (#file fs) of
212 NONE => print ("Can't find user in " ^ #file fs ^ "! Taking no action.\n")
213 | SOME user =>
214 let
215 val realVhostFile = OS.Path.joinDirFile
216 {dir = Config.Apache.confDir,
217 file = #file spl}
218
219 val realLogDir = OS.Path.joinDirFile
220 {dir = Config.homeBase,
221 file = user}
222 val realLogDir = OS.Path.joinDirFile
223 {dir = realLogDir,
224 file = "apache"}
225 val realLogDir = OS.Path.joinDirFile
226 {dir = realLogDir,
227 file = "log"}
228 val realLogDir = OS.Path.joinDirFile
229 {dir = realLogDir,
230 file = Slave.hostname ()}
231 val {base, ...} = OS.Path.splitBaseExt (#file spl)
232 val realLogDir = OS.Path.joinDirFile
233 {dir = realLogDir,
234 file = base}
235 in
236 vhostsChanged := true;
237 case #action fs of
238 Slave.Delete =>
8e965b2d
AC
239 (if !logDeleted then
240 ()
241 else
242 (ignore (OS.Process.system Config.Apache.down);
243 logDeleted := true);
244 ignore (OS.Process.system (Config.rm
7a2b27f0
AC
245 ^ " -rf "
246 ^ realVhostFile));
7db53a0b
AC
247 ignore (OS.Process.system (Config.rm
248 ^ " -rf "
7a2b27f0
AC
249 ^ realLogDir)))
250 | Slave.Add =>
251 (ignore (OS.Process.system (Config.cp
252 ^ " "
253 ^ #file fs
254 ^ " "
255 ^ realVhostFile));
c189cbe9
AC
256 if Posix.FileSys.access (realLogDir, []) then
257 ()
258 else
259 OS.FileSys.mkDir realLogDir)
7a2b27f0
AC
260
261 | _ =>
262 ignore (OS.Process.system (Config.cp
263 ^ " "
264 ^ #file fs
265 ^ " "
266 ^ realVhostFile))
267 end
268 else
269 ()
270 end)
8a7c40fa
AC
271
272val () = Slave.registerPostHandler
273 (fn () =>
274 (if !vhostsChanged then
8e965b2d 275 Slave.shellF ([if !logDeleted then Config.Apache.undown else Config.Apache.reload],
8a7c40fa
AC
276 fn cl => "Error reloading Apache with " ^ cl)
277 else
278 ()))
279
7a2b27f0
AC
280val vhostFiles : (string * TextIO.outstream) list ref = ref []
281fun write' s = app (fn (node, file) => TextIO.output (file, s node)) (!vhostFiles)
282fun write s = app (fn (_, file) => TextIO.output (file, s)) (!vhostFiles)
8a7c40fa 283
f8dfbbcc 284val rewriteEnabled = ref false
ce01b51a 285val localRewriteEnabled = ref false
c98b57cf
AC
286val currentVhost = ref ""
287val currentVhostId = ref ""
f8dfbbcc 288
7a2b27f0 289val pre = ref (fn _ : {user : string, nodes : string list, id : string, hostname : string} => ())
7f75d838
AC
290fun registerPre f =
291 let
292 val old = !pre
293 in
294 pre := (fn x => (old x; f x))
295 end
296
297val post = ref (fn () => ())
298fun registerPost f =
299 let
300 val old = !post
301 in
302 post := (fn () => (old (); f ()))
303 end
304
305val aliaser = ref (fn _ : string => ())
306fun registerAliaser f =
307 let
308 val old = !aliaser
309 in
310 aliaser := (fn x => (old x; f x))
311 end
312
8a7c40fa
AC
313val () = Env.containerV_one "vhost"
314 ("host", Env.string)
315 (fn (env, host) =>
316 let
317 val nodes = Env.env (Env.list Env.string) (env, "WebNodes")
318
319 val ssl = Env.env Env.bool (env, "SSL")
320 val user = Env.env Env.string (env, "User")
321 val group = Env.env Env.string (env, "Group")
322 val docroot = Env.env Env.string (env, "DocumentRoot")
323 val sadmin = Env.env Env.string (env, "ServerAdmin")
324
325 val fullHost = host ^ "." ^ Domain.currentDomain ()
c98b57cf 326 val vhostId = fullHost ^ (if ssl then ".ssl" else "")
8a7c40fa
AC
327 val confFile = fullHost ^ (if ssl then ".vhost_ssl" else ".vhost")
328 in
c98b57cf
AC
329 currentVhost := fullHost;
330 currentVhostId := vhostId;
331
f8dfbbcc 332 rewriteEnabled := false;
ce01b51a 333 localRewriteEnabled := false;
8a7c40fa
AC
334 vhostFiles := map (fn node =>
335 let
336 val file = Domain.domainFile {node = node,
337 name = confFile}
338 in
339 TextIO.output (file, "<VirtualHost ");
340 TextIO.output (file, Domain.nodeIp node);
341 TextIO.output (file, ":");
342 TextIO.output (file, if ssl then
343 "443"
344 else
345 "80");
346 TextIO.output (file, ">\n");
7a2b27f0
AC
347 TextIO.output (file, "\tErrorLog ");
348 TextIO.output (file, Config.homeBase);
349 TextIO.output (file, "/");
350 TextIO.output (file, user);
351 TextIO.output (file, "/apache/log/");
352 TextIO.output (file, node);
353 TextIO.output (file, "/");
354 TextIO.output (file, vhostId);
355 TextIO.output (file, "/error.log\n\tCustomLog ");
356 TextIO.output (file, Config.homeBase);
357 TextIO.output (file, "/");
358 TextIO.output (file, user);
359 TextIO.output (file, "/apache/log/");
360 TextIO.output (file, node);
361 TextIO.output (file, "/");
362 TextIO.output (file, vhostId);
363 TextIO.output (file, "/access.log combined\n");
364 (Config.homeBase ^ "/" ^ user ^ "/apache/log/"
365 ^ node ^ "/" ^ vhostId, file)
8a7c40fa
AC
366 end)
367 nodes;
edd38024
AC
368 write "\tServerName ";
369 write fullHost;
370 write "\n\tSuexecUserGroup ";
8a7c40fa
AC
371 write user;
372 write " ";
373 write group;
374 write "\n\tDocumentRoot ";
375 write docroot;
376 write "\n\tServerAdmin ";
377 write sadmin;
7a2b27f0
AC
378 write "\n";
379 !pre {user = user, nodes = nodes, id = vhostId, hostname = fullHost}
8a7c40fa 380 end,
7f75d838
AC
381 fn () => (!post ();
382 write "</VirtualHost>\n";
7a2b27f0 383 app (TextIO.closeOut o #2) (!vhostFiles)))
8a7c40fa 384
ce01b51a
AC
385val inLocal = ref false
386
2882ee37
AC
387val () = Env.container_one "location"
388 ("prefix", Env.string)
389 (fn prefix =>
390 (write "\t<Location ";
391 write prefix;
ce01b51a
AC
392 write ">\n";
393 inLocal := true),
394 fn () => (write "\t</Location>\n";
395 inLocal := false;
396 localRewriteEnabled := false))
2882ee37
AC
397
398val () = Env.container_one "directory"
399 ("directory", Env.string)
400 (fn directory =>
401 (write "\t<Directory ";
402 write directory;
ce01b51a
AC
403 write ">\n";
404 inLocal := true),
405 fn () => (write "\t</Directory>\n";
406 inLocal := false;
407 localRewriteEnabled := false))
2882ee37 408
f8dfbbcc 409fun checkRewrite () =
ce01b51a
AC
410 if !inLocal then
411 if !rewriteEnabled orelse !localRewriteEnabled then
412 ()
413 else
414 (write "\tRewriteEngine on\n";
415 localRewriteEnabled := true)
416 else if !rewriteEnabled then
f8dfbbcc
AC
417 ()
418 else
419 (write "\tRewriteEngine on\n";
420 rewriteEnabled := true)
421
422val () = Env.action_three "localProxyRewrite"
423 ("from", Env.string, "to", Env.string, "port", Env.int)
424 (fn (from, to, port) =>
425 (checkRewrite ();
426 write "\tRewriteRule\t";
427 write from;
428 write "\thttp://localhost:";
429 write (Int.toString port);
430 write "/";
431 write to;
432 write " [P]\n"))
433
e95a129e
AC
434val () = Env.action_two "proxyPass"
435 ("from", Env.string, "to", Env.string)
436 (fn (from, to) =>
437 (write "\tProxyPass\t";
438 write from;
439 write "\t";
440 write to;
441 write "\n"))
442
443val () = Env.action_two "proxyPassReverse"
444 ("from", Env.string, "to", Env.string)
445 (fn (from, to) =>
446 (write "\tProxyPassReverse\t";
447 write from;
448 write "\t";
449 write to;
450 write "\n"))
f8dfbbcc
AC
451
452val () = Env.action_three "rewriteRule"
453 ("from", Env.string, "to", Env.string, "flags", Env.list flag)
454 (fn (from, to, flags) =>
455 (checkRewrite ();
456 write "\tRewriteRule\t";
457 write from;
458 write "\t";
459 write to;
460 case flags of
461 [] => ()
462 | flag::rest => (write " [";
463 write flag;
464 app (fn flag => (write ",";
465 write flag)) rest;
466 write "]");
467 write "\n"))
468
e95a129e
AC
469val () = Env.action_three "rewriteCond"
470 ("test", Env.string, "pattern", Env.string, "flags", Env.list cond_flag)
471 (fn (from, to, flags) =>
472 (checkRewrite ();
473 write "\tRewriteCond\t";
474 write from;
475 write "\t";
476 write to;
477 case flags of
478 [] => ()
479 | flag::rest => (write " [";
480 write flag;
481 app (fn flag => (write ",";
482 write flag)) rest;
483 write "]");
484 write "\n"))
485
c98b57cf
AC
486val () = Env.action_one "rewriteLogLevel"
487 ("level", Env.int)
488 (fn level =>
489 (checkRewrite ();
490 write "\tRewriteLog ";
7a2b27f0 491 write' (fn x => x);
c98b57cf
AC
492 write "/rewrite.log\n\tRewriteLogLevel ";
493 write (Int.toString level);
494 write "\n"))
495
d5754b53
AC
496val () = Env.action_two "alias"
497 ("from", Env.string, "to", Env.string)
498 (fn (from, to) =>
499 (write "\tAlias\t";
500 write from;
501 write " ";
502 write to;
503 write "\n"))
504
505val () = Env.action_two "scriptAlias"
506 ("from", Env.string, "to", Env.string)
507 (fn (from, to) =>
508 (write "\tScriptAlias\t";
509 write from;
510 write " ";
511 write to;
512 write "\n"))
513
514val () = Env.action_two "errorDocument"
515 ("code", Env.string, "handler", Env.string)
516 (fn (code, handler) =>
517 (write "\tErrorDocument\t";
518 write code;
519 write " ";
520 write handler;
521 write "\n"))
522
d441e69f
AC
523val () = Env.action_one "options"
524 ("options", Env.list apache_option)
525 (fn opts =>
526 case opts of
527 [] => ()
528 | _ => (write "\tOptions";
529 app (fn opt => (write " "; write opt)) opts;
530 write "\n"))
531
532val () = Env.action_one "set_options"
533 ("options", Env.list apache_option)
534 (fn opts =>
535 case opts of
536 [] => ()
537 | _ => (write "\tOptions";
538 app (fn opt => (write " +"; write opt)) opts;
539 write "\n"))
540
541val () = Env.action_one "unset_options"
542 ("options", Env.list apache_option)
543 (fn opts =>
544 case opts of
545 [] => ()
546 | _ => (write "\tOptions";
547 app (fn opt => (write " -"; write opt)) opts;
548 write "\n"))
d5754b53 549
edd38024
AC
550val () = Env.action_one "directoryIndex"
551 ("filenames", Env.list Env.string)
552 (fn opts =>
553 (write "\tDirectoryIndex";
554 app (fn opt => (write " "; write opt)) opts;
555 write "\n"))
556
557val () = Env.action_one "serverAlias"
558 ("host", Env.string)
559 (fn host =>
560 (write "\tServerAlias ";
561 write host;
7f75d838
AC
562 write "\n";
563 !aliaser host))
edd38024 564
2aeb9eec
AC
565val authType = fn (EVar "basic", _) => SOME "basic"
566 | (EVar "digest", _) => SOME "digest"
567 | _ => NONE
568
569val () = Env.action_one "authType"
570 ("type", authType)
571 (fn ty =>
572 (write "\tAuthType ";
573 write ty;
574 write "\n"))
575
576val () = Env.action_one "authName"
577 ("name", Env.string)
578 (fn name =>
579 (write "\tAuthName \"";
580 write name;
581 write "\"\n"))
582
583val () = Env.action_one "authUserFile"
584 ("file", Env.string)
585 (fn name =>
586 (write "\tAuthUserFile ";
587 write name;
588 write "\n"))
589
590val () = Env.action_none "requireValidUser"
591 (fn () => write "\tRequire valid-user\n")
592
593val () = Env.action_one "requireUser"
594 ("users", Env.list Env.string)
595 (fn names =>
596 case names of
597 [] => ()
598 | _ => (write "\tRequire user";
599 app (fn name => (write " "; write name)) names;
600 write "\n"))
601
602val () = Env.action_one "requireGroup"
603 ("groups", Env.list Env.string)
604 (fn names =>
605 case names of
606 [] => ()
607 | _ => (write "\tRequire group";
608 app (fn name => (write " "; write name)) names;
609 write "\n"))
610
611val () = Env.action_none "orderAllowDeny"
612 (fn () => write "\tOrder allow,deny\n")
613
614val () = Env.action_none "orderDenyAllow"
615 (fn () => write "\tOrder deny,allow\n")
616
617val () = Env.action_none "allowFromAll"
618 (fn () => write "\tAllow from all\n")
619
620val () = Env.action_one "allowFrom"
621 ("entries", Env.list Env.string)
622 (fn names =>
623 case names of
624 [] => ()
625 | _ => (write "\tAllow from";
626 app (fn name => (write " "; write name)) names;
627 write "\n"))
628
629val () = Env.action_none "denyFromAll"
630 (fn () => write "\tDeny from all\n")
631
632val () = Env.action_one "denyFrom"
633 ("entries", Env.list Env.string)
634 (fn names =>
635 case names of
636 [] => ()
637 | _ => (write "\tDeny from";
638 app (fn name => (write " "; write name)) names;
639 write "\n"))
640
641val () = Env.action_none "satisfyAll"
642 (fn () => write "\tSatisfy all\n")
643
644val () = Env.action_none "satisfyAny"
645 (fn () => write "\tSatisfy any\n")
646
7f012ffd
AC
647val () = Env.action_one "forceType"
648 ("type", Env.string)
649 (fn ty => (write "\tForceType ";
650 write ty;
651 write "\n"))
652
653val () = Env.action_none "forceTypeOff"
654 (fn () => write "\tForceType None\n")
655
656val () = Env.action_two "action"
657 ("what", Env.string, "how", Env.string)
658 (fn (what, how) => (write "\tAction ";
659 write what;
660 write " ";
661 write how;
662 write "\n"))
663
664val () = Env.action_one "addDefaultCharset"
665 ("charset", Env.string)
666 (fn ty => (write "\tAddDefaultCharset ";
667 write ty;
668 write "\n"))
669
64e85bae 670(*val () = Env.action_one "davSvn"
c8505e59
AC
671 ("path", Env.string)
672 (fn path => (write "\tDAV svn\n\tSVNPath ";
673 write path;
674 write "\n"))
675
676val () = Env.action_one "authzSvnAccessFile"
677 ("path", Env.string)
678 (fn path => (write "\tAuthzSVNAccessFile ";
679 write path;
64e85bae 680 write "\n"))*)
c8505e59 681
9d7fa346
AC
682val () = Env.action_two "addDescription"
683 ("description", Env.string, "patterns", Env.list Env.string)
684 (fn (desc, pats) =>
685 case pats of
686 [] => ()
687 | _ => (write "\tAddDescription \"";
688 write (String.toString desc);
689 write "\"";
690 app (fn pat => (write " "; write pat)) pats;
691 write "\n"))
692
693val () = Env.action_one "indexOptions"
694 ("options", Env.list autoindex_option)
695 (fn opts =>
696 case opts of
697 [] => ()
698 | _ => (write "\tIndexOptions";
699 app (fn (opt, arg) =>
700 (write " ";
701 write opt;
702 Option.app (fn arg =>
703 (write "="; write arg)) arg)) opts;
704 write "\n"))
705
706val () = Env.action_one "set_indexOptions"
707 ("options", Env.list autoindex_option)
708 (fn opts =>
709 case opts of
710 [] => ()
711 | _ => (write "\tIndexOptions";
712 app (fn (opt, arg) =>
713 (write " +";
714 write opt;
715 Option.app (fn arg =>
716 (write "="; write arg)) arg)) opts;
717 write "\n"))
718
719val () = Env.action_one "unset_indexOptions"
720 ("options", Env.list autoindex_option)
721 (fn opts =>
722 case opts of
723 [] => ()
724 | _ => (write "\tIndexOptions";
725 app (fn (opt, _) =>
726 (write " -";
727 write opt)) opts;
728 write "\n"))
729
730val () = Env.action_one "headerName"
731 ("name", Env.string)
732 (fn name => (write "\tHeaderName ";
733 write name;
734 write "\n"))
735
736val () = Env.action_one "readmeName"
737 ("name", Env.string)
738 (fn name => (write "\tReadmeName ";
739 write name;
740 write "\n"))
741
71420f8b
AC
742val () = Domain.registerResetLocal (fn () =>
743 ignore (OS.Process.system (Config.rm ^ " -rf /var/domtool/vhosts/*")))
744
8a7c40fa 745end