mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-12-25 15:03:25 +03:00
Fixed web site no localstorage, MongoDB backup with URL.
This commit is contained in:
parent
e9ebb8aa20
commit
90b060016c
@ -1230,7 +1230,7 @@ function createMeshCore(agent) {
|
||||
var bash = fs.existsSync('/bin/bash') ? '/bin/bash' : false;
|
||||
var sh = fs.existsSync('/bin/sh') ? '/bin/sh' : false;
|
||||
var script = false;
|
||||
if (this.httprequest.xoptions.script)
|
||||
if (this.httprequest.xoptions && this.httprequest.xoptions.script)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -1244,7 +1244,7 @@ function createMeshCore(agent) {
|
||||
}
|
||||
} catch (ex) { }
|
||||
}
|
||||
var python = (this.httprequest.xoptions.python && fs.existsSync('/usr/bin/python')) ? '/usr/bin/python' : false;
|
||||
var python = (this.httprequest.xoptions && this.httprequest.xoptions.python && fs.existsSync('/usr/bin/python')) ? '/usr/bin/python' : false;
|
||||
var shell = bash || sh;
|
||||
|
||||
var env = { HISTCONTROL: 'ignoreboth', TERM: 'xterm' };
|
||||
|
4
db.js
4
db.js
@ -973,6 +973,7 @@ module.exports.CreateDB = function (parent, func) {
|
||||
if (parent.config.settings.autobackup && parent.config.settings.autobackup.backuppath) { backupPath = parent.config.settings.autobackup.backuppath; }
|
||||
try { parent.fs.mkdirSync(backupPath); } catch (e) { }
|
||||
const dbname = (parent.args.mongodbname) ? (parent.args.mongodbname) : 'meshcentral';
|
||||
const dburl = parent.args.mongodb;
|
||||
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;
|
||||
@ -985,7 +986,8 @@ module.exports.CreateDB = function (parent, func) {
|
||||
var mongoDumpPath = 'mongodump';
|
||||
if (parent.config.settings.autobackup && parent.config.settings.autobackup.mongodumppath) { mongoDumpPath = parent.config.settings.autobackup.mongodumppath; }
|
||||
const child_process = require('child_process');
|
||||
const cmd = '\"' + mongoDumpPath + '\" --db \"' + dbname + '\" --archive=\"' + newBackupPath + '.archive\"';
|
||||
const cmd = '\"' + mongoDumpPath + '\" --db=\"' + dbname + '\" --archive=\"' + newBackupPath + '.archive\"';
|
||||
if (dburl) { cmd = '\"' + mongoDumpPath + '\" --url=\"' + dburl + '\" --db=\"' + dbname + '\" --archive=\"' + newBackupPath + '.archive\"'; }
|
||||
var backupProcess = child_process.exec(cmd, { cwd: backupPath }, function (error, stdout, stderr) {
|
||||
try {
|
||||
backupProcess = null;
|
||||
|
@ -1114,7 +1114,7 @@
|
||||
var webState = '{{{webstate}}}';
|
||||
if (webState != '') { webState = JSON.parse(decodeURIComponent(webState)); }
|
||||
for (var i in webState) { localStorage.setItem(i, webState[i]); }
|
||||
if (!webState.loctag) { delete localStorage.removeItem('loctag'); }
|
||||
if (!webState.loctag) { try { delete localStorage.removeItem('loctag'); } catch (ex) { } }
|
||||
|
||||
var args;
|
||||
var autoReconnect = true;
|
||||
@ -1221,6 +1221,7 @@
|
||||
|
||||
// Setup logout control
|
||||
var logoutControl = '';
|
||||
if (logoutControls)
|
||||
if (logoutControls.name != null) { logoutControl = format("Welcome {0}.", logoutControls.name); }
|
||||
if (logoutControls.logoutUrl != null) { logoutControl += format(' <a href=\"' + logoutControls.logoutUrl + '\" style="color:white">' + "Logout" + '</a>'); }
|
||||
if (args.hide & 1) { QH('logoutControlSpan2', logoutControl); } else { QH('logoutControlSpan', logoutControl); }
|
||||
@ -1274,9 +1275,11 @@
|
||||
setInterval(updateDeviceTimeline, 120000); // Check every 2 minutes
|
||||
|
||||
// Load desktop settings
|
||||
var t = localStorage.getItem('desktopsettings');
|
||||
var t = null;
|
||||
try { t = localStorage.getItem('desktopsettings'); } catch (ex) {}
|
||||
if (t != null) { desktopsettings = JSON.parse(t); }
|
||||
t = localStorage.getItem('multidesktopsettings');
|
||||
t = null;
|
||||
try { t = localStorage.getItem('multidesktopsettings'); } catch (ex) {}
|
||||
if (t != null) { multidesktopsettings = JSON.parse(t); }
|
||||
applyDesktopSettings();
|
||||
|
||||
@ -2198,22 +2201,24 @@
|
||||
switch (message.event.action) {
|
||||
case 'userWebState': {
|
||||
// New user web state, update the web page as needed
|
||||
if (localStorage != null) {
|
||||
var oldShowRealNames = localStorage.getItem('showRealNames');
|
||||
var oldUiMode = localStorage.getItem('uiMode');
|
||||
var oldSort = localStorage.getItem('sort');
|
||||
var oldLoctag = localStorage.getItem('loctag');
|
||||
try {
|
||||
if (localStorage != null) {
|
||||
var oldShowRealNames = localStorage.getItem('showRealNames');
|
||||
var oldUiMode = localStorage.getItem('uiMode');
|
||||
var oldSort = localStorage.getItem('sort');
|
||||
var oldLoctag = localStorage.getItem('loctag');
|
||||
|
||||
var webstate = JSON.parse(message.event.state);
|
||||
for (var i in webstate) { localStorage.setItem(i, webstate[i]); }
|
||||
var webstate = JSON.parse(message.event.state);
|
||||
for (var i in webstate) { localStorage.setItem(i, webstate[i]); }
|
||||
|
||||
// Update the web page
|
||||
if ((webstate.deskAspectRatio != null) && (webstate.deskAspectRatio != deskAspectRatio)) { deskAspectRatio = webstate.deskAspectRatio; deskAdjust(); }
|
||||
if ((webstate.showRealNames != null) && (webstate.showRealNames != oldShowRealNames)) { showRealNames = Q('RealNameCheckBox').checked = (webstate.showRealNames == '1'); masterUpdate(6); }
|
||||
if ((webstate.uiMode != null) && (webstate.uiMode != oldUiMode)) { userInterfaceSelectMenu(parseInt(webstate.uiMode)); }
|
||||
if ((webstate.sort != null) && (webstate.sort != oldSort)) { document.getElementById('sortselect').selectedIndex = sort = parseInt(webstate.sort); masterUpdate(6); }
|
||||
if ((webstate.loctag != null) && (webstate.loctag != oldLoctag)) { if (webstate.loctag != null) { args.locale = webstate.loctag; } else { delete args.locale; } masterUpdate(0xFFFFFFFF); }
|
||||
}
|
||||
// Update the web page
|
||||
if ((webstate.deskAspectRatio != null) && (webstate.deskAspectRatio != deskAspectRatio)) { deskAspectRatio = webstate.deskAspectRatio; deskAdjust(); }
|
||||
if ((webstate.showRealNames != null) && (webstate.showRealNames != oldShowRealNames)) { showRealNames = Q('RealNameCheckBox').checked = (webstate.showRealNames == '1'); masterUpdate(6); }
|
||||
if ((webstate.uiMode != null) && (webstate.uiMode != oldUiMode)) { userInterfaceSelectMenu(parseInt(webstate.uiMode)); }
|
||||
if ((webstate.sort != null) && (webstate.sort != oldSort)) { document.getElementById('sortselect').selectedIndex = sort = parseInt(webstate.sort); masterUpdate(6); }
|
||||
if ((webstate.loctag != null) && (webstate.loctag != oldLoctag)) { if (webstate.loctag != null) { args.locale = webstate.loctag; } else { delete args.locale; } masterUpdate(0xFFFFFFFF); }
|
||||
}
|
||||
} catch (ex) {}
|
||||
break;
|
||||
}
|
||||
case 'servertimelinestats': { addServerTimelineStats(message.event.data); break; }
|
||||
@ -10724,9 +10729,11 @@
|
||||
function putstore(name, val) {
|
||||
try {
|
||||
if ((typeof (localStorage) === 'undefined') || (localStorage.getItem(name) == val)) return;
|
||||
if (val == null) { localStorage.removeItem(name); } else { localStorage.setItem(name, val); } } catch (e) { }
|
||||
if (name[0] != '_') {
|
||||
var s = {};
|
||||
if (val == null) { localStorage.removeItem(name); } else { localStorage.setItem(name, val); }
|
||||
} catch (e) { }
|
||||
if (name[0] != '_') {
|
||||
var s = {};
|
||||
try {
|
||||
for (var i = 0, len = localStorage.length; i < len; ++i) {
|
||||
var k = localStorage.key(i);
|
||||
if (k[0] != '_') {
|
||||
@ -10734,9 +10741,10 @@
|
||||
if ((k != 'desktopsettings') && (typeof s[k] == 'string') && (s[k].length > 64)) { delete s[k]; }
|
||||
}
|
||||
}
|
||||
meshserver.send({ action: 'userWebState', state: JSON.stringify(s) });
|
||||
}
|
||||
} catch (ex) {}
|
||||
meshserver.send({ action: 'userWebState', state: JSON.stringify(s) });
|
||||
}
|
||||
}
|
||||
function getstore(name, val) { try { if (typeof (localStorage) === 'undefined') return val; var v = localStorage.getItem(name); if ((v == null) || (v == null)) return val; return v; } catch (e) { return val; } }
|
||||
function addLink(x, f) { return '<span tabindex=0 style=cursor:pointer;text-decoration:none onclick=\'' + f + '\' onkeypress=\"if (event.key==\'Enter\') {' + f + '} \">' + x + ' <img class=hoverButton src=images/link5.png></span>'; }
|
||||
function addLinkConditional(x, f, c) { if (c) return addLink(x, f); return x; }
|
||||
|
Loading…
Reference in New Issue
Block a user