-
Notifications
You must be signed in to change notification settings - Fork 0
/
bncert-webserver-functions.xml
215 lines (215 loc) · 9.57 KB
/
bncert-webserver-functions.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
<component>
<name>bncertwebserverfunctions</name>
<show>0</show>
<functionDefinitionList>
<!-- TODO: Support additional web servers (NGINX) -->
<!-- Actions used exclusively inside this file -->
<actionDefinition name="bncertPopulateWebServerParameters">
<actionList>
<apachePopulateWebServerParameters/>
<!-- Common parameters -->
<setInstallerVariable name="web_server_dir" value="${installdir}/${web_server_dirname}"/>
<setInstallerVariable name="web_server_conf_dir" value="${web_server_dir}/conf"/>
<setInstallerVariable name="web_servers_supported_message" value="Currently only installations using the Apache web server are supported."/>
</actionList>
</actionDefinition>
<actionDefinition name="bncertWebServerConfigurationFiles">
<parameterList>
<stringParameter name="variable"/>
</parameterList>
<actionList>
<globalVariables names="${variable}"/>
<apacheConfigurationFiles variable="${variable}"/>
</actionList>
</actionDefinition>
<!-- Rules -->
<ruleDefinition name="bncertIsHttpsRedirectionEnabled">
<ruleList>
<apacheIsHttpsRedirectionEnabled/>
</ruleList>
</ruleDefinition>
<ruleDefinition name="bncertIsCustomHttpsRedirectionEnabled">
<ruleList>
<apacheIsCustomHttpsRedirectionEnabled/>
</ruleList>
</ruleDefinition>
<ruleDefinition name="bncertIsNonWwwToWwwRedirectionEnabled">
<ruleList>
<apacheIsNonWwwToWwwRedirectionEnabled/>
</ruleList>
</ruleDefinition>
<ruleDefinition name="bncertIsCustomNonWwwToWwwRedirectionEnabled">
<ruleList>
<apacheIsCustomNonWwwToWwwRedirectionEnabled/>
</ruleList>
</ruleDefinition>
<ruleDefinition name="bncertIsWwwToNonWwwRedirectionEnabled">
<ruleList>
<apacheIsWwwToNonWwwRedirectionEnabled/>
</ruleList>
</ruleDefinition>
<ruleDefinition name="bncertIsCustomWwwToNonWwwRedirectionEnabled">
<ruleList>
<apacheIsCustomWwwToNonWwwRedirectionEnabled/>
</ruleList>
</ruleDefinition>
<ruleDefinition name="bncertIsWebServerValid">
<actionList>
<bncertPopulateWebServerParameters/>
<bncertWebServerConfigurationFiles variable="conf_files"/>
<setInstallerVariable name="is_valid" value="1"/>
<!-- Ensure the configuration files exist and are both readable and writable -->
<foreach variables="conf_file" values="${conf_files}">
<actionList>
<setInstallerVariable name="is_valid" value="0">
<ruleList>
<fileTest condition="not_exists" path="${conf_file}"/>
<!-- Do not check certificate files, which may have been changed by users -->
<regExMatch pattern="^.*\.(crt|key)$" logic="does_not_match" text="${conf_file}"/>
</ruleList>
</setInstallerVariable>
</actionList>
</foreach>
</actionList>
<ruleList>
<isTrue value="${is_valid}"/>
</ruleList>
</ruleDefinition>
<ruleDefinition name="bncertIsWebServerPermissionsValid">
<actionList>
<bncertPopulateWebServerParameters/>
<bncertWebServerConfigurationFiles variable="conf_files"/>
<setInstallerVariable name="is_valid" value="1"/>
<!-- Ensure the configuration files exist and are both readable and writable -->
<foreach variables="conf_file" values="${conf_files}">
<actionList>
<setInstallerVariable name="is_valid" value="0">
<ruleList>
<ruleGroup>
<ruleEvaluationLogic>or</ruleEvaluationLogic>
<ruleList>
<fileTest path="${conf_file}" condition="is_directory"/>
<fileTest path="${conf_file}" condition="not_readable"/>
<fileTest path="${conf_file}" condition="not_writable"/>
</ruleList>
</ruleGroup>
<!-- Do not check certificate files, which may have been changed by users -->
<regExMatch pattern="^.*\.(crt|key)$" logic="does_not_match" text="${conf_file}"/>
</ruleList>
</setInstallerVariable>
</actionList>
</foreach>
</actionList>
<ruleList>
<isTrue value="${is_valid}"/>
</ruleList>
</ruleDefinition>
<ruleDefinition name="bncertIsWebServerConfigurationValid">
<actionList>
<bncertPopulateWebServerParameters/>
</actionList>
<ruleList>
<apacheIsWebServerConfigurationValid/>
</ruleList>
</ruleDefinition>
<!-- Actions related to web server -->
<actionDefinition name="bncertBackupWebServerConfiguration">
<actionList>
<bncertWebServerConfigurationFiles variable="conf_files"/>
<foreach variables="conf_file" values="${conf_files}">
<actionList>
<backupFile file="${conf_file}"/>
</actionList>
</foreach>
</actionList>
</actionDefinition>
<actionDefinition name="bncertRestoreWebServerConfiguration">
<actionList>
<bncertWebServerConfigurationFiles variable="conf_files"/>
<foreach variables="conf_file" values="${conf_files}">
<actionList>
<restoreFile file="${conf_file}"/>
</actionList>
</foreach>
</actionList>
</actionDefinition>
<actionDefinition name="bncertStopWebServer">
<parameterList>
<stringParameter name="webServerName"/>
</parameterList>
<actionList>
<setInstallerVariable name="varnish_enabled" value="1">
<ruleList>
<isVarnishEnabled/>
</ruleList>
</setInstallerVariable>
<manageService action="stop" service="varnish">
<ruleList>
<isTrue value="${varnish_enabled}"/>
</ruleList>
</manageService>
<manageService action="stop" service="${webServerName}"/>
</actionList>
</actionDefinition>
<actionDefinition name="bncertStartWebServer">
<parameterList>
<stringParameter name="webServerName"/>
</parameterList>
<actionList>
<manageService action="start" service="${webServerName}"/>
<manageService action="start" service="varnish">
<ruleList>
<isTrue value="${varnish_enabled}"/>
</ruleList>
</manageService>
</actionList>
</actionDefinition>
<actionDefinition name="bncertConfigureServerName">
<parameterList>
<stringParameter name="serverName"/>
</parameterList>
<actionList>
<apacheConfigureServerName serverName="${serverName}"/>
</actionList>
</actionDefinition>
<actionDefinition name="bncertConfigureCertificates">
<parameterList>
<stringParameter name="keyFile"/>
<stringParameter name="crtFile"/>
</parameterList>
<actionList>
<apacheConfigureCertificates keyFile="${keyFile}" crtFile="${crtFile}"/>
</actionList>
</actionDefinition>
<actionDefinition name="bncertEnableHttpsRedirection">
<actionList>
<apacheEnableHttpsRedirection/>
</actionList>
</actionDefinition>
<actionDefinition name="bncertDisableHttpsRedirection">
<actionList>
<apacheDisableHttpsRedirection/>
</actionList>
</actionDefinition>
<actionDefinition name="bncertEnableNonWwwToWwwRedirection">
<actionList>
<apacheEnableNonWwwToWwwRedirection/>
</actionList>
</actionDefinition>
<actionDefinition name="bncertDisableNonWwwToWwwRedirection">
<actionList>
<apacheDisableNonWwwToWwwRedirection/>
</actionList>
</actionDefinition>
<actionDefinition name="bncertEnableWwwToNonWwwRedirection">
<actionList>
<apacheEnableWwwToNonWwwRedirection/>
</actionList>
</actionDefinition>
<actionDefinition name="bncertDisableWwwToNonWwwRedirection">
<actionList>
<apacheDisableWwwToNonWwwRedirection/>
</actionList>
</actionDefinition>
</functionDefinitionList>
</component>