Ylianst / MeshCentral

A complete web-based remote monitoring and management web site. Once setup you can install agents and perform remote desktop session to devices on the local network or over the Internet.
https://meshcentral.com
Apache License 2.0
4.23k stars 568 forks source link

[Q] Change linux client install location? Possible? #5384

Open tiagogbarbosa opened 1 year ago

tiagogbarbosa commented 1 year ago

I have some Raspberries with Overlay file system (essentially read-only), but i have a mount to a partition in sdcard that is writable all the time.. (mounted in /sdcard)

Can i specify MeshCentral client to install in /sdcard/meshcentral? Or is possible to make a custom install script?

Ty in advance

krayon007 commented 1 year ago

If you use the binary installer, use the /help option. One of the command line parameters shows how to change the install location. I forget what it is off the top of my head

tomsik-radek commented 1 year ago

@tiagogbarbosa Hey, if you ever get this working please report it. I have a device with read only file system (Steam Deck) but would love Mesh on it.

si458 commented 1 year ago

@krayon007 /help doesnt work but -help does but returns no info about how to install

simon@SiUbuntu22:~/wtf$ sudo ./meshagent -help
You can run the text version from the command line with the following command(s): 
./meshagent -connect
./meshagent -update
./meshagent -uninstall

EDIT: the above output is because i already have the agent installed below is output for IF you dont have it installed

simon@SiUbuntu22:~/wtf$ sudo ./meshagent -help
You can run the text version from the command line with the following command(s): 
./meshagent -connect
./meshagent -install
./meshagent -install --installPath="/alternate/path"
tomsik-radek commented 1 year ago

~@krayon007 /help doesnt work but -help does but returns no info about how to install~

simon@SiUbuntu22:~/wtf$ sudo ./meshagent -help
You can run the text version from the command line with the following command(s): 
./meshagent -connect
./meshagent -update
./meshagent -uninstall

EDIT: the above output is because i already have the agent installed below is output for IF you dont have it installed

simon@SiUbuntu22:~/wtf$ sudo ./meshagent -help
You can run the text version from the command line with the following command(s): 
./meshagent -connect
./meshagent -install
./meshagent -install --installPath="/alternate/path"

Sadly doesn't seem to work on SteamOS (Arch derivative with read only filesystem, similar to Fedora Silverblue)

/var/lib is writeable (flatpaks install here and I could create the folder)

(deck@steamdeck Downloads)$ sudo ./meshagent -install --installPath="/var/lib/meshcentral"
...Checking for previous installation of "meshagent" [NONE]
...Installing service [ERROR] FS CreateWriteStream Error

Even tried to ~

sudo ./meshagent -install --installPath="/home/deck/.meshagent"
...Checking for previous installation of "meshagent" [NONE]
...Installing service [ERROR] FS CreateWriteStream Error
si458 commented 1 year ago

@tomsik-radek FS CreateWriteStream Error this to me screams a read/write permission issue Are u sure the folders u enters have read/write permission and not readonly?

tomsik-radek commented 1 year ago

Given one of them is in my home directory and I created it, yes I'm sure I (and root) user can write into those two folders. The question is is the script trying to write somewhere else, fails and doesn't tell us where?

tomsik-radek commented 1 year ago
(deck@steamdeck ~)$ cd .meshagent/
(deck@steamdeck .meshagent)$ ls
meshagent
(deck@steamdeck .meshagent)$ ls -la
total 3716
drwxr-xr-x  2 root root    4096 Oct  2 19:13 .
drwx------ 26 deck deck    4096 Oct  2 19:19 ..
-rwxr-xr-x  1 root root 3794180 Oct  2 19:13 meshagent
(deck@steamdeck .meshagent)$ sudo ./meshagent -install --installPath="/home/deck/.meshagent"
[sudo] password for deck:

...Checking for previous installation of "meshagent" [NONE]
...Installing service [ERROR] FS CreateWriteStream Error(deck@steamdeck .meshagent)$
(deck@steamdeck .meshagent)$ ls -la
total 3748
drwxr-xr-x  2 root root    4096 Oct  2 19:33 .
drwx------ 26 deck deck    4096 Oct  2 19:19 ..
-rwxr-xr-x  1 root root 3794180 Oct  2 19:13 meshagent
-rw-r--r--  1 root root   29391 Oct  2 19:33 meshagent.msh
(deck@steamdeck .meshagent)$
si458 commented 1 year ago

It does say installing service, so it might be it doesn't have permission to write the systemd file to start the service on start up? (Just a guess, I don't own a steam deck, I'm not made of money haha)

tomsik-radek commented 1 year ago

It does say installing service, so it might be it doesn't have permission to write the systemd file to start the service on start up? (Just a guess, I don't own a steam deck, I'm not made of money haha)

Hmm, didn't think about that. Yes that might be a possibility.

Okay, manual test, I can create a text file in /etc/systemd/system, is that the right folder?

(deck@steamdeck system)$ sudo touch test.service
(deck@steamdeck system)$ ls -la
total 84
drwxr-xr-x 1 root root 4096 Oct  2 19:37 .
drwxr-xr-x 1 root root 4096 Dec 29  2022 ..
lrwxrwxrwx 1 root root    9 Dec 22  2022 alsa-restore.service -> /dev/null
drwxr-xr-x 1 root root   34 Sep  1 04:11 bluetooth.target.wants
lrwxrwxrwx 1 root root    9 Nov 10  2022 boot.mount -> /dev/null
[removed bloat]
drwxr-xr-x 1 root root   46 Sep  1 04:10 systemd-remount-fs.service.d
-rw-r--r-- 1 root root    0 Oct  2 19:37 test.service
lrwxrwxrwx 1 root root    9 Sep  1 04:11 usr-lib-debug.mount -> /dev/null
lrwxrwxrwx 1 root root    9 Sep  1 04:11 usr-local.mount -> /dev/null
(deck@steamdeck system)$
tomsik-radek commented 1 year ago

Hmm, it might be trying to write to /usr/lib/systemd/system/ which is indeed read only

si458 commented 1 year ago

Hmm, it might be trying to write to /usr/lib/systemd/system/ which is indeed read only

Just checked my pikvm and proxmox machines, yeh it stores the startup file in there

The only thing I can suggest is if u put meshagent into a read/write folder then manually run meshagent -run on startup somehow?

Does steam deck have a startup menu u can add stuff to?

Edit: what about the rc.local file? Is that read/writeable?

tomsik-radek commented 1 year ago

Nicked the systemd file from my Debian server (don't run anything arch/rhel/fedora etc sadly)

(1)(deck@steamdeck ~)$ cat /etc/systemd/system/meshagent.service
[Unit]
Description=meshagent background service
Wants=network-online.target
After=network-online.target
[Service]
WorkingDirectory=/home/deck/.meshagent
ExecStart=/home/deck/.meshagent/meshagent --installedByUser=0
StandardOutput=null
Restart=on-failure
RestartSec=3
[Install]
WantedBy=multi-user.target
Alias=meshagent.service

It doesn't crash, but it autoexits

Oct 02 19:57:34 steamdeck systemd[1]: Started meshagent background service.
Oct 02 19:57:35 steamdeck systemd[1]: meshagent.service: Deactivated successfully.
Oct 02 19:57:35 steamdeck systemd[1]: meshagent.service: Consumed 1.002s CPU time.
Oct 02 19:58:20 steamdeck systemd[1]: Started meshagent background service.

Okay, manual run works, now just work out systemd

(deck@steamdeck .meshagent)$ sudo ./meshagent -connect

Server URL: wss://meshcentral.domain.tld:443/agent.ashx
Device Group: Laptops

Press Ctrl-C to exit.

SteamOS doesn't seem to ship with rc.local, or at least not /etc/rc.local

tomsik-radek commented 1 year ago

Okay with

(deck@steamdeck .meshagent)$ sudo cat /etc/systemd/system/meshagent.service
[Unit]
Description=meshagent background service
Wants=network-online.target
After=network-online.target
[Service]
WorkingDirectory=/home/deck/.meshagent
ExecStart=/home/deck/.meshagent/meshagent --installedByUser=0 -connect
Group=nobody
StandardOutput=null
Restart=on-failure
RestartSec=3
[Install]
WantedBy=multi-user.target
Alias=meshagent.service

Scratch this last part, I'm an idiot. I added it to a group where I set up user rights notifications ~~it runs, but files, ssh, desktop etc, all go "waiting for user to grant rights" and then a second later goes "denied". A login prompt should pop up (and does on my other Linux boxes)~~

"terminal": {
            "linuxshell": "login",
              "launchCommand": {
                "linux": "clear\necho \"Hello Linux\"\n",
                "darwin": "clear\necho \"Hello MacOS\"\n",
                "freebsd": "clear\necho \"Hello FreeBSD\"\n"
              }
        }
tomsik-radek commented 1 year ago

Okay, now it seems to work. Question is if it will survive updates, hopefully yes.

Now, I'm not a Linux developer so I can't help here much, but would it be possible to check if /usr/lib/systemd/system/ is writeable and if not create the service file in /etc/systemd/system/?

Also I'm not sure why I had to put -connect in the service file when my Debian devices don't have it. Because I'm technically running the "portable" version of the agent as a service, so not ideal setup

tomsik-radek commented 1 year ago

Okay this won't work either because after a while, the Desktop, Files and terminal tabs just disappear completely. I guess the agent in portable -connect mode doesn't keep handshaking with the server?

Don't appear after OS restart either, but do after service restart