Ylianst/MeshAgent

--exec not working.

Closed this issue · 3 comments

After modifying, agent-installer.js I tried the following.

  1. compiles the agent. make linux ARCHID=6 DEBUG=1
  2. chmod +x meshagent_x86-64
  3. cp meshagent_x86-64 modules/
  4. cd modules/
  5. ./meshagent_x86-64 -exec "require('clipboard').nativeAddCompressedModule('agent-installer');process.exit();"
  6. Nothing shows on the terminal. The command runs and exists no output.

Weirdly enough, the output is in memory, not printed to the terminal. any idea?

I'm assuming you are wanting edit the agent-installer.js, and link it in the compiled binary... There are two ways to do this... I'll talk about the new way last, since it is only supported in the latest agent release...

You are on the right track with how you are doing it. That is the current way I've typically done it... And you are correct, it places some C code in the clipboard... What you should do is edit the microscript/ILibDuktape_Polyfills.c file, and search for agent-installer. Select the entire section for that, and hit paste... It will overwrite that section with the updated one...

To save some steps, so you don't have to change directories, you can run the command like this, specifying the path to where your modules folder is:

./meshagent_x86-64 -exec "setModulePath('/mnt/GITHub/MeshAgent/modules');require('clipboard').nativeAddCompressedModule('agent-installer');process.exit();"

Anyways, I have updated some things, to make things easier going forward...
Starting with the latest agent release, you can run this command:
./meshagent_x86-64 -export

This command will cause the agent to export all the embedded JS files into a folder called modules_expanded

Then you can edit the JS files as you see fit in that folder.
When you are ready to re-import, run the following command. (Note: I meant to add a command line switch for this step, but didn't get there yet when the re-org happened)

./meshagent_x86-64 -exec "require('code-utils').shrink({modulesPath:'/mnt/hgfs/GITHub/MeshAgent/modules',filePath:'/mnt/hgfs/GITHub/MeshAgent/microscript/ILibDuktape_Polyfills.c'});process.exit();"

Just specify the appropriate paths as they may not match the ones I used. This command will read all the files in the modules_expanded folder, and compress/encode it, and update the ILibDuktape_Polyfills.c file.

Thank you for putting this together. REally helpful.