From abe862153ec9b84aeea56a017e98498f4c375a90 Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Mon, 14 Sep 2020 15:34:55 -0700 Subject: [PATCH] More Linux interactive installer improvements. --- MeshCentralServer.njsproj | 1 + agents/meshinstall-linux.js | 93 +++++++++++++++++++++---------------- views/default.handlebars | 7 +-- 3 files changed, 57 insertions(+), 44 deletions(-) diff --git a/MeshCentralServer.njsproj b/MeshCentralServer.njsproj index 93f8c626..37271d96 100644 --- a/MeshCentralServer.njsproj +++ b/MeshCentralServer.njsproj @@ -573,6 +573,7 @@ + diff --git a/agents/meshinstall-linux.js b/agents/meshinstall-linux.js index 5aa37c9a..1f67e2e4 100644 --- a/agents/meshinstall-linux.js +++ b/agents/meshinstall-linux.js @@ -55,15 +55,41 @@ if (msh.InstallFlags == null) { msh.InstallFlags = parseInt(msh.InstallFlags.toString()); } -if ((msh.InstallFlags & 1) == 1) { buttons.unshift('Connect'); } -if ((msh.InstallFlags & 2) == 2) { +if (process.argv.includes('-mesh')) { + console.log(JSON.stringify(msh, null, 2)); + process.exit(); +} + +if ((msh.InstallFlags & 1) == 1) { + buttons.unshift('Connect'); + if (process.argv.includes('-connect')) { + global._child = require('child_process').execFile(process.execPath, + [process.execPath.split('/').pop(), '--no-embedded=1', '--disableUpdate=1', + '--MeshName="' + msh.MeshName + '"', '--MeshType="' + msh.MeshType + '"', + '--MeshID="' + msh.MeshID + '"', + '--ServerID="' + msh.ServerID + '"', + '--MeshServer="' + msh.MeshServer + '"', + '--AgentCapabilities="0x00000020"']); + + global._child.stdout.on('data', function (c) { }); + global._child.stderr.on('data', function (c) { }); + global._child.on('exit', function (code) { process.exit(code); }); + + console.log("\nConnecting to: " + msh.MeshServer); + console.log("Device Group: " + msh.MeshName); + console.log('\nPress Ctrl-C to exit\n'); + skip = true; + } +} + +if ((!skip) && ((msh.InstallFlags & 2) == 2)) { if (!require('user-sessions').isRoot()) { console.log('\n' + "Elevated permissions is required to install/uninstall the agent."); console.log("Please try again with sudo."); process.exit(); } if (s) { - if (process.platform == 'darwin' || require('message-box').kdialog) { + if ((process.platform == 'darwin') || require('message-box').kdialog) { buttons.unshift("Setup"); } else { buttons.unshift("Uninstall"); @@ -74,8 +100,8 @@ if ((msh.InstallFlags & 2) == 2) { } } -if (process.platform != 'darwin') { - if (!require('message-box').kdialog && (require('message-box').zenity == null || (!require('message-box').zenity.extra))) { +if (!skip) { + if (process.platform != 'darwin') { if (process.argv.includes('-install') || process.argv.includes('-update')) { var p = []; for (var i = 0; i < process.argv.length; ++i) { @@ -90,47 +116,32 @@ if (process.platform != 'darwin') { _uninstall(); process.exit(); } - else if (process.argv.includes('-connect')) { - global._child = require('child_process').execFile(process.execPath, - [process.execPath.split('/').pop(), '--no-embedded=1', '--disableUpdate=1', - '--MeshName="' + msh.MeshName + '"', '--MeshType="' + msh.MeshType + '"', - '--MeshID="' + msh.MeshID + '"', - '--ServerID="' + msh.ServerID + '"', - '--MeshServer="' + msh.MeshServer + '"', - '--AgentCapabilities="0x00000020"']); - - global._child.stdout.on('data', function (c) { }); - global._child.stderr.on('data', function (c) { }); - global._child.on('exit', function (code) { process.exit(code); }); - - console.log("\nConnecting to: " + msh.MeshServer); - console.log("Device Group: " + msh.MeshName); - console.log('\nPress Ctrl-c to exit\n'); - skip = true; - } else { - console.log('\n' + "The graphical version of this installer cannot run on this system."); - console.log("Try installing/updating Zenity, and run again." + '\n'); - console.log("You can also run the text version from the command line with the following command(s): "); - if ((msh.InstallFlags & 1) == 1) { - console.log('./' + process.execPath.split('/').pop() + ' -connect'); - } - if ((msh.InstallFlags & 2) == 2) { - if (s) { - console.log('./' + process.execPath.split('/').pop() + ' -update'); - console.log('./' + process.execPath.split('/').pop() + ' -uninstall'); + else { + if (!require('message-box').kdialog && ((require('message-box').zenity == null) || (!require('message-box').zenity.extra))) { + console.log('\n' + "The graphical version of this installer cannot run on this system."); + console.log("Try installing/updating Zenity, and run again." + '\n'); + console.log("You can also run the text version from the command line with the following command(s): "); + if ((msh.InstallFlags & 1) == 1) { + console.log('./' + process.execPath.split('/').pop() + ' -connect'); } - else { - console.log('./' + process.execPath.split('/').pop() + ' -install'); - console.log('./' + process.execPath.split('/').pop() + ' -install --installPath="/alternate/path"'); + if ((msh.InstallFlags & 2) == 2) { + if (s) { + console.log('./' + process.execPath.split('/').pop() + ' -update'); + console.log('./' + process.execPath.split('/').pop() + ' -uninstall'); + } + else { + console.log('./' + process.execPath.split('/').pop() + ' -install'); + console.log('./' + process.execPath.split('/').pop() + ' -install --installPath="/alternate/path"'); + } } + console.log(''); + process.exit(); } - console.log(''); - process.exit(); } } -} -else { - if (!require('user-sessions').isRoot()) { console.log('\n' + "This utility requires elevated permissions. Please try again with sudo."); process.exit(); } + else { + if (!require('user-sessions').isRoot()) { console.log('\n' + "This utility requires elevated permissions. Please try again with sudo."); process.exit(); } + } } diff --git a/views/default.handlebars b/views/default.handlebars index ec6729a7..b81ccfb3 100644 --- a/views/default.handlebars +++ b/views/default.handlebars @@ -4170,8 +4170,9 @@ if (serverinfo.https == true) { portStr = (serverinfo.port == 443)?'':(':' + serverinfo.port); } else { portStr = (serverinfo.port == 80) ? '' : (':' + serverinfo.port); } // Add Linux/macOS binary installer option - var binaryInstallAgents = { 6 : 'Linux x86-64', 5 : 'Linux x86-32', 16 : 'Apple OSX x86-64', 25 : 'Linux ARM-HF, Rasberry Pi', 26 : 'Linux ARM64-HF', 28: 'Linux MIPS24KC (OpenWRT)', 30 : 'FreeBSD x86-64' }; - for (var i in binaryInstallAgents) { moreoptions += '' } + var binaryInstallAgentsOrder = [ 6, 5 ,16 ,25 ,26 ,28 ,30 ]; + var binaryInstallAgents = { 5 : 'Linux x86-32', 6 : 'Linux x86-64', 16 : 'Apple OSX x86-64', 25 : 'Linux ARM-HF, Rasberry Pi', 26 : 'Linux ARM64-HF', 28: 'Linux MIPS24KC (OpenWRT)', 30 : 'FreeBSD x86-64' }; + for (var i in binaryInstallAgentsOrder) { moreoptions += '' } x += '
'; x += addHtmlValue("System Type", ''); x += '
'; @@ -4216,7 +4217,7 @@ // Linux binary installer x += ''; setDialogMode(2, "Add Mesh Agent", 2, null, x, 'fileDownload');