Factor path prefixes into ConfigCore structure
authorClinton Ebadi <clinton@unknownlamer.org>
Wed, 16 Apr 2014 07:57:24 +0000 (03:57 -0400)
committerClinton Ebadi <clinton@unknownlamer.org>
Wed, 16 Apr 2014 07:57:24 +0000 (03:57 -0400)
Not fully worked out yet, but this is the first step toward making it
easier to relocate domtool.

18 files changed:
Makefile
config/core/core.sig [new file with mode: 0644]
config/core/core.sml [new file with mode: 0644]
configDefault/apache.cfg
configDefault/bind.cfg
configDefault/bind.csg
configDefault/courier.cfg
configDefault/domtool.cfg
configDefault/domtool.cfs
configDefault/exim.cfg
configDefault/firewall.cfg
configDefault/mailman.cfg
configDefault/mysql.cfg
configDefault/postgres.cfg
configDefault/webalizer.cfg
src/domain.sml
src/plugins/bind.sml
src/sources

index 7f5d7d5..118c5de 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -20,8 +20,9 @@ mlton: bin/domtool-server bin/domtool-client bin/domtool-slave \
 
 smlnj: $(COMMON_DEPS) openssl/smlnj/FFI/libssl.h.cm pcre/smlnj/FFI/libpcre.h.cm \
        src/domtool.cm
+       CFLAGS += -m32
 
-configDefault/config.sig: src/config.sig.header \
+configDefault/config.sig: config/core/core.sig src/config.sig.header \
                configDefault/*.csg configDefault/*.cfs \
                src/config.sig.footer
        cat configDefault/*.csg \
@@ -30,7 +31,7 @@ configDefault/config.sig: src/config.sig.header \
                src/config.sig.footer \
                >configDefault/config.sig
 
-configDefault/configDefault.sml: src/configDefault.sml.header \
+configDefault/configDefault.sml: config/core/core.sml src/configDefault.sml.header \
                configDefault/*.cfg src/configDefault.sml.footer
        cat src/configDefault.sml.header \
                configDefault/*.cfg \
diff --git a/config/core/core.sig b/config/core/core.sig
new file mode 100644 (file)
index 0000000..c3377ee
--- /dev/null
@@ -0,0 +1,22 @@
+(* Core configure to allow domtool to be easily relocated *)
+signature CONFIG_CORE = sig
+
+    val sharedRoot : string
+    (* Global file system space for domtool daemon to share *)
+
+    val localRoot : string
+    (* Local file system space for domtool to generate configuration into *)
+
+    val installPrefix : string
+    (* Prefix for domtool bin/share data ala GNU $PREFIX *)
+
+    val cat : string
+    val cp : string
+    val diff : string
+    val rm : string
+    val echo : string
+    val grep : string
+    val sudo : string
+    (* Paths to standard UNIX utilities *)
+
+end
diff --git a/config/core/core.sml b/config/core/core.sml
new file mode 100644 (file)
index 0000000..b03556a
--- /dev/null
@@ -0,0 +1,15 @@
+structure ConfigCore :> CONFIG_CORE = struct
+
+val sharedRoot = "/afs/hcoop.net/common/etc/domtool"
+val localRoot = "/var/domtool"
+val installPrefix = "/usr/local"
+
+val cat = "/bin/cat"
+val cp = "/bin/cp"
+val diff = "/usr/bin/diff"
+val rm = "/bin/rm"
+val echo = "/bin/echo"
+val grep = "/bin/grep"
+val sudo = "/usr/bin/sudo"
+
+end
index ccb222d..3d10c3a 100644 (file)
@@ -2,17 +2,17 @@ structure Apache :> APACHE_CONFIG = struct
 
 open ConfigTypes
 
-val reload = "/usr/bin/sudo /usr/local/sbin/domtool-publish apache"
-val down = "/usr/bin/sudo /usr/local/sbin/domtool-publish apache-down"
-val undown = "/usr/bin/sudo /usr/local/sbin/domtool-publish apache-undown"
-val fixperms = "/usr/bin/sudo /usr/local/sbin/domtool-publish apache-fixperms"
+val reload = ConfigCore.sudo ^ " " ^ ConfigCore.installPrefix ^ "/sbin/domtool-publish apache"
+val down = ConfigCore.sudo ^ " " ^ ConfigCore.installPrefix ^ "/sbin/domtool-publish apache-down"
+val undown = ConfigCore.sudo ^ " " ^ ConfigCore.installPrefix ^ "/sbin/domtool-publish apache-undown"
+val fixperms = ConfigCore.sudo ^ " " ^ ConfigCore.installPrefix ^ "/sbin/domtool-publish apache-fixperms"
 
-val reload1 = "/usr/bin/sudo /usr/local/sbin/domtool-publish apache1.3"
-val down1 = "/usr/bin/sudo /usr/local/sbin/domtool-publish apache1.3-down"
-val undown1 = "/usr/bin/sudo /usr/local/sbin/domtool-publish apache1.3-undown"
-val fixperms1 = "/usr/bin/sudo /usr/local/sbin/domtool-publish apache1.3-fixperms"
+val reload1 = ConfigCore.sudo ^ " " ^ ConfigCore.installPrefix ^ "/sbin/domtool-publish apache1.3"
+val down1 = ConfigCore.sudo ^ " " ^ ConfigCore.installPrefix ^ "/sbin/domtool-publish apache1.3-down"
+val undown1 = ConfigCore.sudo ^ " " ^ ConfigCore.installPrefix ^ "/sbin/domtool-publish apache1.3-undown"
+val fixperms1 = ConfigCore.sudo ^ " " ^ ConfigCore.installPrefix ^ "/sbin/domtool-publish apache1.3-fixperms"
 
-val confDir = "/var/domtool/vhosts"
+val confDir = ConfigCore.localRoot ^ "/vhosts"
 
 val webNodes_all = [("navajos", {version = APACHE_2, auth = MOD_WAKLOG})]
 val webNodes_admin = [("deleuze", {version = APACHE_2, auth = MOD_WAKLOG})]
@@ -41,6 +41,7 @@ fun logDirOf version1 user =
                       user,
                       "/apache/log"]
 
+(* FIXME: hcoop.net reference *)
 fun realLogDirOf user =
     if size user < 2 then
        "/bad_username"
@@ -55,12 +56,12 @@ fun realLogDirOf user =
 
 fun backupLogDirOf version1 =
     if version1 then
-       "/afs/hcoop.net/common/etc/domtool/backup/apache/"
+       ConfigCore.sharedRoot ^ "/backup/apache/"
     else
-       "/afs/hcoop.net/common/etc/domtool/backup/apache2/"
+       ConfigCore.sharedRoot ^ "/backup/apache2/"
 
 val defaultPhpVersion = 5
 
-val waklogUserFile = "/var/domtool/waklog.conf"
+val waklogUserFile = ConfigCore.localRoot ^ "/waklog.conf"
 
 end
index a0577df..1554dc3 100644 (file)
@@ -1,13 +1,15 @@
 structure Bind :> BIND_CONFIG = struct
 
-val defaultTTL = 3600
+val masterNode = "deleuze"
+val slaveNodes = ["outpost"]
 
+val defaultTTL = 3600
 
-val zonePath = "/var/domtool/zones"
+val zonePath = ConfigCore.localRoot ^ "/zones"
 val zonePath_real = "/etc/bind/zones"
 
-val namedConf = "/var/domtool/named.conf.local"
+val namedConf = ConfigCore.localRoot ^ "/named.conf.local"
 
-val reload = "/usr/bin/sudo /usr/local/sbin/domtool-publish bind"
+val reload = ConfigCore.sudo ^ " " ^ ConfigCore.installPrefix ^ "/sbin/domtool-publish bind"
 
 end
index e89b146..3ecd1ca 100644 (file)
@@ -1,5 +1,8 @@
 signature BIND_CONFIG = sig
 
+    val masterNode : string
+    val slaveNodes : string list
+
     val defaultTTL : int
 
     val zonePath : string
index a4ffa87..a0da8b3 100644 (file)
@@ -9,13 +9,14 @@ val makeuserdb = "/usr/sbin/makeuserdb"
 val userdbDir = "/etc/courier/userdb"
 (* Directory for storing userdb info *)
 
-val postReload = "/usr/bin/sudo /usr/local/sbin/domtool-publish courier"
+val postReload = ConfigCore.sudo ^ " " ^ ConfigCore.installPrefix ^ "/sbin/domtool-publish courier"
 (* Command to run after reloading userdb data *)
 
 val logFile = "/var/log/exim4/mainlog"
 (* SMTP log *)
 
-val pushUserdb = "/usr/bin/rsync -r --delete /etc/courier/userdb/* /afs/hcoop.net/common/etc/domtool/email/userdb/"
-val pullUserdb = "/usr/bin/rsync -r --delete /afs/hcoop.net/common/etc/domtool/email/userdb/* /etc/courier/userdb/"
+(* FIXME: should probably be in an external script *)
+val pushUserdb = "/usr/bin/rsync -r --delete /etc/courier/userdb/* " ^ ConfigCore.sharedRoot ^ "/email/userdb/"
+val pullUserdb = "/usr/bin/rsync -r --delete " ^ ConfigCore.sharedRoot ^ "/email/userdb/* /etc/courier/userdb/"
 
 end
index a56c152..225b028 100644 (file)
@@ -1,16 +1,11 @@
-val libRoot = "/afs/hcoop.net/common/etc/domtool/lib"
-val resultRoot = "/afs/hcoop.net/common/etc/domtool/nodes"
+open ConfigCore
+
+val libRoot = ConfigCore.sharedRoot ^ "/lib"
+val resultRoot = ConfigCore.sharedRoot ^ "/nodes"
 val tmpDir = "/tmp/domtool"
-val oldResultRoot = "/afs/hcoop.net/common/etc/domtool/nodes.old"
+val oldResultRoot = ConfigCore.sharedRoot ^ "/nodes.old"
 
-val cat = "/bin/cat"
-val cp = "/bin/cp"
-val diff = "/usr/bin/diff"
-val rm = "/bin/rm"
-val echo = "/bin/echo"
-val grep = "/bin/grep"
-val sudo = "/usr/bin/sudo"
-val domtool_publish = "/usr/local/sbin/domtool-publish"
+val domtool_publish = ConfigCore.installPrefix ^ "/sbin/domtool-publish"
 
 val defaultNs = "ns1.hcoop.net"
 
@@ -22,43 +17,39 @@ val defaultMinimum = 3600
 val nodeIps = [("deleuze", "69.90.123.67"), ("hopper", "69.90.123.74"), ("fritz", "69.90.123.75"), ("navajos", "69.90.123.70"), ("bog", "69.90.123.72"), ("outpost", "151.236.216.192")]
 val defaultNode = "fritz"
 
-val masterNode = "deleuze"
-val slaveNodes = ["outpost"]
-(* THESE ARE THE DNS MASTER/SLAVE, NOT DOMTOOL NODES *)
-
 val dnsNodes_all = ["deleuze", "outpost"]
 val dnsNodes_admin = []
 
 val mailNodes_all = ["deleuze"]
 val mailNodes_admin = []
 
-val aclFile = "/afs/hcoop.net/common/etc/domtool/acl"
+val aclFile = ConfigCore.sharedRoot ^ "/acl"
 
 val testUser = "test"
 
 val defaultDomain = "hcoop.net"
 
-val dispatcher = defaultNode ^ ".hcoop.net"
+val dispatcher = defaultNode ^ "."  ^ defaultDomain
 val dispatcherPort = 1234
 val slavePort = 1235
 val queueSize = 5
 
 val bufSize = 1024
 
-val trustStore = "/afs/hcoop.net/common/etc/domtool/TrustStore.pem"
+val trustStore = ConfigCore.sharedRoot ^ "/TrustStore.pem"
 
-val certDir = "/afs/hcoop.net/common/etc/domtool/certs"
-val keyDir = "/afs/hcoop.net/common/etc/domtool/keys"
-val serialDir = "/afs/hcoop.net/common/etc/domtool/serials"
+val certDir = ConfigCore.sharedRoot ^ "/certs"
+val keyDir = ConfigCore.sharedRoot ^ "/keys"
+val serialDir = ConfigCore.sharedRoot ^ "/serials"
 
 val dispatcherName = defaultNode
 
 fun domtoolDir user =
     case user of
-       "domtool" => "/afs/hcoop.net/common/etc/domtool/.domtool"
+       "domtool" => ConfigCore.sharedRoot ^ "/.domtool"
       | _ => OS.Path.joinDirFile {dir = Posix.SysDB.Passwd.home (Posix.SysDB.getpwnam user),
                                  file = ".domtool"}
 
 val worldReadable = ["/usr/share/moin", "/usr/share/apache/icons", "/afs/hcoop.net/common/app/moin/installed"]
 
-val publish_reusers = "/usr/bin/sudo " ^ domtool_publish ^ " users"
+val publish_reusers = ConfigCore.sudo ^ " " ^ domtool_publish ^ " users"
index a1c755a..6d8622a 100644 (file)
@@ -11,14 +11,6 @@ val oldResultRoot : string
 val tmpDir : string
 (* Filesystem location for creating temporary directories *)
 
-(* Paths to standard UNIX utilities *)
-val cat : string
-val cp : string
-val diff : string
-val rm : string
-val echo : string
-val grep : string
-val sudo : string
 val domtool_publish : string
 
 (* DNS SOA parameter defaults *)
@@ -32,9 +24,6 @@ val defaultMinimum : int
 val nodeIps : (string * string) list
 val defaultNode : string
 
-val masterNode : string
-val slaveNodes : string list
-
 val aclFile : string
 (* Place to serialize ACL information *)
 
dissimilarity index 69%
index a1ef37a..db689ec 100644 (file)
@@ -1,14 +1,14 @@
-structure Exim :> EXIM_CONFIG = struct
-
-val aliases = "/var/domtool/aliases"
-val aliasesDefault = "/var/domtool/aliases.default"
-val handleDomains = "/var/domtool/local_domains.cfg"
-val relayDomains = "/var/domtool/relay_domains.cfg"
-
-val reload = "/usr/bin/sudo /usr/local/sbin/domtool-publish exim"
-
-val aliasTo = ["deleuze"]
-
-val mainLog = "/var/log/exim4/mainlog"
-
-end
+structure Exim :> EXIM_CONFIG = struct
+
+val aliases = ConfigCore.localRoot ^ "/aliases"
+val aliasesDefault = ConfigCore.localRoot ^ "/aliases.default"
+val handleDomains = ConfigCore.localRoot ^ "/local_domains.cfg"
+val relayDomains = ConfigCore.localRoot ^ "/relay_domains.cfg"
+
+val reload = ConfigCore.sudo ^ " " ^ ConfigCore.installPrefix ^ "/sbin/domtool-publish exim"
+
+val aliasTo = ["deleuze"]
+
+val mainLog = "/var/log/exim4/mainlog"
+
+end
index 4eaa0af..7bd179a 100644 (file)
@@ -1,10 +1,10 @@
 (* -*- sml -*- *)
 structure Firewall :> FIREWALL_CONFIG = struct
 
-val firewallRules = "/afs/hcoop.net/common/etc/domtool/firewall/user.rules"
-val firewallDir = "/var/domtool/firewall/"
+val firewallRules = ConfigCore.sharedRoot ^ "/firewall/user.rules"
+val firewallDir = ConfigCore.localRoot ^ "/firewall/"
 val firewallNodes = ["bog", "navajos"]
 
-val reload = "/usr/bin/sudo /usr/local/sbin/domtool-publish firewall"
+val reload = ConfigCore.sudo ^ " " ^ ConfigCore.installPrefix ^ "/sbin/domtool-publish firewall"
 
 end
index 090de39..bc80616 100644 (file)
@@ -2,9 +2,9 @@ structure Mailman :> MAILMAN_CONFIG = struct
 
 val node = "deleuze"
 
-val mapFile = "/var/domtool/mailman.map"
-val handleDomains = "/var/domtool/mailman_domains.cfg"
+val mapFile = ConfigCore.localRoot ^ "/mailman.map"
+val handleDomains = ConfigCore.localRoot ^ "/mailman_domains.cfg"
 
-val reload = "/usr/bin/sudo /usr/local/sbin/domtool-publish mailman"
+val reload = ConfigCore.sudo ^ " " ^ ConfigCore.installPrefix ^ "/sbin/domtool-publish mailman"
 
 end
dissimilarity index 87%
index 05faa7a..3673718 100644 (file)
@@ -1,9 +1,9 @@
-structure MySQL :> MYSQL_CONFIG = struct
-
-val adduser = "/usr/bin/sudo /usr/local/sbin/domtool-mysql adduser"
-val passwd = "/usr/bin/sudo /usr/local/sbin/domtool-mysql passwd"
-val createdb = "/usr/bin/sudo /usr/local/sbin/domtool-mysql createdb"
-val dropdb = "/usr/bin/sudo /usr/local/sbin/domtool-mysql dropdb"
-val grant = "/usr/bin/sudo /usr/local/sbin/domtool-mysql grant"
-
-end
+structure MySQL :> MYSQL_CONFIG = struct
+
+val adduser = ConfigCore.sudo ^ " " ^ ConfigCore.installPrefix ^ "/sbin/domtool-mysql adduser"
+val passwd = ConfigCore.sudo ^ " " ^ ConfigCore.installPrefix ^ "/sbin/domtool-mysql passwd"
+val createdb = ConfigCore.sudo ^ " " ^ ConfigCore.installPrefix ^ "/sbin/domtool-mysql createdb"
+val dropdb = ConfigCore.sudo ^ " " ^ ConfigCore.installPrefix ^ "/sbin/domtool-mysql dropdb"
+val grant = ConfigCore.sudo ^ " " ^ ConfigCore.installPrefix ^ "/sbin/domtool-mysql grant"
+
+end
dissimilarity index 65%
index 83dfe53..4f0d3e0 100644 (file)
@@ -1,10 +1,10 @@
-structure Postgres :> POSTGRES_CONFIG = struct
-
-val adduser = "/usr/bin/sudo /usr/local/sbin/domtool-postgres adduser"
-val createdb = "/usr/bin/sudo /usr/local/sbin/domtool-postgres createdb"
-val dropdb = "/usr/bin/sudo /usr/local/sbin/domtool-postgres dropdb"
-
-val postgres81port = "5432";
-val postgres91port = "5433"
-
-end
+structure Postgres :> POSTGRES_CONFIG = struct
+
+val adduser = ConfigCore.sudo ^ " " ^ ConfigCore.installPrefix ^ "/sbin/domtool-postgres adduser"
+val createdb = ConfigCore.sudo ^ " " ^ ConfigCore.installPrefix ^ "/sbin/domtool-postgres createdb"
+val dropdb = ConfigCore.sudo ^ " " ^ ConfigCore.installPrefix ^ "/sbin/domtool-postgres dropdb"
+
+val postgres81port = "5432";
+val postgres91port = "5433"
+
+end
index addea9c..02be716 100644 (file)
@@ -1,10 +1,10 @@
 structure Webalizer :> WEBALIZER_CONFIG = struct
 
-val configDir = "/afs/hcoop.net/common/etc/domtool/webalizer/config"
-val outputDir = "/afs/hcoop.net/common/etc/domtool/webalizer/output"
-val backupDir = "/afs/hcoop.net/common/etc/domtool/backup/webalizer"
+val configDir = ConfigCore.sharedRoot ^ "/webalizer/config"
+val outputDir = ConfigCore.sharedRoot ^ "/webalizer/output"
+val backupDir = ConfigCore.sharedRoot ^ "/backup/webalizer"
 
-val defaultOutput = "/afs/hcoop.net/common/etc/domtool/webalizer/output/main/"
+val defaultOutput = ConfigCore.sharedRoot ^ "/webalizer/output/main/"
 val defaultHost = "www.hcoop.net"
 
 end
index 82367ce..82367f3 100644 (file)
@@ -279,11 +279,11 @@ val soaD = multiApp ((EVar "soa", dl),
                     [nsD, serialD, refD, retD, expD, minD])
 
 val masterD = (EApp ((EVar "internalMaster", dl),
-                    (EString Config.masterNode, dl)),
+                    (EString Config.Bind.masterNode, dl)),
               dl)
 
 val slavesD = (EList (map (fn s => (EString s, dl))
-                         (List.filter (fn x => List.exists (fn y => y = x) (Config.dnsNodes_all @ Config.dnsNodes_admin)) Config.slaveNodes)), dl)
+                         (List.filter (fn x => List.exists (fn y => y = x) (Config.dnsNodes_all @ Config.dnsNodes_admin)) Config.Bind.slaveNodes)), dl)
 
 val _ = Defaults.registerDefault ("Aliases",
                                  (TList (TBase "your_domain", dl), dl),
index 20aeb60..ff99fba 100644 (file)
@@ -229,7 +229,7 @@ val () = Slave.registerFileHandler (fn fs =>
                                           val {dir, file} = OS.Path.splitDirFile (#file fs)
                                                             
                                           fun dnsChanged () =
-                                              if #domain fs = !didDomain orelse Slave.hostname () <> Config.masterNode then
+                                              if #domain fs = !didDomain orelse Slave.hostname () <> Config.Bind.masterNode then
                                                   ()
                                               else if Slave.isDelete (#action fs) then
                                                   let
index 1538dd4..3c3ff42 100644 (file)
@@ -7,6 +7,8 @@ ast.sml
 
 configTypes.sml
 
+../config/core/core.sig
+../config/core/core.sml
 ../configDefault/config.sig
 ../configDefault/configDefault.sml