(defun until-closed-helper (level)
(if
- (re-search-backward "\\_<\\(with\\|where\\|begin\\|end\\)\\_>"
+ (re-search-backward "\\_<\\(with\\|where\\|begin\\|end\\|let\\)\\_>"
nil t)
(cond
((string= (match-string 0) "end")
(back-to-indentation)
(multiple-value-bind (previous-keyword base-indent)
(save-excursion
- (if (re-search-backward "\\_<\\(with\\|where\\|begin\\|end\\)\\_>"
+ (if (re-search-backward "\\_<\\(with\\|where\\|begin\\|end\\|let\\|in\\)\\_>"
nil t)
(values (match-string 0) (current-indentation))
(values nil 0)))
'noindent)
((nth 4 state)
(domtool-calculate-comment-indent state))
- ((looking-at "\\_<\\(with\\|end\\)\\_>")
+ ((looking-at "\\_<\\(with\\|end\\|in\\)\\_>")
(until-closed))
((not previous-keyword)
base-indent)
{{A filesystem path that you're allowed to write to.
The set of permitted values is generated from a set of roots by closing it
under the subdirectory relation.}}
+extern val end_in_slash : your_path -> your_path;
+{{Add a slash at the end of a path, if there isn't one already.}}
extern type readable_path;
{{Like [your_path], but also includes some paths that everyone is allowed to
script <- Script;
alias htdocs "/usr/share/moin/htdocs";
- scriptAlias prefix script
+ scriptAlias prefix (end_in_slash script)
end;
{{Add a MoinMoin wiki to a vhost.}}
val moinMoin = \ host : (host) ->
web host with
addMoinMoin where
- Htdocs = "moin";
+ Htdocs = "/moin";
Prefix = "/"
end
end;
val _ = Env.registerFunction ("mail_node_to_node",
fn [e] => SOME e
| _ => NONE)
+
+
open Ast
val dl = ErrorMsg.dummyLoc
+val _ = Env.registerFunction ("end_in_slash",
+ fn [(EString "", _)] => SOME (EString "/", dl)
+ | [(EString s, _)] =>
+ SOME (EString (if String.sub (s, size s - 1) = #"/" then
+ s
+ else
+ s ^ "/"), dl)
+ | _ => NONE)
+
+
val nsD = (EString Config.defaultNs, dl)
val serialD = (EVar "serialAuto", dl)
val refD = (EInt Config.defaultRefresh, dl)
case d of
Filename {filename, heading, showEmpty} =>
if fname = filename then
- entries := readFile showEmpty ("\n" :: line :: ":\n" :: heading :: line :: !entries)
+ entries := readFile showEmpty ("\n" :: line :: "\n" :: heading :: line :: !entries)
else
()
| Extension {extension, heading} =>
NONE => ()
| SOME extension' =>
if extension' = extension then
- entries := readFile true ("\n" :: line :: ":\n" :: heading base :: line :: !entries)
+ entries := readFile true ("\n" :: line :: "\n" :: heading base :: line :: !entries)
else
()
end
end
val () = registerDescriber (considerAll [Filename {filename = "soa",
- heading = "DNS SOA",
+ heading = "DNS SOA:",
showEmpty = false}])
val () = Env.registerAction ("domainHost",
in
case Env.action prim of
NONE => raise Fail "Unbound primitive action"
- | SOME action => action (evs, args)
+ | SOME action => action (evs, List.map (Reduce.reduceExp Env.empty) args)
end
fun exec evs e =
val () = Domain.registerDescriber (Domain.considerAll
[Domain.Extension {extension = "vhost",
- heading = fn host => "Web vhost " ^ host},
+ heading = fn host => "Web vhost " ^ host ^ ":"},
Domain.Extension {extension = "vhost_ssl",
- heading = fn host => "SSL web vhost " ^ host}])
+ heading = fn host => "SSL web vhost " ^ host ^ ":"}])
end
val () = Domain.registerDescriber (Domain.considerAll
[Domain.Filename {filename = "named.conf",
- heading = "named.conf addition",
+ heading = "named.conf addition:",
showEmpty = false},
Domain.Filename {filename = "dns",
- heading = "DNS zonefile contents",
+ heading = "DNS zonefile contents:",
showEmpty = false}])
end
val () = Domain.registerDescriber (Domain.considerAll
[Domain.Filename {filename = "aliases",
- heading = "E-mail aliases",
+ heading = "E-mail aliases:",
showEmpty = false},
Domain.Filename {filename = "aliases.default",
- heading = "Default e-mail alias",
+ heading = "Default e-mail alias:",
showEmpty = false},
Domain.Filename {filename = "mail",
- heading = "E-mail handling",
- showEmpty = false},
+ heading = "E-mail handling is on.",
+ showEmpty = true},
Domain.Filename {filename = "mail.relay",
- heading = "E-mail relaying",
- showEmpty = false}])
+ heading = "E-mail relaying is on.",
+ showEmpty = true}])
end
val () = Domain.registerDescriber (Domain.considerAll
[Domain.Filename {filename = "mailman",
- heading = "Mailman web host mapping",
+ heading = "Mailman web host mapping:",
showEmpty = false}])
end
NONE => SOME "No password given"
| SOME passwd =>
if validPasswd passwd then
- if Slave.shell [Config.MySQL.adduser, user, " ", passwd] then
- NONE
- else
- SOME "Error executing CREATE USER script"
+ Option.map (fn s => "Error executing CREATE USER script:\n" ^ s)
+ (Slave.shellOutput [Config.MySQL.adduser, user, " ", passwd])
else
SOME "Password contains characters besides letters, digits, and !.-_"
fun passwd {user, passwd} =
if validPasswd passwd then
- if Slave.shell [Config.MySQL.passwd, user, " ", passwd] then
- NONE
- else
- SOME "Error executing SET PASSWORD script"
+ Option.map (fn s => "Error executing SET PASSWORD script:\n" ^ s)
+ (Slave.shellOutput [Config.MySQL.passwd, user, " ", passwd])
else
SOME "Password contains characters besides letters, digits, and !.-_"
fun createdb {user, dbname} =
- if Slave.shell [Config.MySQL.createdb, user, " ", dbname] then
- NONE
- else
- SOME "Error executing CREATE DATABASE script"
+ Option.map (fn s => "Error executing CREATE DATABASE script:\n" ^ s)
+ (Slave.shellOutput [Config.MySQL.createdb, user, " ", dbname])
fun dropdb {user, dbname} =
- if Slave.shell [Config.MySQL.dropdb, user, " ", dbname] then
- NONE
- else
- SOME "Error executing DROP DATABASE script"
+ Option.map (fn s => "Error executing DROP DATABASE script:\n" ^ s)
+ (Slave.shellOutput [Config.MySQL.dropdb, user, " ", dbname])
fun grant {user, dbname} =
- if Slave.shell [Config.MySQL.grant, user, " ", dbname] then
- NONE
- else
- SOME "Error executing GRANT script"
+ Option.map (fn s => "Error executing GRANT script:\n" ^ s)
+ (Slave.shellOutput [Config.MySQL.grant, user, " ", dbname])
val _ = Dbms.register ("mysql", {getpass = SOME Client.getpass,
adduser = adduser,
structure Postgres :> POSTGRES = struct
fun adduser {user, passwd} =
- if Slave.shell [Config.Postgres.adduser, user] then
- NONE
- else
- SOME "Error executing CREATE USER script"
+ Option.map (fn s => "Error executing CREATE USER script:\n" ^ s)
+ (Slave.shellOutput [Config.Postgres.adduser, user])
fun passwd _ = SOME "We don't use PostgreSQL passwords."
fun createdb {user, dbname} =
- if Slave.shell [Config.Postgres.createdb, user, " ", dbname] then
- NONE
- else
- SOME "Error executing CREATE DATABASE script"
+ Option.map (fn s => "Error executing CREATE DATABASE script:\n" ^ s)
+ (Slave.shellOutput [Config.Postgres.createdb, user, " ", dbname])
fun dropdb {user, dbname} =
- if Slave.shell [Config.Postgres.dropdb, user, " ", dbname] then
- NONE
- else
- SOME "Error executing DROP DATABASE script"
+ Option.map (fn s => "Error executing DROP DATABASE script:\n" ^ s)
+ (Slave.shellOutput [Config.Postgres.dropdb, user, " ", dbname])
val _ = Dbms.register ("postgres", {getpass = NONE,
adduser = adduser,
val () = Domain.registerDescriber (Domain.considerAll
[Domain.Extension {extension = "wbl",
- heading = fn host => "Webalizer config for " ^ host}])
+ heading = fn host => "Webalizer config for " ^ host ^ ":"}])
end
val shell : string list -> bool
val shellF : string list * (string -> string) -> unit
+ val shellOutput : string list -> string option
val concatTo : (string -> bool) -> string -> unit
(* Search through the result configuration hierarchy for all files matching
ErrorMsg.error NONE (msg s)
end
+fun shellOutput ss =
+ let
+ val proc = Unix.execute ("/bin/bash", ["-c", String.concat ss ^ " 2>&1"])
+ val inf = Unix.textInstreamOf proc
+
+ fun loop out =
+ case TextIO.inputLine inf of
+ NONE => String.concat (rev out)
+ | SOME line => loop (line :: out)
+
+ val lines = loop []
+ in
+ print lines;
+ if OS.Process.isSuccess (Unix.reap proc) then
+ NONE
+ else
+ SOME lines
+ end
+
fun hostname () =
let
val inf = TextIO.openIn "/etc/hostname"