More Linux interactive installer improvements.

This commit is contained in:
Ylian Saint-Hilaire 2020-09-14 15:34:55 -07:00
parent 2cd930b2dc
commit abe862153e
3 changed files with 57 additions and 44 deletions

View File

@ -573,6 +573,7 @@
<Content Include="views\login-mobile.handlebars" />
<Content Include="views\login.handlebars" />
<Content Include="views\message.handlebars" />
<Content Include="views\message2.handlebars" />
<Content Include="views\messenger.handlebars" />
<Content Include="views\mstsc.handlebars" />
<Content Include="views\player.handlebars" />

View File

@ -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(); }
}
}

View File

@ -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 += '<option value=' + i + '>' + binaryInstallAgents[i] + '</option>' }
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 += '<option value=' + binaryInstallAgentsOrder[i] + '>' + binaryInstallAgents[binaryInstallAgentsOrder[i]] + '</option>' }
x += '<div id=aginsSysTypeDiv>';
x += addHtmlValue("System Type", '<select id=aginsSysType onchange=addAgentToMeshClick() style=width:236px>' + moreoptions + '</select>');
x += '</div>';
@ -4216,7 +4217,7 @@
// Linux binary installer
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 />';
x += addHtmlValue("Mesh Agent", '<a id=aginsbinlnk href="meshagents?id=' + meshid.split('/')[2] + '&installflags=0' + (urlargs.key?('&key=' + urlargs.key):'') + '" download onclick="setDialogMode(0)">' + "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.split('/')[2] + '&installflags=",1)>');
x += addHtmlValue("Command", '<input id=aginsbincmd type=text style="width:216px" readonly value=\'wget -O meshagent' + (((features & 0x80000000) != 0)?' --no-check-certificate':'') + ' \"https://' + servername + portStr + domainUrl + 'meshagents?id=' + meshid.split('/')[2] + '\' /> <img src=images/link4.png height=10 width=10 title="' + "Copy agent URL to clipboard" + '" style=cursor:pointer onclick=copyAgentIdValue("aginsbincmd")>');
x += addHtmlValue("Command", '<input id=aginsbincmd type=text style="width:216px" readonly value=\'wget -O meshagent' + (((features & 0x80000000) != 0)?' --no-check-certificate':'') + ' \"https://' + servername + portStr + domainUrl + 'meshagents?id=' + meshid.split('/')[2].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")>');
x += '</div>';
setDialogMode(2, "Add Mesh Agent", 2, null, x, 'fileDownload');