Update Easy_Domain to support trivial configuration of default node
[hcoop/domtool2.git] / lib / easy_domain.dtl
... / ...
CommitLineData
1{{The most common kinds of domain configuration}}
2
3val default_node : (node) = "mire";
4val web_node : (web_node) = "mire";
5val web_ip = ip_of_node (web_node_to_node web_node);
6
7val webAt =
8 \ n : (web_node) ->
9 \ host : (host) ->
10 \\ config : Vhost -> begin
11 dns (dnsA (literal host) (ip_of_node (web_node_to_node n)));
12
13 vhost host where
14 WebPlaces = [web_place_default n]
15 with
16 config
17 end
18 end;
19
20val web = \ host -> \\ config : Vhost -> begin
21 n <- DefaultWebNode;
22 webAt n host with config end;
23end;
24
25val webAtIp =
26 \ ip : (your_ip) ->
27 \ host : (host) ->
28 \\ config : Vhost -> begin
29 dns (dnsA (literal host) (your_ip_to_ip ip));
30
31 vhost host where
32 WebPlaces = [web_place web_node ip]
33 with
34 config
35 end
36 end;
37
38val addDefaultAlias = begin
39 mailbox <- Mailbox;
40 defaultAlias mailbox
41end;
42
43val addWww = begin
44 web "www" with
45 serverAliasDefault;
46 www : [Vhost] <- WWW;
47 www
48 end
49end;
50
51val dom =
52 \ d : (your_domain) ->
53 \\ config : Domain ->
54 domain d with
55 dns (dnsNS "ns1.hcoop.net");
56 dns (dnsNS "ns2.hcoop.net");
57
58 user_web_node <- DefaultWebNode;
59
60 defa : bool <- DefaultA;
61 if defa then
62 dns (dnsA default (ip_of_node (web_node_to_node user_web_node)))
63 else
64 Skip
65 end;
66
67 hmail : bool <- HandleMail;
68 if hmail then
69 handleMail
70 else
71 Skip
72 end;
73
74 amx : bool <- AddMX;
75 if amx then
76 dns (dnsMX 1 "mail.hcoop.net")
77 else
78 Skip
79 end;
80
81 createWWW : bool <- CreateWWW;
82 if createWWW then
83 addWww
84 else
85 Skip
86 end;
87
88 defAl : bool <- DefaultAlias;
89 if defAl then
90 addDefaultAlias
91 else
92 Skip
93 end;
94
95 config
96end;
97
98val nameserver = \host -> dns (dnsNS host);
99val dnsIP = \from -> \to -> dns (dnsA (literal from) to);
100val dnsIPv6 = \from -> \to -> dns (dnsAAAA (literal from) to);
101val dnsMail = \num -> \host -> dns (dnsMX num host);
102val dnsAlias = \from -> \to -> dns (dnsCNAME (literal from) to);
103val dnsDefault = \to -> dns (dnsA default to);
104val dnsDefaultv6 = \to -> dns (dnsAAAA default to);
105val dnsText = \from -> \to -> dns (dnsTXT (srv_literal from) to);
106val dnsDefaultText = \to -> dns (dnsTXT srv_default to);
107
108val dnsWildcardIP = \to -> dns (dnsA wildcard to);