add linux binary to agentinvite (#5717)
Signed-off-by: si458 <simonsmith5521@gmail.com>
Simon Smith committed
Jan 23, 2024 at 04:57 UTC
b860981925c05560be04e988eb45238d330dc392
1 file changed
+82
-12
views/agentinvite.handlebars
+82
-12
@@ -82,6 +82,7 @@
82
<button id="twintab64" class="tablinks" onclick="openTab(event, 'wintab64')">Windows 64bit</button>
83
<button id="twintab32" class="tablinks" onclick="openTab(event, 'wintab32')">Windows 32bit</button>
84
<button id="tlinuxtab" class="tablinks" onclick="openTab(event, 'linuxtab')">Linux</button>
85
+ <button id="tlinuxbinarytab" class="tablinks" onclick="openTab(event, 'linuxbinarytab')">Linux Binary</button>
86
<button id="tmacostab" class="tablinks" onclick="openTab(event, 'macostab')">MacOS</button>
87
<button id="tandrotab" class="tablinks" onclick="openTab(event, 'androtab')">Android</button>
88
<button id="tassistab" class="tablinks" onclick="openTab(event, 'assistab')">Assistant</button>
@@ -114,6 +115,8 @@
115
<br /><br />
116
</div>
117
118
+ <div id="linuxbinarytab" class="tabcontent" style="background-color:white;color:black"></div>
119
+
120
<div id="macostab" class="tabcontent" style="background-color:white;color:black">
121
<h3>Apple™ MacOS</h3>
122
<p><a id="macosurl">Download the installer here</a>, right click on it or press "control" and click on the file. Then select "Open" and follow the instructions.</p>
@@ -222,30 +225,70 @@
225
226
// Setup visible tabs
227
var tabcount = 0, tabselect = null;
225
- var tab1 = (showAgents == 0) || (showAgents & 1);
226
- var tab2 = (showAgents == 0) || (showAgents & 1);
227
- var tab3 = (showAgents == 0) || (showAgents & 2);
228
- var tab4 = (showAgents == 0) || (showAgents & 4);
229
- var tab5 = (showAgents == 0) || (showAgents & 16);
230
- var tab6 = (showAgents == 0) || (showAgents & 8);
231
- if (tab6) { tabcount++; tabselect = 'assistab'; }
232
- if (tab5) { tabcount++; tabselect = 'androtab'; }
233
- if (tab4) { tabcount++; tabselect = 'macostab'; }
228
+ var tab1 = (showAgents == 0) || (showAgents & 1); //win64
229
+ var tab2 = (showAgents == 0) || (showAgents & 1); //win32
230
+ var tab3 = (showAgents == 0) || (showAgents & 2); //linux
231
+ var tab4 = (showAgents == 0) || (showAgents & 2); //linuxbinary
232
+ var tab5 = (showAgents == 0) || (showAgents & 4); //macos
233
+ var tab6 = (showAgents == 0) || (showAgents & 16); //android
234
+ var tab7 = (showAgents == 0) || (showAgents & 8); //assistant
235
+ if (tab7) { tabcount++; tabselect = 'assistab'; }
236
+ if (tab6) { tabcount++; tabselect = 'androtab'; }
237
+ if (tab5) { tabcount++; tabselect = 'macostab'; }
238
+ if (tab4) { tabcount++; tabselect = 'linuxbinarytab'; }
239
if (tab3) { tabcount++; tabselect = 'linuxtab'; }
240
if (tab2) { tabcount++; tabselect = 'wintab32'; }
241
if (tab1) { tabcount++; tabselect = 'wintab64'; }
242
QV('twintab64', tab1 && (tabcount > 1));
243
QV('twintab32', tab2 && (tabcount > 1));
244
QV('tlinuxtab', tab3 && (tabcount > 1));
240
- QV('tmacostab', tab4 && (tabcount > 1));
241
- QV('tandrotab', tab5 && (tabcount > 1));
242
- QV('tassistab', tab6 && (tabcount > 1));
245
+ QV('tlinuxbinarytab', tab4 && (tabcount > 1));
246
+ QV('tmacostab', tab5 && (tabcount > 1));
247
+ QV('tandrotab', tab6 && (tabcount > 1));
248
+ QV('tassistab', tab7 && (tabcount > 1));
249
250
userInterfaceSelectMenu();
251
setup();
252
openTab(null, tabselect);
253
}
254
255
+ function linuxBinarySetup() {
256
+ var x = '<h3>Linux Binary</h3>', moreoptions = '';
257
+ var opts = '<select id=aginsSelect onchange=addAgentToMeshClick() style=width:236px>';
258
+ opts += '<option value=5 selected>' + "Linux / BSD / macOS Binary Installer" + '</option>';
259
+ opts += '</select>';
260
+ x += '<table style=display:none><td style=width:120px><td><b>' + opts + '</b></table>';
261
+ var servername = window.location.hostname;
262
+ if ((servername.indexOf('.') == -1)) { servername = window.location.hostname; } // If the server name is not set or it's in LAN-only mode, use the URL hostname as server name.
263
+ var portStr = (serverPort == 443) ? '' : (':' + serverPort);
264
+ var binaryInstallAgentsOrder = [ 6, 5, 10005, 25, 26, 28, 30, 32, 36, 37, 40, 41 ];
265
+ var binaryInstallAgents = { 5 : 'Linux x86-32', 6 : 'Linux x86-64', 10005 : 'Apple OSX Universal', 25 : 'Linux ARM-HF, Rasberry Pi', 26 : 'Linux ARM64-HF', 28: 'Linux MIPS24KC (OpenWRT)', 30 : 'FreeBSD x86-64', 32: 'Linux ARM 64 bit (glibc/2.24 NOKVM)', 36: 'OpenWRT x86-64', 37: 'OpenBSD x86-64', 40: 'Linux MIPSEL24KC (OpenWRT)', 41: 'ARMADA/CORTEX-A53/MUSL (OpenWRT)' };
266
+ for (var i in binaryInstallAgentsOrder) { moreoptions += '<option value=' + binaryInstallAgentsOrder[i] + '>' + binaryInstallAgents[binaryInstallAgentsOrder[i]] + '</option>' }
267
+ x += '<div id=aginsSysTypeDiv>';
268
+ x += addHtmlValue("System Type", '<select id=aginsSysType onchange=addAgentToMeshClick() style=width:236px>' + moreoptions + '</select>');
269
+ x += '</div>';
270
+ x += '<div id=aginsTypeDiv>';
271
+ x += addHtmlValue("Installation Type", '<select id=aginsType onchange=addAgentToMeshClick() style=width:236px><option value=0>' + "Background & interactive" + '</option><option value=2>' + "Background only" + '</option><option value=1>' + "Interactive only" + '</option></select>');
272
+ x += '</div><hr>';
273
+ x += '<div id=agins_linux_inst style=display:none>' + "This is a executable on OS's with graphical user interfaces. You need to 'chmod +x meshagent' and run this file." + '<br /><br />';
274
+ x += addHtmlValue("Mesh Agent", '<a id=aginsbinlnk name="meshagents?id=' + meshid + '&installflags=0' + (urlargs.key?('&key=' + urlargs.key):'') + '">' + "meshagent" + '</a> <img src=images/link4.png height=10 width=10 title="' + "Copy agent URL to clipboard" + '" style=cursor:pointer onclick=copyAgentUrl("meshagents?id=' + meshid + '&installflags=",1)>');
275
+ x += addHtmlValue("Command", '<input id=aginsbincmd type=text style="width:216px" readonly value=\'wget -O meshagent ' + ((serverNoProxy != 0) ?'--no-proxy':'') + ' --no-check-certificate \"https://' + servername + portStr + domainUrl + 'meshagents?id=' + meshid.split('$').join('%24').split('@').join('%40') + '\' /> <img src=images/link4.png height=10 width=10 title="' + "Copy agent URL to clipboard" + '" style=cursor:pointer onclick=copyAgentIdValue("aginsbincmd")>');
276
+ x += '</div>';
277
+ QH('linuxbinarytab', x);
278
+ addAgentToMeshClick();
279
+ }
280
+
281
+ function addAgentToMeshClick() {
282
+ var v = Q('aginsSelect').value;
283
+ QV('agins_linux_un', v == 4);
284
+ QV('agins_linux_inst', v == 5);
285
+ QV('aginsSysTypeDiv', v == 5);
286
+ Q('aginsbinlnk').onclick = function() { downloadFile((Q('aginsbinlnk').name.split('installflags=')[0]) + 'installflags=' + Q('aginsType').value + (urlargs.key?('&key=' + urlargs.key):'') + '&meshinstall=' + Q('aginsSysType').value); };
287
+ Q('aginsbincmd').value = (Q('aginsbincmd').value.split('&installflags=')[0]) + '&installflags=' + Q('aginsType').value + (urlargs.key?('&key=' + urlargs.key):'') + '&meshinstall=' + Q('aginsSysType').value + '\"';
288
+ QV('aginsTypeDiv', (v == 0) || (v == 5));
289
+ QV('asinsTypeDiv', (v == 7));
290
+ }
291
+
292
// Create the QR code
293
new QRCode(Q('android_qrimage'), { text: magenturl, width: 220, height: 220, colorDark: '#000000', colorLight: '#FFF', correctLevel: QRCode.CorrectLevel.M });
294
Q('android_qrimage2').setAttribute('href', magenturl)
@@ -388,6 +431,9 @@
431
QH('linuxinstall', linuxInstall);
432
QH('unlinuxinstall', linuxUnInstall);
433
434
+ // Linux Binary Setup
435
+ linuxBinarySetup();
436
+
437
// MeshCentral Assistant
438
url = 'meshagents?id=10006&meshid=' + meshid + '&ac={{{assistanttype}}}';
439
Q('assisturl').href = url;
@@ -412,6 +458,30 @@
458
function format(format) { var args = Array.prototype.slice.call(arguments, 1); return format.replace(/{(\d+)}/g, function (match, number) { return typeof args[number] != 'undefined' ? args[number] : match; }); };
459
function escapeHtml(string) { return String(string).replace(/[&<>"'`=\/]/g, function (s) { return { '&': '&', '<': '<', '>': '>', '"': '"', "'": ''', '/': '/', '`': '`', '=': '=' }[s]; }); };
460
function escapeHtmlBreaks(string) { return String(string).replace(/[&<>"'`=\/]/g, function (s) { return { '&': '&', '<': '<', '>': '>', '"': '"', "'": ''', '/': '/', '`': '`', '=': '=', '\r': '<br />', '\n': '' }[s]; }); };
461
+ function addHtmlValue(t, v) { return '<table><td style=width:120px>' + t + '<td><b>' + v + '</b></table>'; }
462
+ function downloadFile(link, name, closeDialog) {
463
+ var element = document.createElement('a');
464
+ element.setAttribute('href', link);
465
+ element.setAttribute('rel', 'noreferrer noopener');
466
+ element.setAttribute('target', 'fileDownloadFrame');
467
+ element.setAttribute('download', decodeURIComponent(name?name:''));
468
+ document.body.appendChild(element);
469
+ element.click();
470
+ document.body.removeChild(element);
471
+ if (closeDialog) { setDialogMode(0); }
472
+ }
473
+ function copyAgentUrl(url,addflag) {
474
+ var servername = window.location.hostname;
475
+ if ((servername.indexOf('.') == -1)) { servername = window.location.hostname; } // If the server name is not set or it's in LAN-only mode, use the URL hostname as server name.
476
+ var portStr = (serverPort == 443) ? '' : (':' + serverPort);
477
+ var c = 'https://' + servername + portStr + domainUrl + url;
478
+ if (addflag == 1) c += Q('aginsType').value;
479
+ c += (urlargs.key?('&key=' + urlargs.key):'');
480
+ if (Q('aginsSelect').value == 5) { c += '&meshinstall=' + Q('aginsSysType').value; }
481
+ if (Q('aginsSelect').value == 7) { c += '&ac=' + Q('asinsType').value; }
482
+ copyTextToClip(c);
483
+ }
484
+ function copyAgentIdValue(id) { copyTextToClip(Q(id).value); }
485
</script>
486
</body>
487
</html>