mysql: revoke permissions when dropping database
[hcoop/domtool2.git] / lib / easy_domain.dtl
CommitLineData
6bb366c5
AC
1{{The most common kinds of domain configuration}}
2
4dffd36f 3val web_node : (web_node) = "shelob";
733d4d61 4val default_node : (node) = web_node_to_node web_node;
539abe03 5val web_ip = ip_of_node (web_node_to_node web_node);
c2dfd5dd 6val web_ipv6 = ipv6_of_node (web_node_to_node web_node);
15e529d6 7
733d4d61
CE
8var WebPlaces = [web_place_default web_node];
9
15e529d6 10val webAt =
ae272cb5
AC
11 \ n : (web_node) ->
12 \ host : (host) ->
13 \\ config : Vhost -> begin
cfedb922 14 dns (dnsA (literal host) (ip_of_node (web_node_to_node n)));
c2dfd5dd 15 dns (dnsAAAA (literal host) (ipv6_of_node (web_node_to_node n)));
15e529d6 16
ae272cb5
AC
17 vhost host where
18 WebPlaces = [web_place_default n]
19 with
20 config
21 end
22 end;
15e529d6 23
5c8b4fb8
CE
24val web = \ host -> \\ config : Vhost -> begin
25 n <- DefaultWebNode;
26 webAt n host with config end;
27end;
6bb366c5 28
2e87719c 29val webAtIp =
ae272cb5 30 \ ip : (your_ip) ->
c2dfd5dd 31 \ ipv6 : (your_ipv6) ->
ae272cb5
AC
32 \ host : (host) ->
33 \\ config : Vhost -> begin
cfedb922 34 dns (dnsA (literal host) (your_ip_to_ip ip));
8632e78d 35 dns (dnsAAAA (literal host) (your_ipv6_to_ipv6 ipv6));
2e87719c 36
ae272cb5 37 vhost host where
c2dfd5dd 38 WebPlaces = [web_place web_node ip ipv6]
ae272cb5
AC
39 with
40 config
41 end
42 end;
2e87719c 43
6052cb79
CE
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];
d4fd47c0
CE
56
57 config; (* config is included in case of directives like
58 serverAliasDefault. https rewrite should override all
59 others since it matches first. *)
6052cb79
CE
60 end;
61 else
62 webAt n host where
63 SSL = no_ssl;
64 with config end;
65 end;
66end;
67
a356587a 68val addDefaultAlias = begin
d4e42f2a 69 mailbox <- Mailbox;
945262dc
CE
70 source <- DefaultAliasSource;
71 aliasPrim source (addressTarget mailbox)
d4e42f2a
AC
72end;
73
74val addWww = begin
75 web "www" with
76 serverAliasDefault;
77 www : [Vhost] <- WWW;
78 www
79 end
80end;
81
a356587a 82val dom =
ae272cb5
AC
83 \ d : (your_domain) ->
84 \\ config : Domain ->
85 domain d with
86 dns (dnsNS "ns1.hcoop.net");
0c195384 87 dns (dnsNS "ns2.hcoop.net");
6bb366c5 88
5c8b4fb8
CE
89 user_web_node <- DefaultWebNode;
90
942d94ab
AC
91 defa : bool <- DefaultA;
92 if defa then
c2dfd5dd
CE
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)))
942d94ab
AC
95 else
96 Skip
97 end;
6eeb3bf9 98
b3cab94c
AC
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
4515633d 108 dns (dnsMX 1 "mail.hcoop.net");
b3cab94c
AC
109 else
110 Skip
111 end;
6bb366c5 112
ae272cb5
AC
113 createWWW : bool <- CreateWWW;
114 if createWWW then
115 addWww
116 else
117 Skip
118 end;
d4e42f2a 119
ae272cb5
AC
120 defAl : bool <- DefaultAlias;
121 if defAl then
122 addDefaultAlias
123 else
124 Skip
125 end;
d4e42f2a 126
ae272cb5 127 config
5c8b4fb8 128end;
6b718954 129
8c142ff5 130val nameserver = \host -> dns (dnsNS host);
cfedb922
AC
131val dnsIP = \from -> \to -> dns (dnsA (literal from) to);
132val dnsIPv6 = \from -> \to -> dns (dnsAAAA (literal from) to);
8c142ff5 133val dnsMail = \num -> \host -> dns (dnsMX num host);
cfedb922
AC
134val dnsAlias = \from -> \to -> dns (dnsCNAME (literal from) to);
135val dnsDefault = \to -> dns (dnsA default to);
136val dnsDefaultv6 = \to -> dns (dnsAAAA default to);
63ac3b82
AC
137val dnsText = \from -> \to -> dns (dnsTXT (srv_literal from) to);
138val dnsDefaultText = \to -> dns (dnsTXT srv_default to);
6b65a0a6 139
1b1021cb 140val dnsWildcardIP = \to -> dns (dnsA wildcard to);
5ea8643a
CE
141
142val addDefaultSPF = dnsDefaultText "v=spf1 mx -all";