ryanblenis / MeshCentral-ScriptTask

Scripting plugin for MeshCentral
Apache License 2.0
52 stars 14 forks source link

Unable install/uninstall plugins after upgrade to Meshcentral 0.9.7 #18

Closed itsmedakshesh closed 2 years ago

itsmedakshesh commented 3 years ago

MeshCentral version: 0.9.7 OS Running: Ubuntu 18.04 Recent change: Did upgrade from 0.4.5 to 0.9.7 MechCentral runs without errors. Issue: Cannot uninstall or install plugins. Its restart the service (first disconnects meshcentral and then starts again but plugins remains.)

Screenshot_23

Recent, error log:

/home//node_modules/meshcentral/db.js:1489 obj.getPlugin = function (id, func) { id = require('mongodb').ObjectID(id); obj.pluginsfile.find({ _id: id }).sort({ name: 1 }).toArray(func); }; // Get plugin ^

TypeError: require(...).ObjectID is not a function at Object.obj.getPlugin (/home//node_modules/meshcentral/db.js:1489:79) at Object.obj.installPlugin (/home//node_modules/meshcentral/pluginHandler.js:356:19) at WebSocket.processWebSocketData (/home//node_modules/meshcentral/meshuser.js:4833:45) at WebSocket.emit (events.js:400:28) at Receiver.receiverOnMessage (/home//node_modules/ws/lib/websocket.js:720:20) at Receiver.emit (events.js:400:28) at Receiver.dataMessage (/home//node_modules/ws/lib/receiver.js:414:14) at Receiver.getData (/home//node_modules/ws/lib/receiver.js:346:17) at Receiver.startLoop (/home//node_modules/ws/lib/receiver.js:133:22) at Receiver._write (/home//node_modules/ws/lib/receiver.js:69:10)

VINISHVV commented 3 years ago

Please try this method

Remove the existing plugins Disable the plugin by editing config.js Goto server console and run "resetserver"

Enable plugin by editing config.js Goto server console and run "resetserver" Install required plugins and refresh agents.

itsmedakshesh commented 3 years ago

Please try this method

Remove the existing plugins Disable the plugin by editing config.js Goto server console and run "resetserver"

Enable plugin by editing config.js Goto server console and run "resetserver" Install required plugins and refresh agents.

Thank you for your assistance. I am using MongoDB to store my mesh data. Do you know if this tool "Plugin" works with mongoDB?

VINISHVV commented 3 years ago

Please try this method Remove the existing plugins Disable the plugin by editing config.js Goto server console and run "resetserver" Enable plugin by editing config.js Goto server console and run "resetserver" Install required plugins and refresh agents.

Thank you for your assistance. I am using MongoDB to store my mesh data. Do you know if this tool "Plugin" works with mongoDB?

I am also using mongodb.

itsmedakshesh commented 3 years ago

Please try this method Remove the existing plugins Disable the plugin by editing config.js Goto server console and run "resetserver" Enable plugin by editing config.js Goto server console and run "resetserver" Install required plugins and refresh agents.

Thank you for your assistance. I am using MongoDB to store my mesh data. Do you know if this tool "Plugin" works with mongoDB?

I am also using mongodb.

Can you tell me what are the correct changes we should make to enable or use of MongoDB?

My config looks like this:

{ "comment" : "This is a sample configuration file, edit a section and remove the _ in front of the name. Refer to the user's guide for details.$ "settings": { "Cert": "", "MongoDb": "mongodb://127.0.0.1:27017", "MongoDbName": "meshcentral", "_MongoDbChangeStream": true, "WANonly": false, "LANonly": false, "_Minify": 1, "_SessionTime": 30, "_SessionKey": "", "_SessionSameSite": "strict", "_DbEncryptKey": "", "_DbExpire": { "events": 1728000, "powerevents": 864000 }, "plugins": { "enabled": true }, "_Port": 443, "_RedirPort": 80, "_AllowLoginToken": true, "_AllowFraming": true, "_WebRTC": false, "_Nice404": false, "_ClickOnce": false, "_SelfUpdate": true, "_AgentPing": 60, "_AgentPong": 60, "_AgentIdleTimeout": 150, "_MeshErrorLogPath": "c:\tmp", "_NpmPath": "c:\npm.exe", "_NpmProxy": "http://1.2.3.4:80", "_AllowHighQualityDesktop": true, "_UserAllowedIP": "127.0.0.1,192.168.1.0/24", "_UserBlockedIP": "127.0.0.1,::1,192.168.0.100", "_AgentAllowedIP": "192.168.0.100/24", "_AgentBlockedIP": "127.0.0.1,::1", "_LocalDiscovery": { "name": "Local server name", "info": "Information about this server" }, "_TlsOffload": true, "_MpsTlsOffload": true, "_No2FactorAuth": true, "_WebRtConfig": { "iceServers": [ { "urls": "stun:stun.services.mozilla.com" }, { "urls": "stun:stun.l.google.com:19302" } ] }, "_AutoBackup": { "backupIntervalHours": 24, "keepLastDaysBackup": 10, "zipPassword": "MyReallySecretPassword3", "_backupPath": "C:\backups" }, "_Redirects": { "meshcommander": "https://www.meshcommander.com/" } },

VINISHVV commented 3 years ago

@itsmedakshesh

One doubt, Do you have internet access enabled in your server? If No please enable the internet access temporarily and do the below methods to reinstall the plugins.

1) Goto Meshcentral data/Plugins and remove the unwanted plugins folder permanently. 2) Goto server -> Console -> and enter "resetserver" to restart the meshcentral. 3) Login mesh central and remove all plugins. 4) Reinstall the required plugins and click on refresh agent.

Hope this method will resolve your issues.

leleb commented 3 years ago

image -I deleted everythig in Meshcentral data/Plugins, -set "plugins": {"enabled": false} restarted machine, then set true but plugins list still there (Plugins directory is empty) ScriptTask plugin listed twice because I tried to re-install and remove (I am using mongodb, is it stored somewhere there?)

itsmedakshesh commented 3 years ago

image -I deleted everythig in Meshcentral data/Plugins, -set "plugins": {"enabled": false} restarted machine, then set true but plugins list still there (Plugins directory is empty) ScriptTask plugin listed twice because I tried to re-install and remove (I am using mongodb, is it stored somewhere there?)

Follow this command:

1) mongo - Login there 2) find the collection name - Plugins 3) remove all the data in the plugins collection (aka plugins table) 4) this will surely help you to get rid of the corrupted installed entries in the myserver plugins views.

Screenshot_34

leleb commented 3 years ago

image -I deleted everythig in Meshcentral data/Plugins, -set "plugins": {"enabled": false} restarted machine, then set true but plugins list still there (Plugins directory is empty) ScriptTask plugin listed twice because I tried to re-install and remove (I am using mongodb, is it stored somewhere there?)

Follow this command:

  1. mongo - Login there
  2. find the collection name - Plugins
  3. remove all the data in the plugins collection (aka plugins table)
  4. this will surely help you to get rid of the corrupted installed entries in the myserver plugins views.

Screenshot_34

tips worked, plugins removed. However looks like plugins no more available in meshcentral 0.9.7 with mongodb. Re installing a plugin (tried WorkFromHome) did not download anything in plugins directory and need to use above procedure to remove from plugins list.

sblosser commented 2 years ago

I can confirm this is an issue when using MongoDB. Switched to NeDB and the plugin install/remove functionality works.

ryanblenis commented 2 years ago

Submitted a pull request to MeshCentral ( https://github.com/Ylianst/MeshCentral/pull/3143 ) for this issue (dependencies changes in the main project). Once that is approved and there is a new version number available, I'll bump up the version here with compatibility fixes for new mongodb requirements.

VINISHVV commented 2 years ago

Seems The fix working fine.. Thanks @ryanblenis

ryanblenis commented 2 years ago

The fix has been included in the main project and this plugin updated as well. Thanks all!