cvsimport
authoradamch <adamch>
Thu, 22 Nov 2007 21:56:53 +0000 (21:56 +0000)
committeradamch <adamch>
Thu, 22 Nov 2007 21:56:53 +0000 (21:56 +0000)
14 files changed:
elisp/domtool-mode.el
lib/domain.dtl
lib/web_apps.dtl
src/domain.sml
src/eval.sml
src/plugins/apache.sml
src/plugins/bind.sml
src/plugins/exim.sml
src/plugins/mailman.sml
src/plugins/mysql.sml
src/plugins/postgres.sml
src/plugins/webalizer.sml
src/slave.sig
src/slave.sml

index 1e6959d..292acfa 100644 (file)
 
 (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)
index 2b17089..3d9b088 100644 (file)
@@ -43,6 +43,8 @@ extern type your_path;
 {{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
index 9d6bb9f..f17e8e8 100644 (file)
@@ -22,14 +22,14 @@ val addMoinMoin = begin
   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;
index 3998b83..f8464f2 100644 (file)
@@ -202,10 +202,22 @@ val _ = Env.registerFunction ("dns_node_to_node",
 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)
@@ -894,7 +906,7 @@ fun considerAll ds {node, domain} =
                                     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} =>
@@ -905,7 +917,7 @@ fun considerAll ds {node, domain} =
                                                 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
@@ -921,7 +933,7 @@ fun considerAll ds {node, domain} =
     end
 
 val () = registerDescriber (considerAll [Filename {filename = "soa",
-                                                  heading = "DNS SOA",
+                                                  heading = "DNS SOA:",
                                                   showEmpty = false}])
 
 val () = Env.registerAction ("domainHost",
index 8789eac..1fec487 100644 (file)
@@ -102,7 +102,7 @@ fun exec' evs (eAll as (e, _)) =
        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 =
index 4da19f9..966240c 100644 (file)
@@ -931,8 +931,8 @@ val () = Domain.registerResetLocal (fn () =>
 
 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
index f08367e..48a2b03 100644 (file)
@@ -284,10 +284,10 @@ val () = Domain.registerResetLocal (fn () =>
 
 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
index f4943ac..ee036ce 100644 (file)
@@ -102,16 +102,16 @@ val () = Env.actionV_none "relayMail"
 
 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
index b716cbd..fcfbc7c 100644 (file)
@@ -187,7 +187,7 @@ val () = Slave.registerPostHandler (fn () =>
 
 val () = Domain.registerDescriber (Domain.considerAll
                                   [Domain.Filename {filename = "mailman",
-                                                    heading = "Mailman web host mapping",
+                                                    heading = "Mailman web host mapping:",
                                                     showEmpty = false}])
 
 end
index 5114e17..3cfa94f 100644 (file)
@@ -31,39 +31,29 @@ fun adduser {user, passwd} =
        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,
index 09e3a07..f80fcea 100644 (file)
 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,
index 416460d..c73ed98 100644 (file)
@@ -124,6 +124,6 @@ val () = Domain.registerResetLocal (fn () =>
 
 val () = Domain.registerDescriber (Domain.considerAll
                                   [Domain.Extension {extension = "wbl",
-                                                     heading = fn host => "Webalizer config for " ^ host}])
+                                                     heading = fn host => "Webalizer config for " ^ host ^ ":"}])
 
 end
index c413a07..7471d86 100644 (file)
@@ -45,6 +45,7 @@ signature SLAVE = sig
 
     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
index 01d872c..ba31da8 100644 (file)
@@ -82,6 +82,25 @@ fun shellF (ss, msg) =
            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"