diff --git a/db.js b/db.js
index 07f6eae9..19177b9e 100644
--- a/db.js
+++ b/db.js
@@ -668,8 +668,11 @@ module.exports.CreateDB = function (parent, func) {
func(obj); // Completed function setup
}
+ obj.performingBackup = false;
obj.performBackup = function () {
- console.log('Performing backup...');
+ if (obj.performingBackup) return 1;
+ obj.performingBackup = true;
+ //console.log('Performing backup...');
try { obj.parent.fs.mkdirSync(obj.parent.backuppath); } catch (e) { }
const dbname = (obj.parent.args.mongodbname) ? (obj.parent.args.mongodbname) : 'meshcentral';
const currentDate = new Date();
@@ -687,7 +690,7 @@ module.exports.CreateDB = function (parent, func) {
const cmd = mongoDumpPath + ' --db \"' + dbname + '\" --archive=\"' + newBackupPath + '.archive\"';
var backupProcess = child_process.exec(cmd, { cwd: obj.parent.backuppath }, function (error, stdout, stderr) {
backupProcess = null;
- if ((error != null) && (error != '')) { console.log('ERROR: Unable to perform database backup.\r\n'); return; }
+ if ((error != null) && (error != '')) { console.log('ERROR: Unable to perform database backup.\r\n'); obj.performingBackup = false; return; }
// Perform archive compression
var archiver = require('archiver');
@@ -699,7 +702,7 @@ module.exports.CreateDB = function (parent, func) {
} else {
archive = archiver('zip', { zlib: { level: 9 } });
}
- output.on('close', function () { setTimeout(function () { try { obj.parent.fs.unlink(newBackupPath + '.archive'); } catch (ex) { } }, 5000); });
+ output.on('close', function () { obj.performingBackup = false; setTimeout(function () { try { obj.parent.fs.unlink(newBackupPath + '.archive'); } catch (ex) { console.log(ex); } }, 5000); });
output.on('end', function () { });
archive.on('warning', function (err) { console.log('Backup warning: ' + err); });
archive.on('error', function (err) { console.log('Backup error: ' + err); });
@@ -719,7 +722,7 @@ module.exports.CreateDB = function (parent, func) {
} else {
archive = archiver('zip', { zlib: { level: 9 } });
}
- output.on('close', function () { });
+ output.on('close', function () { obj.performingBackup = false; });
output.on('end', function () { });
archive.on('warning', function (err) { console.log('Backup warning: ' + err); });
archive.on('error', function (err) { console.log('Backup error: ' + err); });
@@ -747,6 +750,8 @@ module.exports.CreateDB = function (parent, func) {
}
});
}
+
+ return 0;
}
function padNumber(number, digits) { return Array(Math.max(digits - String(number).length + 1, 0)).join(0) + number; }
diff --git a/meshcentral.js b/meshcentral.js
index 4f4237c5..8d84c4cc 100644
--- a/meshcentral.js
+++ b/meshcentral.js
@@ -1707,12 +1707,15 @@ process.on('SIGINT', function () { if (meshserver != null) { meshserver.Stop();
// Load the really basic modules
var meshserver = null;
var previouslyInstalledModules = { };
-function mainStart(args) {
+function mainStart() {
// Check the NodeJS is version 6 or better.
if (Number(process.version.match(/^v(\d+\.\d+)/)[1]) < 6) { console.log("MeshCentral requires Node v6.x or above, current version is " + process.version + "."); return; }
// Check for any missing modules.
InstallModules(['minimist'], function () {
+ // Parse inbound arguments
+ var args = require('minimist')(process.argv.slice(2));
+
// Get the server configuration
var config = getConfig(false);
if (config == null) { process.exit(); }
@@ -1764,7 +1767,7 @@ function mainStart(args) {
}
if (require.main === module) {
- mainStart(require('minimist')(process.argv.slice(2))); // Called directly, launch normally.
+ mainStart(); // Called directly, launch normally.
} else {
module.exports.mainStart = mainStart; // Required as a module, useful for winservice.js
}
diff --git a/meshuser.js b/meshuser.js
index cf2936ae..8e7720e2 100644
--- a/meshuser.js
+++ b/meshuser.js
@@ -524,7 +524,8 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
switch (cmd) {
case 'help': {
r = 'Available commands: help, info, versions, args, resetserver, showconfig, usersessions, tasklimiter, setmaxtasks, cores,\r\n'
- r += 'migrationagents, agentstats, webstats, mpsstats, swarmstats, acceleratorsstats, updatecheck, serverupdate, nodeconfig, heapdump, relays.';
+ r += 'migrationagents, agentstats, webstats, mpsstats, swarmstats, acceleratorsstats, updatecheck, serverupdate, nodeconfig,\r\n';
+ r += 'heapdump, relays, autobackup.';
break;
}
case 'agentstats': {
@@ -703,6 +704,11 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
if (r == '') { r = 'No relays.'; }
break;
}
+ case 'autobackup': {
+ var backupResult = parent.db.performBackup();
+ if (backupResult == 0) { r = 'Starting auto-backup...'; } else { r = 'Backup alreay in progress.'; }
+ break;
+ }
default: { // This is an unknown command, return an error message
r = 'Unknown command \"' + cmd + '\", type \"help\" for list of avaialble commands.';
break;
diff --git a/views/default.handlebars b/views/default.handlebars
index fc08c32d..6c34e1f9 100644
--- a/views/default.handlebars
+++ b/views/default.handlebars
@@ -6051,19 +6051,21 @@
x += addHtmlValue('Features', addLinkConditional(meshFeatures, 'p20editmeshfeatures()', meshrights & 1));
// Display user consent
- meshFeatures = [];
- var consent = 0;
- if (currentMesh.consent) { consent = currentMesh.consent; }
- if (serverinfo.consent) { consent |= serverinfo.consent; }
- if (consent & 0x0008) { meshFeatures.push('Desktop Prompt'); } else { if (consent & 0x0001) { meshFeatures.push('Desktop Notify'); } }
- if (consent & 0x0010) { meshFeatures.push('Terminal Prompt'); } else { if (consent & 0x0002) { meshFeatures.push('Terminal Notify'); } }
- if (consent & 0x0020) { meshFeatures.push('Files Prompt'); } else { if (consent & 0x0004) { meshFeatures.push('Files Notify'); } }
- //if ((consent & 7) == 7) { meshFeatures.push('Always Notify'); } else if ((currentMesh.consent & 7) != 0) { meshFeatures.push('Notify Sometimes'); }
- //if ((consent & 56) == 56) { meshFeatures.push('Always Blink Border'); } else if ((currentMesh.consent & 56) != 0) { meshFeatures.push('Blick Border Sometimes'); }
+ if (currentMesh.mtype == 2) {
+ meshFeatures = [];
+ var consent = 0;
+ if (currentMesh.consent) { consent = currentMesh.consent; }
+ if (serverinfo.consent) { consent |= serverinfo.consent; }
+ if (consent & 0x0008) { meshFeatures.push('Desktop Prompt'); } else { if (consent & 0x0001) { meshFeatures.push('Desktop Notify'); } }
+ if (consent & 0x0010) { meshFeatures.push('Terminal Prompt'); } else { if (consent & 0x0002) { meshFeatures.push('Terminal Notify'); } }
+ if (consent & 0x0020) { meshFeatures.push('Files Prompt'); } else { if (consent & 0x0004) { meshFeatures.push('Files Notify'); } }
+ if (consent == 7) { meshFeatures = ['Always Notify']; }
+ if ((consent & 56) == 56) { meshFeatures = ['Always Prompt']; }
- meshFeatures = meshFeatures.join(', ');
- if (meshFeatures == '') { meshFeatures = 'None'; }
- x += addHtmlValue('User Consent', addLinkConditional(meshFeatures, 'p20editmeshconsent()', meshrights & 1));
+ meshFeatures = meshFeatures.join(', ');
+ if (meshFeatures == '') { meshFeatures = 'None'; }
+ x += addHtmlValue('User Consent', addLinkConditional(meshFeatures, 'p20editmeshconsent()', meshrights & 1));
+ }
// Intel AMT setup
if (currentMesh.mtype == 2) {