From 997326b44f59d0334c563d10ee16181db7cafbcf Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Fri, 7 Jun 2019 16:44:00 -0700 Subject: [PATCH] Added backupconfig command in server console. --- db.js | 40 ++++++++++++++++++++++++++++++++++++ meshuser.js | 6 +++++- package.json | 2 +- sample-config.json | 3 +++ views/agentinvite.handlebars | 9 ++++---- 5 files changed, 54 insertions(+), 6 deletions(-) diff --git a/db.js b/db.js index 63f03d7b..dbb9c100 100644 --- a/db.js +++ b/db.js @@ -706,6 +706,46 @@ module.exports.CreateDB = function (parent, func) { func(obj); // Completed function setup } + // Return a human readable string with current backup configuration + obj.getBackupConfig = function () { + var r = '', backupPath = parent.backuppath; + if (parent.config.settings.autobackup && parent.config.settings.autobackup.backuppath) { backupPath = parent.config.settings.autobackup.backuppath; } + const dbname = (parent.args.mongodbname) ? (parent.args.mongodbname) : 'meshcentral'; + const currentDate = new Date(); + const fileSuffix = currentDate.getFullYear() + '-' + padNumber(currentDate.getMonth() + 1, 2) + '-' + padNumber(currentDate.getDate(), 2) + '-' + padNumber(currentDate.getHours(), 2) + '-' + padNumber(currentDate.getMinutes(), 2); + const newAutoBackupFile = 'meshcentral-autobackup-' + fileSuffix; + const newAutoBackupPath = parent.path.join(backupPath, newAutoBackupFile); + + r += 'DB Name: ' + dbname + '\r\n'; + r += 'DB Type: ' + ['None','NeDB','MongoJS','MongoDB'][obj.databaseType] + '\r\n'; + r += 'BackupPath: ' + backupPath + '\r\n'; + r += 'newAutoBackupFile: ' + newAutoBackupFile + '\r\n'; + r += 'newAutoBackupPath: ' + newAutoBackupPath + '\r\n'; + + if (parent.config.settings.autobackup == null) { + r += 'No Settings/AutoBackup\r\n'; + } else { + if (parent.config.settings.autobackup.backupintervalhours != null) { + if (typeof parent.config.settings.autobackup.backupintervalhours != 'number') { r += 'Bad backupintervalhours type\r\n'; } + else { r += 'Backup Interval (Hours): ' + parent.config.settings.autobackup.backupintervalhours + '\r\n'; } + } + if (parent.config.settings.autobackup.keeplastdaysbackup != null) { + if (typeof parent.config.settings.autobackup.keeplastdaysbackup != 'number') { r += 'Bad keeplastdaysbackup type\r\n'; } + else { r += 'Keep Last Backups (Days): ' + parent.config.settings.autobackup.keeplastdaysbackup + '\r\n'; } + } + if (parent.config.settings.autobackup.zippassword != null) { + if (typeof parent.config.settings.autobackup.zippassword != 'string') { r += 'Bad zippassword type\r\n'; } + else { r += 'ZIP Password Set\r\n'; } + } + if (parent.config.settings.autobackup.mongodumppath != null) { + if (typeof parent.config.settings.autobackup.mongodumppath != 'string') { r += 'Bad mongodumppath type\r\n'; } + else { r += 'MongoDump Path: ' + parent.config.settings.autobackup.mongodumppath + '\r\n'; } + } + } + + return r; + } + obj.performingBackup = false; obj.performBackup = function () { try { diff --git a/meshuser.js b/meshuser.js index 3e66fa0a..841232a1 100644 --- a/meshuser.js +++ b/meshuser.js @@ -546,7 +546,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use 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,\r\n'; - r += 'heapdump, relays, autobackup, dupagents.'; + r += 'heapdump, relays, autobackup, backupconfig, dupagents.'; break; } case 'dupagents': { @@ -737,6 +737,10 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use if (backupResult == 0) { r = 'Starting auto-backup...'; } else { r = 'Backup alreay in progress.'; } break; } + case 'backupconfig': { + r = parent.db.getBackupConfig(); + 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/package.json b/package.json index da564b90..57177556 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "meshcentral", - "version": "0.3.6-g", + "version": "0.3.6-h", "keywords": [ "Remote Management", "Intel AMT", diff --git a/sample-config.json b/sample-config.json index eb613044..4d15a9dd 100644 --- a/sample-config.json +++ b/sample-config.json @@ -81,6 +81,9 @@ "_MaxAgentSessions": 100, "MaxSingleUserSessions": 10 }, + "_Redirects": { + "meshcommander": "https://www.meshcommander.com/" + }, "_yubikey": { "id": "0000", "secret": "xxxxxxxxxxxxxxxxxxxxx", "_proxy": "http://myproxy.domain.com:80" }, "_httpheaders": { "Strict-Transport-Security": "max-age=360000" }, "_agentConfig": [ "webSocketMaskOverride=1" ] diff --git a/views/agentinvite.handlebars b/views/agentinvite.handlebars index 6ddcd984..b759296d 100644 --- a/views/agentinvite.handlebars +++ b/views/agentinvite.handlebars @@ -40,6 +40,7 @@ border: 1px solid #ccc; border-top: none; } + @@ -69,7 +70,7 @@
-

Agent Installation

+

Remote Agent Installation

You have been invited to install a software that will allow a remote operator to fully access your computer remotely including the desktop and files. Only follow the instructions below if this invitation was expected and you know who will be accessing your computer. @@ -87,7 +88,7 @@

Microsoft™ Windows 64bit

Download the software here, run it and press "Install" or "Connect".

- +
@@ -95,7 +96,7 @@

Microsoft™ Windows 32bit

Download the software here, run it and press "Install" or "Connect".

- +
@@ -142,7 +143,7 @@ var serverNoProxy = "{{{servernoproxy}}}"; var installFlags = "{{{installflags}}}"; var groupName = decodeURIComponent("{{{meshname}}}"); - if (groupName != '') { QH('groupname', ' - ' + groupName); } + if (groupName != '') { QH('groupname', ' for ' + groupName); } userInterfaceSelectMenu(); setup();