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