diff --git a/meshctrl.js b/meshctrl.js index 26b57101..133c3545 100644 --- a/meshctrl.js +++ b/meshctrl.js @@ -111,18 +111,7 @@ if (args['_'].length == 0) { } else { switch (args['_'][1].toLowerCase()) { case 'config': { - console.log("Perform operations on the config.json file. Example usage:\r\n"); - console.log(" MeshCtrl config --show"); - console.log("\r\nOptional arguments:\r\n"); - console.log(" --show - Display the config.json file."); - console.log(" --adddomain [domain] - Add a domain."); - console.log(" --removedomain [domain] - Remove a domain."); - console.log(" --settodomain [domain] - Set values to the domain."); - console.log(" --removefromdomain [domain] - Remove values from the domain."); - console.log("\r\nWith adddomain, removedomain, settodomain and removefromdomain you can add the key and value pair. For example:\r\n"); - console.log(" --adddomain \"MyDomain\" --title \"My Server Name\" --newAccounts false"); - console.log(" --settodomain \"MyDomain\" --title \"My Server Name\""); - console.log(" --removefromdomain \"MyDomain\" --title"); + displayConfigHelp(); break; } case 'sendinviteemail': { @@ -297,12 +286,29 @@ if (args['_'].length == 0) { if (ok) { serverConnect(); } } +function displayConfigHelp() { + console.log("Perform operations on the config.json file. Example usage:\r\n"); + console.log(" MeshCtrl config --show"); + console.log("\r\nOptional arguments:\r\n"); + console.log(" --show - Display the config.json file."); + console.log(" --listdomains - Display non-default domains."); + console.log(" --adddomain [domain] - Add a domain."); + console.log(" --removedomain [domain] - Remove a domain."); + console.log(" --settodomain [domain] - Set values to the domain."); + console.log(" --removefromdomain [domain] - Remove values from the domain."); + console.log("\r\nWith adddomain, removedomain, settodomain and removefromdomain you can add the key and value pair. For example:\r\n"); + console.log(" --adddomain \"MyDomain\" --title \"My Server Name\" --newAccounts false"); + console.log(" --settodomain \"MyDomain\" --title \"My Server Name\""); + console.log(" --removefromdomain \"MyDomain\" --title"); +} + function performConfigOperations(args) { var domainValues = ['title', 'title2', 'titlepicture', 'trustedcert', 'welcomepicture', 'welcometext', 'userquota', 'meshquota', 'newaccounts', 'usernameisemail', 'newaccountemaildomains', 'newaccountspass', 'newaccountsrights', 'geolocation', 'lockagentdownload', 'userconsentflags', 'Usersessionidletimeout', 'auth', 'ldapoptions', 'ldapusername', 'ldapuserbinarykey', 'ldapoptions', 'footer', 'certurl', 'loginKey', 'userallowedip', 'agentallowedip', 'agentnoproxy', 'agentconfig', 'orphanagentuser', 'httpheaders', 'yubikey', 'passwordrequirements', 'limits', 'amtacmactivation', 'redirects', 'sessionrecording']; var configChange = false; var fs = require('fs'); var path = require('path'); var configFile = path.join(__dirname, 'config.json'); + var didSomething = 0; if (fs.existsSync(configFile) == false) { configFile = path.join('meshcentral-data', 'config.json'); } if (fs.existsSync(configFile) == false) { configFile = path.join(__dirname, 'meshcentral-data', 'config.json'); } if (fs.existsSync(configFile) == false) { configFile = path.join(__dirname, '..', 'meshcentral-data', 'config.json'); } @@ -311,6 +317,7 @@ function performConfigOperations(args) { try { config = fs.readFileSync(configFile); } catch (ex) { console.log("Error: Unable to read config.json"); return; } try { config = JSON.parse(config); } catch (ex) { console.log("Error: Unable to parse config.json"); return; } if (args.adddomain != null) { + didSomething++; if (config.domains == null) { config.domains = {}; } if (config.domains[args.adddomain] != null) { console.log("Error: Domain \"" + args.adddomain + "\" already exists"); } else { @@ -326,11 +333,13 @@ function performConfigOperations(args) { } } if (args.removedomain != null) { + didSomething++; if (config.domains == null) { config.domains = {}; } if (config.domains[args.removedomain] == null) { console.log("Error: Domain \"" + args.removedomain + "\" does not exist"); } else { delete config.domains[args.removedomain]; configChange = true; } } if (args.settodomain != null) { + didSomething++; if (config.domains == null) { config.domains = {}; } if (config.domains[args.settodomain] == null) { console.log("Error: Domain \"" + args.settodomain + "\" does not exist"); } else { @@ -346,15 +355,30 @@ function performConfigOperations(args) { } } if (args.removefromdomain != null) { + didSomething++; if (config.domains == null) { config.domains = {}; } if (config.domains[args.removefromdomain] == null) { console.log("Error: Domain \"" + args.removefromdomain + "\" does not exist"); } else { for (var i in args) { if (domainValues.indexOf(i.toLowerCase()) >= 0) { delete config.domains[args.removefromdomain][i]; configChange = true; } } } } - if (args.show == 1) { console.log(JSON.stringify(config, null, 2)); } else { console.log("Done."); } if (configChange) { try { fs.writeFileSync(configFile, JSON.stringify(config, null, 2)); } catch (ex) { console.log("Error: Unable to read config.json"); return; } } - //console.log(configFile); + if (args.show == 1) { + console.log(JSON.stringify(config, null, 2)); return; + } else if (args.listdomains == 1) { + if (config.domains == null) { + console.log('No domains found.'); return; + } else { + // Show the list of active domains, skip the default one. + for (var i in config.domains) { if ((i != '') && (i[0] != '_')) { console.log(i); } } return; + } + } else { + if (didSomething == 0) { + displayConfigHelp(); + } else { + console.log("Done.", didSomething); + } + } } function onVerifyServer(clientName, certs) { return null; } diff --git a/package.json b/package.json index a5b8aac1..429452da 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "meshcentral", - "version": "0.4.6-e", + "version": "0.4.6-f", "keywords": [ "Remote Management", "Intel AMT", diff --git a/views/default-min.handlebars b/views/default-min.handlebars index fcbae720..2e15359d 100644 --- a/views/default-min.handlebars +++ b/views/default-min.handlebars @@ -1860,11 +1860,13 @@ } if (r != '') { + r += ''; if (view == 2) { // This height of 1 div at the end to fix a problem in Linux firefox browsers r = '
' + "User" + '' + "Address" + '' + "Connectivity" + r + '
'; //State'; } } else { + r += ''; if (sort == 3) { r = '
' + "No devices with tags found." + '
'; } } diff --git a/views/default.handlebars b/views/default.handlebars index 64189611..ceb1b953 100644 --- a/views/default.handlebars +++ b/views/default.handlebars @@ -2913,11 +2913,13 @@ } if (r != '') { + r += ''; if (view == 2) { // This height of 1 div at the end to fix a problem in Linux firefox browsers r = '
' + "User" + '' + "Address" + '' + "Connectivity" + r + '
'; //State'; } } else { + r += ''; if (sort == 3) { r = '
' + "No devices with tags found." + '
'; } } diff --git a/views/translations/default-min_cs.handlebars b/views/translations/default-min_cs.handlebars index 18c89524..c9d16ee4 100644 --- a/views/translations/default-min_cs.handlebars +++ b/views/translations/default-min_cs.handlebars @@ -1860,11 +1860,13 @@ } if (r != '') { + r += ''; if (view == 2) { // This height of 1 div at the end to fix a problem in Linux firefox browsers r = '
' + "Uživatel" + '' + "Adresa" + '' + "Konektivita" + r + '
'; //State'; } } else { + r += ''; if (sort == 3) { r = '
' + "No devices with tags found." + '
'; } } diff --git a/views/translations/default-min_fr.handlebars b/views/translations/default-min_fr.handlebars index 8030f8e3..32596755 100644 --- a/views/translations/default-min_fr.handlebars +++ b/views/translations/default-min_fr.handlebars @@ -1860,11 +1860,13 @@ } if (r != '') { + r += ''; if (view == 2) { // This height of 1 div at the end to fix a problem in Linux firefox browsers r = '
' + "Utilisateur" + '' + "Address" + '' + "Connectivity" + r + '
'; //State'; } } else { + r += ''; if (sort == 3) { r = '
' + "No devices with tags found." + '
'; } } diff --git a/views/translations/default-min_ja.handlebars b/views/translations/default-min_ja.handlebars index 1fa0b31a..a1f74529 100644 --- a/views/translations/default-min_ja.handlebars +++ b/views/translations/default-min_ja.handlebars @@ -1860,11 +1860,13 @@ } if (r != '') { + r += ''; if (view == 2) { // This height of 1 div at the end to fix a problem in Linux firefox browsers r = '
' + "ユーザー" + '' + "住所" + '' + "接続性" + r + '
'; //State'; } } else { + r += ''; if (sort == 3) { r = '
' + "No devices with tags found." + '
'; } } diff --git a/views/translations/default-min_nl.handlebars b/views/translations/default-min_nl.handlebars index f09cafbd..aea93332 100644 --- a/views/translations/default-min_nl.handlebars +++ b/views/translations/default-min_nl.handlebars @@ -1860,11 +1860,13 @@ } if (r != '') { + r += ''; if (view == 2) { // This height of 1 div at the end to fix a problem in Linux firefox browsers r = '
' + "Gebruiker" + '' + "Adres" + '' + "connectiviteit" + r + '
'; //State'; } } else { + r += ''; if (sort == 3) { r = '
' + "No devices with tags found." + '
'; } } diff --git a/views/translations/default-min_pt.handlebars b/views/translations/default-min_pt.handlebars index 264b9571..3b107896 100644 --- a/views/translations/default-min_pt.handlebars +++ b/views/translations/default-min_pt.handlebars @@ -1860,11 +1860,13 @@ } if (r != '') { + r += ''; if (view == 2) { // This height of 1 div at the end to fix a problem in Linux firefox browsers r = '
' + "Do utilizador" + '' + "Endereço" + '' + "Conectividade" + r + '
'; //State'; } } else { + r += ''; if (sort == 3) { r = '
' + "No devices with tags found." + '
'; } } diff --git a/views/translations/default_cs.handlebars b/views/translations/default_cs.handlebars index e2bb0c47..8288e664 100644 --- a/views/translations/default_cs.handlebars +++ b/views/translations/default_cs.handlebars @@ -2911,11 +2911,13 @@ } if (r != '') { + r += ''; if (view == 2) { // This height of 1 div at the end to fix a problem in Linux firefox browsers r = '
' + "Uživatel" + '' + "Adresa" + '' + "Konektivita" + r + '
'; //State'; } } else { + r += ''; if (sort == 3) { r = '
' + "No devices with tags found." + '
'; } } diff --git a/views/translations/default_fr.handlebars b/views/translations/default_fr.handlebars index 1aaac44d..49310d09 100644 --- a/views/translations/default_fr.handlebars +++ b/views/translations/default_fr.handlebars @@ -2911,11 +2911,13 @@ } if (r != '') { + r += ''; if (view == 2) { // This height of 1 div at the end to fix a problem in Linux firefox browsers r = '
' + "Utilisateur" + '' + "Address" + '' + "Connectivity" + r + '
'; //State'; } } else { + r += ''; if (sort == 3) { r = '
' + "No devices with tags found." + '
'; } } diff --git a/views/translations/default_ja.handlebars b/views/translations/default_ja.handlebars index fb379285..3066862d 100644 --- a/views/translations/default_ja.handlebars +++ b/views/translations/default_ja.handlebars @@ -2911,11 +2911,13 @@ } if (r != '') { + r += ''; if (view == 2) { // This height of 1 div at the end to fix a problem in Linux firefox browsers r = '
' + "ユーザー" + '' + "住所" + '' + "接続性" + r + '
'; //State'; } } else { + r += ''; if (sort == 3) { r = '
' + "No devices with tags found." + '
'; } } diff --git a/views/translations/default_nl.handlebars b/views/translations/default_nl.handlebars index 334bab74..b467080f 100644 --- a/views/translations/default_nl.handlebars +++ b/views/translations/default_nl.handlebars @@ -2911,11 +2911,13 @@ } if (r != '') { + r += ''; if (view == 2) { // This height of 1 div at the end to fix a problem in Linux firefox browsers r = '
' + "Gebruiker" + '' + "Adres" + '' + "connectiviteit" + r + '
'; //State'; } } else { + r += ''; if (sort == 3) { r = '
' + "No devices with tags found." + '
'; } } diff --git a/views/translations/default_pt.handlebars b/views/translations/default_pt.handlebars index 96be6a9c..b4f89e85 100644 --- a/views/translations/default_pt.handlebars +++ b/views/translations/default_pt.handlebars @@ -2911,11 +2911,13 @@ } if (r != '') { + r += ''; if (view == 2) { // This height of 1 div at the end to fix a problem in Linux firefox browsers r = '
' + "Do utilizador" + '' + "Endereço" + '' + "Conectividade" + r + '
'; //State'; } } else { + r += ''; if (sort == 3) { r = '
' + "No devices with tags found." + '
'; } }