mysql: revoke permissions when dropping database
[hcoop/domtool2.git] / lib / easy_domain.dtl
... / ...
CommitLineData
1{{The most common kinds of domain configuration}}
2
3val web_node : (web_node) = "shelob";
4val default_node : (node) = web_node_to_node web_node;
5val web_ip = ip_of_node (web_node_to_node web_node);
6val web_ipv6 = ipv6_of_node (web_node_to_node web_node);
7
8var WebPlaces = [web_place_default web_node];
9
10val webAt =
11 \ n : (web_node) ->
12 \ host : (host) ->
13 \\ config : Vhost -> begin
14 dns (dnsA (literal host) (ip_of_node (web_node_to_node n)));
15 dns (dnsAAAA (literal host) (ipv6_of_node (web_node_to_node n)));
16
17 vhost host where
18 WebPlaces = [web_place_default n]
19 with
20 config
21 end
22 end;
23
24val web = \ host -> \\ config : Vhost -> begin
25 n <- DefaultWebNode;
26 webAt n host with config end;
27end;
28
29val webAtIp =
30 \ ip : (your_ip) ->
31 \ ipv6 : (your_ipv6) ->
32 \ host : (host) ->
33 \\ config : Vhost -> begin
34 dns (dnsA (literal host) (your_ip_to_ip ip));
35 dns (dnsAAAA (literal host) (your_ipv6_to_ipv6 ipv6));
36
37 vhost host where
38 WebPlaces = [web_place web_node ip ipv6]
39 with
40 config
41 end
42 end;
43
44val webSsl = \ host -> \ certFile -> \\ config : Vhost -> begin
45 n <- DefaultWebNode;
46 webAt n host where
47 SSL = certFile;
48 with config end;
49
50 force_ssl <- ForceSSL;
51 if force_ssl then
52 webAt n host where
53 SSL = no_ssl;
54 with
55 rewriteRule "^(.*)$" "https://%{HTTP_HOST}$1" [redirect];
56
57 config; (* config is included in case of directives like
58 serverAliasDefault. https rewrite should override all
59 others since it matches first. *)
60 end;
61 else
62 webAt n host where
63 SSL = no_ssl;
64 with config end;
65 end;
66end;
67
68val addDefaultAlias = begin
69 mailbox <- Mailbox;
70 source <- DefaultAliasSource;
71 aliasPrim source (addressTarget mailbox)
72end;
73
74val addWww = begin
75 web "www" with
76 serverAliasDefault;
77 www : [Vhost] <- WWW;
78 www
79 end
80end;
81
82val dom =
83 \ d : (your_domain) ->
84 \\ config : Domain ->
85 domain d with
86 dns (dnsNS "ns1.hcoop.net");
87 dns (dnsNS "ns2.hcoop.net");
88
89 user_web_node <- DefaultWebNode;
90
91 defa : bool <- DefaultA;
92 if defa then
93 dns (dnsA default (ip_of_node (web_node_to_node user_web_node)));
94 dns (dnsAAAA default (ipv6_of_node (web_node_to_node user_web_node)))
95 else
96 Skip
97 end;
98
99 hmail : bool <- HandleMail;
100 if hmail then
101 handleMail
102 else
103 Skip
104 end;
105
106 amx : bool <- AddMX;
107 if amx then
108 dns (dnsMX 1 "mail.hcoop.net");
109 else
110 Skip
111 end;
112
113 createWWW : bool <- CreateWWW;
114 if createWWW then
115 addWww
116 else
117 Skip
118 end;
119
120 defAl : bool <- DefaultAlias;
121 if defAl then
122 addDefaultAlias
123 else
124 Skip
125 end;
126
127 config
128end;
129
130val nameserver = \host -> dns (dnsNS host);
131val dnsIP = \from -> \to -> dns (dnsA (literal from) to);
132val dnsIPv6 = \from -> \to -> dns (dnsAAAA (literal from) to);
133val dnsMail = \num -> \host -> dns (dnsMX num host);
134val dnsAlias = \from -> \to -> dns (dnsCNAME (literal from) to);
135val dnsDefault = \to -> dns (dnsA default to);
136val dnsDefaultv6 = \to -> dns (dnsAAAA default to);
137val dnsText = \from -> \to -> dns (dnsTXT (srv_literal from) to);
138val dnsDefaultText = \to -> dns (dnsTXT srv_default to);
139
140val dnsWildcardIP = \to -> dns (dnsA wildcard to);
141
142val addDefaultSPF = dnsDefaultText "v=spf1 mx -all";