netvolt / LinuxRMM-Script

To help users that want to add Linux Agents to Tactical RMM, without need to pay upfront for code signed agents. Thanks to @ZoLuSs for the initial commit. If this solution works for you, consider contributing to Tactical RMM project!
MIT License
89 stars 39 forks source link

Golang install breaks $PATH #1

Closed Geektasticdad closed 1 year ago

Geektasticdad commented 1 year ago

This installer worked pretty well, but I ran into one issue.

During the golang install it updates the /root/.profile to add "export PATH=/usr/local/go/bin" but after his happens when I restart the SSH session (or log into the console) none of the standard commands work (i.e. ls, nano, etc.). I get the following error:

Command 'ls' is available in the following places
 * /bin/ls
 * /usr/bin/ls
The command could not be located because '/bin:/usr/bin' is not included in the PATH environment variable.

When I check the $PATH the only thing listed is the /usr/local/go/bin path. I had to fix the PATH (export PATH=/bin:/usr/bin) for my session then edit the /root/.profile to comment out the PATH in there. Once that was done, I had no further problems.

Why is the script adding that PATH option to the /root/.profile file? Is there any consequence to leaving that commented out?

Geektasticdad commented 1 year ago

I should add, this happened on Ubuntu Server 20.04 and Ubuntu Server 22.04

netvolt commented 1 year ago

Hi @Geektasticdad. It looks like a standard action of golang installation. I did same as you (fixing the PATH and commenting .profile in root folder). It did not break my setup until client needed an update. When you update it simple moves out from RMM and even reinstalling it, i was not able to make it work again. Have you tested it ?

Geektasticdad commented 1 year ago

Hi @Geektasticdad. It looks like a standard action of golang installation. I did same as you (fixing the PATH and commenting .profile in root folder). It did not break my setup until client needed an update. When you update it simple moves out from RMM and even reinstalling it, i was not able to make it work again. Have you tested it ?

I don't think this has anything to do with to do with Golang or the path variable at all. I started running parts of this script by hand, and it installed the RMM portion just fine but didn't install MeshCentral but it did create the /opt/tacticalmesh/ folder, just empty.

So I went through lines 186 through 194 carefully and ran each one at the terminal. When I ran the command /tmp/meshagent -install --installPath="/opt/tacticalmesh" it returned

root@lxdocker03:/tmp# /tmp/meshagent -install --installPath="/opt/tacticalmesh"
Langauge envronment variable was not set (process.env.LANG).  Defaulting to English ('en').
See the agent-translations.json file for a list of current languages that are implemented
Usage: meshcentral -lang=en

You can run the text version from the command line with the following command(s): 
./meshagent -connect
./meshagent -install
./meshagent -install --installPath="/alternate/path"

No matter how I tried to tweak the command, even took of the --installPath="/opt/tacticalmesh" it still kicked back the error. So I think the issue lies with MeshCentral 1.0.85.

Here's how I managed to work around it though...

  1. After the rmmagent-linux.sh script ran I went back into https://mesh.domain.com/, went to Add Agent, and chose Linux / BSD instead of Linux / BSD / macOS Binary Installer.
  2. I copied the code and ran it which installed MeshCentral under /usr/local/mesh_services/meshaent/. However, TRMM still couldn't see the Mesh install because it wasn't under /opt/tacticalmesh/.
  3. Once I figured that out, I stopped the meshagent services (systemctl stop meshagent) and copied everything from /usr/local/mesh_services/meshagent/ to /opt/tacticalmesh/.
  4. Then I edited /etc/systemd/system/meshagent.service and changed all references to /usr/local/mesh_services/meshagent/ to /opt/tacticalmesh/.
  5. After that I ran systemctl daemon-reload and then started the services again.
  6. I was almost there!! The final step is to TRMM and Take Control then run Recover Connection.

Now everything seems to work just fine. Take Control doesn't do anything (no GUI, server only), but I can run Remote Background and connect to an SSH session.