-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathconfigureOnBeforeInit.js
More file actions
63 lines (58 loc) · 1.73 KB
/
configureOnBeforeInit.js
File metadata and controls
63 lines (58 loc) · 1.73 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
// Configure dialog: delay + exclude.list via api.env.file.Read (nodeId required).
// Placeholders: ${env.name}, ${targetNodes.nodeGroup}
var envName = "${env.name}";
var nodeGroup = "${targetNodes.nodeGroup}";
var currentDelay = "10";
var currentExclude = "";
var envResp, sampleNodeId, envInfo, ni, confPath, excludeFullPath, confRead, dm, exRead;
var lp = "/data/";
if (nodeGroup != "storage") {
envResp = api.env.control.GetContainerEnvVarsByGroup(envName, session, nodeGroup);
if (envResp.result == 0 && envResp.object && envResp.object.WEBROOT) {
lp = envResp.object.WEBROOT;
if (lp.charAt(lp.length - 1) != "/") {
lp += "/";
}
} else {
lp = "/var/www/webroot/";
}
}
envInfo = jelastic.environment.control.GetEnvInfo(envName, session);
if (envInfo.result == 0 && envInfo.nodes) {
for (ni = 0; ni < envInfo.nodes.length; ni++) {
if (envInfo.nodes[ni].nodeGroup == nodeGroup) {
sampleNodeId = envInfo.nodes[ni].id;
break;
}
}
}
function readNodeFile(path) {
return api.env.file.Read(envName, session, String(path), null, nodeGroup, sampleNodeId);
}
confPath = lp + "lsyncd/etc/lsyncd.conf";
excludeFullPath = lp + "lsyncd/etc/exclude.list";
confRead = readNodeFile(confPath);
if (confRead.result == 0 && confRead.body) {
dm = String(confRead.body).match(/delay=(\d+)/);
if (dm) {
currentDelay = dm[1];
}
}
exRead = readNodeFile(excludeFullPath);
if (exRead.result == 0 && exRead.body != null) {
currentExclude = String(exRead.body);
}
settings.fields.push({
name: "delay",
caption: "Sync delay (sec)",
type: "string",
value: currentDelay
});
settings.fields.push({
name: "exclude",
caption: "Exclude paths",
type: "text",
height: 200,
value: currentExclude
});
return settings;