1
0
Fork 0
mirror of https://github.com/Ylianst/MeshCentral.git synced 2025-03-09 15:40:18 +00:00

Tweaks to plugin install/removal so server does not require a restart. Initial support for downgrading plugins.

This commit is contained in:
Ryan Blenis 2019-11-22 14:25:13 -05:00
parent 800504f5ed
commit 78bbf03b00
5 changed files with 165 additions and 19 deletions

View file

@ -3147,11 +3147,12 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
}
case 'installplugin': {
if ((user.siteadmin & 0xFFFFFFFF) == 0 || parent.parent.pluginHandler == null) break; // must be full admin, plugins enabled
parent.parent.pluginHandler.installPlugin(command.id, function(){
parent.parent.updateMeshCore();
parent.parent.pluginHandler.installPlugin(command.id, command.version_only, function(){
parent.db.getPlugins(function(err, docs) {
try { ws.send(JSON.stringify({ action: 'updatePluginList', list: docs, result: err })); } catch (ex) { }
});
var targets = ['*', 'server-users'];
parent.parent.DispatchEvent(targets, obj, { action: 'pluginStateChange' });
});
break;
}
@ -3160,7 +3161,8 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
parent.parent.pluginHandler.disablePlugin(command.id, function(){
parent.db.getPlugins(function(err, docs) {
try { ws.send(JSON.stringify({ action: 'updatePluginList', list: docs, result: err })); } catch (ex) { }
// @TODO delete plugin object from handler
var targets = ['*', 'server-users'];
parent.parent.DispatchEvent(targets, obj, { action: 'pluginStateChange' });
});
});
break;
@ -3174,6 +3176,18 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
});
break;
}
case 'getpluginversions': {
if ((user.siteadmin & 0xFFFFFFFF) == 0 || parent.parent.pluginHandler == null) break; // must be full admin, plugins enabled
parent.parent.pluginHandler.getPluginVersions(command.id)
.then(function (versionInfo) {
try { ws.send(JSON.stringify({ action: 'downgradePluginVersions', info: versionInfo, error: null })); } catch (ex) { }
})
.catch(function (e) {
try { ws.send(JSON.stringify({ action: 'pluginError', msg: e })); } catch (ex) { }
});
break;
}
case 'plugin': {
if (parent.parent.pluginHandler == null) break; // If the plugin's are not supported, reject this command.
command.userid = user._id;