diff --git a/meshuser.js b/meshuser.js index d2a00731..a4780c80 100644 --- a/meshuser.js +++ b/meshuser.js @@ -3137,6 +3137,12 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use } break; } + case 'distributeCore': { + for (var i in command.nodes) { + parent.sendMeshAgentCore(user, domain, command.nodes[i]._id, 'default'); + } + break; + } case 'plugins': { // Since plugin actions generally require a server restart, use the Full admin permission if ((user.siteadmin & 0xFFFFFFFF) == 0 || parent.parent.pluginHandler == null) break; // must be full admin with plugins enabled @@ -3172,7 +3178,7 @@ 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, command.version_only, function(){ + parent.parent.pluginHandler.installPlugin(command.id, command.version_only, null, function(){ parent.db.getPlugins(function(err, docs) { try { ws.send(JSON.stringify({ action: 'updatePluginList', list: docs, result: err })); } catch (ex) { } }); diff --git a/pluginHandler.js b/pluginHandler.js index c1a38f11..d0d70b59 100644 --- a/pluginHandler.js +++ b/pluginHandler.js @@ -317,7 +317,7 @@ module.exports.pluginHandler = function (parent) { }); }; - obj.installPlugin = function(id, version_only, func) { + obj.installPlugin = function(id, version_only, force_url, func) { parent.db.getPlugin(id, function(err, docs){ // the "id" would probably suffice, but is probably an sanitary issue, generate a random instead var randId = Math.random().toString(32).replace('0.', ''); @@ -327,6 +327,7 @@ module.exports.pluginHandler = function (parent) { const file = obj.fs.createWriteStream(fileName); var dl_url = plugin.downloadUrl; if (version_only != null && version_only != false) dl_url = version_only.url; + if (force_url != null) dl_url = force_url; var url = require('url'); var q = url.parse(dl_url, true); var http = (q.protocol == "http") ? require('http') : require('https'); @@ -342,7 +343,7 @@ module.exports.pluginHandler = function (parent) { }; var request = http.get(opts, function(response) { // handle redirections with grace - if (response.headers.location) return obj.installPlugin(id, { name: version_only.name, url: response.headers.location }, func); + if (response.headers.location) return obj.installPlugin(id, version_only, response.headers.location, func); response.pipe(file); file.on('finish', function() { file.close(function(){ @@ -377,13 +378,16 @@ module.exports.pluginHandler = function (parent) { zipfile.on("end", function () { setTimeout(function () { obj.fs.unlinkSync(fileName); if (version_only == null || version_only === false) { - parent.db.setPluginStatus(id, 1, func); + parent.db.setPluginStatus(id, 1, func); } else { - parent.db.updatePlugin(id, { status: 1, version: version_only.name }, func); + parent.db.updatePlugin(id, { status: 1, version: version_only.name }, func); } obj.plugins[plugin.shortName] = require(obj.pluginPath + '/' + plugin.shortName + '/' + plugin.shortName + '.js')[plugin.shortName](obj); obj.exports[plugin.shortName] = obj.plugins[plugin.shortName].exports; if (typeof obj.plugins[plugin.shortName].server_startup == 'function') obj.plugins[plugin.shortName].server_startup(); + var plugin_config = obj.fs.readFileSync(obj.pluginPath + '/' + plugin.shortName + '/config.json'); + plugin_config = JSON.parse(plugin_config); + parent.db.updatePlugin(plugin._id, plugin_config); parent.updateMeshCore(); }); }); }); diff --git a/views/default.handlebars b/views/default.handlebars index fc7e9b22..aef176a3 100644 --- a/views/default.handlebars +++ b/views/default.handlebars @@ -423,7 +423,9 @@
Name | Description | Link | Version | Latest Available | Status | Action |
---|