Meshcentral: Uploading core file

Created on 6 Jan 2020  路  15Comments  路  Source: Ylianst/MeshCentral

Greetings,

I'm having a few issues when uploading a core file. My objective is to customize my core files so I can add a few commands to be executed by an agent but first I was playing with a few of the existing core files. I Changed the recoverycore.js file and tried this:

 ` Console -> Agent Action -> Upload recovery core`

This way the core was succesfully uploaded, my changes were there (just changed the initial text), and all commands were available. Then I tried another approach:

 `Console -> Agent Action -> Upload core file`

Here I manually choose the same file I modified in the previous example, but It doesn't seem to work at all. Not only none of the commands work but the core's name "MeshCore Recovery" do not appear as the current agent core.

I don't know if I'm doing something wrong here.
Ty

Fixed - Confirm & Close question

Most helpful comment

I have a fix for this, it will be in MeshCentral v0.4.7-a when I next publish it.

All 15 comments

Hi. The agent runs JavaScript using DukTape and our own built-in methods that try to match NodeJS a little, but it's not as complete. By default, the agent runs "/agents/meshcore.js", so you should modify that file, the "/agents/recoverycore.js" file is just a simpler file we use for debugging. If you change "/agents/meshcore.js" and restart the server, all your agents will have your change.

Note that when you update the server, your "/agents/meshcore.js" will be overwritten and your changes will be lost. You can copy that file to "meshcentral-data/meshcore.js" and make your changes there. MeshCentral will use "meshcore.js" in "meshcentral-data" first. However, you don't get the latest fixes and feature anymore.

If you make useful changes, feel free to submit then as a GitHub pull request. Also, if you make server/core changes, let us know you are running with modifications when filing a issue.

Hope that helps,
Ylian

Also I just want to add:

  • if the additions are useful to you
  • but might not fit in with being added to the core for everyone (via pull request) to the main project
  • and you still want the latest meshcore.js updates without having to manually update your meshcore.js every time a MeshCentral update is published

A plugin might be a good fit. The plugin system works great for adding new commands/functionality and gives you all of the above.

Actually @Ylianst,

Taking a closer look at this and trying to upload a meshcore.js file (or even switch to the recovery core) seems to fail (the name changes, but the basic "help" command fails when using the recovery core) since commit fc0915de60f6ef799db450cb46bbf0060a8e7127. Looks like it might have something to do with the group permissions implementation.

Working on this now!

I have a fix for this, it will be in MeshCentral v0.4.7-a when I next publish it.

Thank you for your hard work.

@steuck13: Probably shouldn't close this issue until the fix is at least published, if not tested.

@steuck13: v0.4.7-a has been published, can you test it (or a newer version) to see if the fix works for you?

The recovery core selection now works as expected. Uploading a core file from disk (using the recovery core file as a test) still yields no working commands in the console.

I do want to note that MeshCentral will merge the meshcore.js and all of the dependencies in the "node_modules/meshcentral/agents/modules_meshcore" folder to create a big core file that is sent to the agent. The "recoverycore.js" does have required modules that need to be included so you can't just upload it from file.

So, you can't edit the meshcore.js and upload it and expect it to work. Best trick is to backup the existing "meshcore.js" in the "agents" folder, make changes to it. Then, if you hold "Alt" and hit "Agent Action" button, it will clear the core on that agent. Hold "Shift" and hit "Agent Action" to push the new core. This way, you can quickly make change to the core and see the results.

I don't actually use the feature to upload a core from disk or server files (obviously being me, I'd make a plugin) just thought I'd mention it as I was testing for this issue and noticed it- and if it is there and an option it stands to reason that it would work.

If it doesn't work and isn't the right way to go about sending a core, should those options just be removed? Or is it just that the recovery core I uploaded manually doesn't contain the node_modules/meshcentral/agents/modules_meshcore files, and therefore "help" is not expected to work in this instance?

Right, so uploading a core file from disk will work if you merge everything first. If you just try to upload meshcore.js or recoverycore.js, it will not work because none of the dependencies are included. I am ok removing it if people are ok with it. I added that feature a long time ago, when the meshcore was only a few lines long. It's grown quite a bit since.

Gotcha, as long as it serves a functional purpose that works I have no problem with it being there. Thanks for the info though- definitely good to know!

I'll stop hijacking the thread now and let @steuck13 decide if this answers / solves their issue - but it looks good to me. Thank you.

As @MailYouLater noted, I did make a fix for @steuck13. Hopefully it worked, waiting for confirmation.

It worked, thank you. Also thank you about the info related to uploading a core from the disk, as I thought (and you explained previously) the best way would be to modify the default core file.

Was this page helpful?
0 / 5 - 0 ratings