-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbncert-functions.xml
More file actions
334 lines (334 loc) · 19.5 KB
/
bncert-functions.xml
File metadata and controls
334 lines (334 loc) · 19.5 KB
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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
<component>
<name>bncertfunctions</name>
<show>0</show>
<functionDefinitionList>
<!-- Validation actions -->
<actionDefinition name="bncertValidateInstalldir">
<actionList>
<setInstallerVariable name="valid_webserver" value="0"/>
<setInstallerVariable name="valid_webserver_permissions" value="0"/>
<setInstallerVariable name="valid_webserver_conf" value="0"/>
<!-- Check files are available -->
<setInstallerVariable name="valid_webserver" value="1">
<ruleList>
<bncertIsWebServerValid/>
</ruleList>
</setInstallerVariable>
<!-- Check files are available -->
<setInstallerVariable name="valid_webserver_permissions" value="1">
<ruleList>
<isTrue value="${valid_webserver}"/>
<bncertIsWebServerPermissionsValid/>
</ruleList>
</setInstallerVariable>
<!-- Check the web server configuration is valid -->
<setInstallerVariable name="valid_webserver_conf" value="1">
<ruleList>
<isTrue value="${valid_webserver}"/>
<isTrue value="${valid_webserver_permissions}"/>
<bncertIsWebServerConfigurationValid/>
</ruleList>
</setInstallerVariable>
<!-- Warnings -->
<setInstallerVariable name="enable_redirections" value="1"/>
<actionGroup>
<actionList>
<setInstallerVariable name="enable_redirections" value="0"/>
<showWarning text="Custom redirections were detected in your web server configuration files. This tool will not be able to enable/disable redirections."/>
</actionList>
<ruleList>
<isTrue value="${valid_webserver_conf}"/>
<ruleGroup>
<ruleEvaluationLogic>or</ruleEvaluationLogic>
<ruleList>
<bncertIsCustomHttpsRedirectionEnabled/>
<bncertIsCustomNonWwwToWwwRedirectionEnabled/>
<bncertIsCustomWwwToNonWwwRedirectionEnabled/>
</ruleList>
</ruleGroup>
</ruleList>
</actionGroup>
</actionList>
</actionDefinition>
<actionDefinition name="bncertValidateDomain">
<parameterList>
<stringParameter name="domain"/>
</parameterList>
<actionList>
<!-- Obtain public IP address, but only once -->
<actionGroup>
<actionList>
<getPublicIpAddress variable="machine_public_ipaddr" progressText="Determining machine public IP address"/>
<actionGroup>
<actionList>
<showQuestion title="Could not detect public IP address" text="
The public IP address for this machine could not be detected. A public IP address will be required for Let's Encrypt to verify that your domains point to this machine. Do you want to proceed anyways?" variable="ignore_public_ip_warning" default="no"/>
<throwError text="Please check public IP configuration for this machine. For more info see: https://docs.bitnami.com/general/faq/configuration/configure-static-address/">
<ruleList>
<isFalse value="${ignore_public_ip_warning}"/>
</ruleList>
</throwError>
</actionList>
<ruleList>
<stringTest text="${machine_public_ipaddr}" type="empty"/>
</ruleList>
</actionGroup>
</actionList>
<ruleList>
<isTrue value="${perform_public_ip_validation}"/>
<stringTest text="${machine_public_ipaddr}" type="empty"/>
</ruleList>
</actionGroup>
<!-- Now validate the domain DNS and ensure the IP matches -->
<if>
<conditionRuleList>
<hostValidation host="${domain}" type="hostname" condition="is_not_valid"/>
</conditionRuleList>
<actionList>
<throwError text="The domain '${domain}' does not resolve, please fix its DNS entries or remove it."/>
</actionList>
<elseActionList>
<throwError text="The domain '${domain}' resolves to a different IP address than the one detected for this machine, which is '${machine_public_ipaddr}'. Please fix its DNS entries or remove it. For more info see: https://docs.bitnami.com/general/faq/configuration/configure-custom-domain/">
<ruleList>
<validateDomainIpAddressResolution domain="${domain}" ipAddress="${machine_public_ipaddr}" negate="1"/>
<isTrue value="${perform_public_ip_validation}"/>
</ruleList>
</throwError>
</elseActionList>
</if>
</actionList>
</actionDefinition>
<!-- Parameters for updating metadata -->
<actionDefinition name="bncertDetectMissingDomains">
<parameterList>
<stringParameter name="domains"/>
<stringParameter name="variable"/>
</parameterList>
<actionList>
<globalVariables names="${domainsVariable}"/>
<tclEval>
<code><![CDATA[
set domains [installbuilder::substText {${domains}}]
set variable [installbuilder::substText {${variable}}]
set missing_domains {}
proc listContains {list element} {
return [expr [lsearch -exact $list $element] != -1]
}
foreach domain $domains {
if {[regexp {^www\.(.*)} $domain - nonWwwDomain]} {
if {![listContains $domains $nonWwwDomain]} {
lappend missing_domains $nonWwwDomain
}
} else {
set wwwDomain www.$domain
if {![listContains $domains $wwwDomain]} {
lappend missing_domains $wwwDomain
}
}
}
installbuilder::setVariable $variable $missing_domains
]]></code>
</tclEval>
</actionList>
</actionDefinition>
<actionDefinition name="bncertAddCommonChangesToPerform">
<actionList>
<!-- Stop web server (added as first element) -->
<setInstallerVariable name="changes_to_perform_metadata" value=""Stop web server" ${changes_to_perform_metadata}">
<ruleList>
<isTrue value="${manage_services}"/>
</ruleList>
</setInstallerVariable>
<!-- Server name -->
<setInstallerVariable name="changes_to_perform_metadata" value="${changes_to_perform_metadata} "Configure web server name to: ${server_name}"">
<ruleList>
<isTrue value="${configure_server_name}"/>
</ruleList>
</setInstallerVariable>
<!-- Redirections -->
<setInstallerVariableFromRegEx name="non_www_domain" pattern="^(www\.)?(.*)" substitution="\2" text="${server_name}"/>
<setInstallerVariable name="https_redirection_text" value="HTTP to HTTPS redirection (example: redirect http://${non_www_domain} to https://${non_www_domain})"/>
<setInstallerVariable name="nonwww_to_www_redirection_text" value="non-www to www redirection (example: redirect ${non_www_domain} to www.${non_www_domain})"/>
<setInstallerVariable name="www_to_nonwww_redirection_text" value="www to non-www redirection (example: redirect www.${non_www_domain} to ${non_www_domain})"/>
<!-- First disable the ones we want to, after that we can enable the rest -->
<actionGroup>
<actionList>
<!-- Disable redirections -->
<!-- Note that we won't show the text if we enable a mutually exclusive redirection -->
<setInstallerVariable name="changes_to_perform_metadata" value="${changes_to_perform_metadata} "Disable ${https_redirection_text}"">
<ruleList>
<bncertIsHttpsRedirectionEnabled/>
<isFalse value="${enable_https_redirection}"/>
</ruleList>
</setInstallerVariable>
<setInstallerVariable name="changes_to_perform_metadata" value="${changes_to_perform_metadata} "Disable ${nonwww_to_www_redirection_text}"">
<ruleList>
<bncertIsNonWwwToWwwRedirectionEnabled/>
<isFalse value="${enable_nonwww_to_www_redirection}"/>
<isFalse value="${enable_www_to_nonwww_redirection}"/>
</ruleList>
</setInstallerVariable>
<setInstallerVariable name="changes_to_perform_metadata" value="${changes_to_perform_metadata} "Disable ${www_to_nonwww_redirection_text}"">
<ruleList>
<bncertIsWwwToNonWwwRedirectionEnabled/>
<isFalse value="${enable_nonwww_to_www_redirection}"/>
<isFalse value="${enable_www_to_nonwww_redirection}"/>
</ruleList>
</setInstallerVariable>
<!-- Enable redirections -->
<foreach values="https nonwww_to_www www_to_nonwww" variables="redirection">
<actionList>
<setInstallerVariable name="changes_to_perform_metadata" value="${changes_to_perform_metadata} "Enable ${${redirection}_redirection_text}"">
<ruleList>
<isTrue value="${enable_${redirection}_redirection}"/>
</ruleList>
</setInstallerVariable>
</actionList>
</foreach>
</actionList>
<ruleList>
<isTrue value="${enable_redirections}"/>
</ruleList>
</actionGroup>
<!-- Start services -->
<setInstallerVariable name="changes_to_perform_metadata" value="${changes_to_perform_metadata} "Start web server once all changes have been performed"">
<ruleList>
<isTrue value="${manage_services}"/>
</ruleList>
</setInstallerVariable>
</actionList>
</actionDefinition>
<!-- Actions for populating parameters depending on metadata -->
<actionDefinition name="bncertPopulateChangesToPerform">
<actionList>
<setInstallerVariable name="changes_to_perform_text" value=""/>
<setInstallerVariable name="entry_number" value="0"/>
<foreach variables="entry" values="${changes_to_perform_metadata}">
<actionList>
<mathExpression text="${entry_number}+1" variable="entry_number"/>
<setInstallerVariable name="changes_to_perform_text" value="${changes_to_perform_text}
${entry_number}. ${entry}"/>
</actionList>
</foreach>
<stringModify text="${changes_to_perform_text}" logic="trim" variable="changes_to_perform_text"/>
</actionList>
</actionDefinition>
<actionDefinition name="bncertPopulateReport">
<actionList>
<!-- Errors -->
<actionGroup>
<actionList>
<setInstallerVariable name="parameter(custom_final_page).title" value="Error"/>
<setInstallerVariable name="parameter(custom_final_page).explanation" value="An error occurred when applying configurations."/>
<setInstallerVariable name="parameter(custom_final_page).parameter(report_text).explanation" value="The web server configuration was left unchanged. There was an error in the new configuration, so it was reverted."/>
</actionList>
<ruleList>
<isTrue value="${report_aborted}"/>
</ruleList>
</actionGroup>
<!-- Non-fatal errors -->
<actionGroup>
<actionList>
<!-- Skipped/failed configuration steps -->
<setInstallerVariable name="parameter(custom_final_page).title" value="Some errors occurred"/>
<setInstallerVariable name="parameter(custom_final_page).explanation" value="The configuration was applied, but some of the changes could not be applied. Find the details below."/>
</actionList>
<ruleList>
<isFalse value="${report_aborted}"/>
<stringTest text="${report_failures_metadata}" type="not_empty"/>
</ruleList>
</actionGroup>
<!-- List of failed steps -->
<actionGroup>
<actionList>
<setInstallerVariable name="report_text" value="${report_text}Failed steps:"/>
<foreach variables="entry" values="${report_failures_metadata}">
<actionList>
<setInstallerVariable name="report_text" value="${report_text}
* ${entry}"/>
</actionList>
</foreach>
<setInstallerVariable name="report_text" value="${report_text}

"/>
</actionList>
<ruleList>
<stringTest text="${report_failures_metadata}" type="not_empty"/>
</ruleList>
</actionGroup>
<!-- Steps that succeeded but could not be reverted (e.g. certificates created but we don't revoke them) -->
<actionGroup>
<actionList>
<setInstallerVariable name="report_text" value="${report_text}Some steps were not reverted. Run the tool again to apply them:"/>
<foreach variables="entry" values="${report_nonreversible_metadata}">
<actionList>
<setInstallerVariable name="report_text" value="${report_text}
* ${entry}"/>
</actionList>
</foreach>
<setInstallerVariable name="report_text" value="${report_text}

"/>
</actionList>
<ruleList>
<isTrue value="${report_aborted}"/>
<stringTest text="${report_nonreversible_metadata}" type="not_empty"/>
</ruleList>
</actionGroup>
<!-- Backup files -->
<actionGroup>
<actionList>
<setInstallerVariable name="report_text" value="${report_text}Backup files:"/>
<foreach variables="original_file backup_file" values="${restore_metadata}">
<actionList>
<setInstallerVariable name="report_text" value="${report_text}
* ${backup_file}"/>
</actionList>
</foreach>
<setInstallerVariable name="report_text" value="${report_text}

"/>
</actionList>
<ruleList>
<isFalse value="${report_aborted}"/>
<stringTest text="${restore_metadata}" type="not_empty"/>
</ruleList>
</actionGroup>
<!-- Log file -->
<!-- InstallBuilder is not allowing change to the log filename if we don't run through the original final page -->
<setInstallerVariable name="log_file" value="${system_temp_directory}/${project.shortName}-${current_run_id}.log"/>
<renameFile origin="${installer_installation_log}" destination="${log_file}"/>
<setInstallerVariable name="report_text" value="${report_text}Find more details in the log file:

${log_file}

"/>
<!-- Add Bitnami Support link info for non-GUI runs -->
<setInstallerVariable name="link_parameter" value="parameter(custom_final_page).parameter(bitnami_support_link)"/>
<setInstallerVariable name="report_text" value="${report_text}${${link_parameter}.explanation}

${${link_parameter}.description}
">
<ruleList>
<compareText text="${installer_ui}" logic="does_not_equal" value="gui"/>
</ruleList>
</setInstallerVariable>
</actionList>
</actionDefinition>
<!-- Grouped actions for a specific stage, to avoid duplicating code for different installation modes -->
<actionDefinition name="bncertPostInstalldirActions">
<actionList>
<setInstallerVariable name="installdir" value="${installdir.unix}"/>
<!-- Run the auto-updater now that we know the installdir -->
<runUpdater targetDir="${installdir}" ruleEvaluationLogic="or">
<ruleList>
<platformTest type="linux"/>
</ruleList>
</runUpdater>
<!-- Backup configuration before proceeding -->
<bncertBackupWebServerConfiguration/>
<setInstallerVariable name="requires_restoring" value="1"/>
</actionList>
</actionDefinition>
<actionDefinition name="bncertAbortActions">
<actionList>
<showProgressDialog title="Reverting changes">
<actionList>
<bncertRestoreWebServerConfiguration progressText="Restoring web server configuration"/>
<actionGroup>
<actionList>
<bncertStopWebServer progressText="Stopping web server"/>
<bncertStartWebServer progressText="Starting web server"/>
</actionList>
<ruleList>
<isTrue value="${manage_services}"/>
</ruleList>
</actionGroup>
</actionList>
</showProgressDialog>
</actionList>
</actionDefinition>
</functionDefinitionList>
</component>