Closed ggaussling closed 5 years ago
Hi,
Your initial run potentially caused the issue. When it started for the first time, it would have created meshcentral-data folder under root ownership. Please ls -l the folder and check the ownership.
Regards,
Joko
pi@raspberrypi:~ $ tree -Dladugp /home/pi/node_modules/meshcentral
/home/pi/node_modules/meshcentral
+-- [drwxr-xr-x pi pi May 5 1:06] agents
¦ +-- [drwxr-xr-x pi pi May 5 1:06] modules_meshcmd
¦ +-- [drwxr-xr-x pi pi May 5 1:06] modules_meshcmd_min
¦ +-- [drwxr-xr-x pi pi May 5 1:06] modules_meshcore
¦ +-- [drwxr-xr-x pi pi May 5 1:06] modules_meshcore_min
+-- [drwxr-xr-x pi pi May 5 1:06] amt
+-- [drwxr-xr-x pi pi May 5 1:06] bin
+-- [drwxr-xr-x pi pi May 5 1:06] public
¦ +-- [drwxr-xr-x pi pi May 5 1:06] clickonce
¦ ¦ +-- [drwxr-xr-x pi pi May 5 1:06] minirouter
¦ ¦ +-- [drwxr-xr-x pi pi May 5 1:06] Application Files
¦ ¦ +-- [drwxr-xr-x pi pi May 5 1:06] MeshMiniRouter_2_0_0_26
¦ +-- [drwxr-xr-x pi pi May 5 1:06] images
¦ ¦ +-- [drwxr-xr-x pi pi May 5 1:06] notify
¦ ¦ +-- [drwxr-xr-x pi pi May 5 1:06] webp
¦ +-- [drwxr-xr-x pi pi May 5 1:06] samples
¦ +-- [drwxr-xr-x pi pi May 5 1:06] scripts
¦ +-- [drwxr-xr-x pi pi May 5 1:06] sounds
¦ +-- [drwxr-xr-x pi pi May 5 1:06] styles
+-- [drwxr-xr-x pi pi May 5 1:06] views
20 directories
pi@raspberrypi:~ $ locate data |grep mesh| grep --color data
/home/pi/meshcentral-data
[...]
pi@raspberrypi:~ $ tree -augp /home/pi/meshcentral-data
/home/pi/meshcentral-data
+-- [-rw-r--r-- root root ] agentserver-cert-private.key
+-- [-rw-r--r-- root root ] agentserver-cert-public.crt
+-- [-rw-r--r-- root root ] config.json
+-- [-rw-r--r-- root root ] meshcentral.db
+-- [-rw-r--r-- root root ] meshcentral-events.db
+-- [-rw-r--r-- root root ] meshcentral-power.db
+-- [-rw-r--r-- root root ] meshcentral-smbios.db
+-- [-rw-r--r-- root root ] meshcentral-stats.db
+-- [-rw-r--r-- pi pi ] mesherrors.txt
+-- [-rw-r--r-- root root ] mpsserver-cert-private.key
+-- [-rw-r--r-- root root ] mpsserver-cert-public.crt
+-- [-rw-r--r-- root root ] root-cert-private.key
+-- [-rw-r--r-- root root ] root-cert-public.crt
+-- [-rw-r--r-- root root ] serverstate.txt
+-- [-rw-r--r-- root root ] webserver-cert-private.key
+-- [-rw-r--r-- root root ] webserver-cert-public.crt
0 directories, 16 files
pi@raspberrypi:~ $ sudo chown -R -c pi:pi /home/pi/meshcentral-data
changed ownership of '/home/pi/meshcentral-data/serverstate.txt' from root:root to pi:pi
changed ownership of '/home/pi/meshcentral-data/agentserver-cert-public.crt' from root:root to pi:pi
changed ownership of '/home/pi/meshcentral-data/meshcentral-events.db' from root:root to pi:pi
changed ownership of '/home/pi/meshcentral-data/agentserver-cert-private.key' from root:root to pi:pi
changed ownership of '/home/pi/meshcentral-data/root-cert-public.crt' from root:root to pi:pi
changed ownership of '/home/pi/meshcentral-data/meshcentral.db' from root:root to pi:pi
changed ownership of '/home/pi/meshcentral-data/webserver-cert-private.key' from root:root to pi:pi
changed ownership of '/home/pi/meshcentral-data/meshcentral-power.db' from root:root to pi:pi
changed ownership of '/home/pi/meshcentral-data/mpsserver-cert-private.key' from root:root to pi:pi
changed ownership of '/home/pi/meshcentral-data/mpsserver-cert-public.crt' from root:root to pi:pi
changed ownership of '/home/pi/meshcentral-data/webserver-cert-public.crt' from root:root to pi:pi
changed ownership of '/home/pi/meshcentral-data/meshcentral-stats.db' from root:root to pi:pi
changed ownership of '/home/pi/meshcentral-data/config.json' from root:root to pi:pi
changed ownership of '/home/pi/meshcentral-data/root-cert-private.key' from root:root to pi:pi
changed ownership of '/home/pi/meshcentral-data/meshcentral-smbios.db' from root:root to pi:pi
Hm, I guess I forgot to stop some processes beforehand.
pi 1750 16.2 5.0 141572 48152 pts/0 Sl 15:33 0:04 node node_modules/meshcentral --lanonly --fastcert
pi 1920 0.0 0.0 4368 564 pts/0 S+ 15:33 0:00 grep --color=auto mesh
root 15076 0.0 0.3 7216 3336 pts/0 S 14:30 0:00 sudo node node_modules/meshcentral --lanonly --fastcert
root 15080 0.1 4.7 141572 45432 pts/0 Sl 14:30 0:04 node node_modules/meshcentral --lanonly --fastcert
root 15105 0.0 0.0 1888 408 pts/0 S 14:30 0:00 /bin/sh -c /usr/bin/node /home/pi/node_modules/meshcentral --lanonly --fastcert --launch
root 15106 0.4 6.1 153992 58156 pts/0 Sl 14:30 0:17 /usr/bin/node /home/pi/node_modules/meshcentral --lanonly --fastcert --launch
sudo kill -9 1750 1920 15076 15080 15105 15106
kill: (1750): No such process
kill: (1920): No such process
[1]- Killed sudo node node_modules/meshcentral --lanonly --fastcert
[2]+ Killed node node_modules/meshcentral --lanonly --fastcert
pi@raspberrypi:~ $ ps axu | grep mesh
pi 2508 0.0 0.0 4368 544 pts/0 S+ 15:34 0:00 grep --color=auto mesh
pi@raspberrypi:~ $ node node_modules/meshcentral --lanonly --fastcert &
[1] 2539
pi@raspberrypi:~ $ ps axu | grep mesh
pi 2539 71.5 4.2 85920 40168 pts/0 Rl 15:35 0:01 node node_modules/meshcentral --lanonly --fastcert
pi 2551 0.0 0.0 4368 572 pts/0 S+ 15:35 0:00 grep --color=auto mesh
pi@raspberrypi:~ $ ps axu | grep mesh{ Error: Command failed: /usr/bin/node /home/pi/node_modules/meshcentral --lanonly --fastcert --launch
/home/pi/node_modules/nedb/lib/datastore.js:77
if (err) { throw err; }
^
Error: EACCES: permission denied, open '/home/pi/meshcentral-data/meshcentral.db'
at ChildProcess.exithandler (child_process.js:281:12)
at emitTwo (events.js:131:20)
at ChildProcess.emit (events.js:214:7)
at maybeClose (internal/child_process.js:915:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
killed: false,
code: 1,
signal: null,
cmd: '/usr/bin/node /home/pi/node_modules/meshcentral --lanonly --fastcert --launch' }
ERROR: MeshCentral failed with critical error, check MeshErrors.txt. Restarting in 5 seconds...
pi@raspberrypi:~ $ systemctl stop meshcentral.service
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to stop 'meshcentral.service'.
Multiple identities can be used for authentication:
1. ,,, (pi)
2. root
Choose identity to authenticate as (1-2): 1
Password:
==== AUTHENTICATION COMPLETE ===
pi@raspberrypi:~ $ systemctl status meshcentral.service
? meshcentral.service - MeshCentral Server
Loaded: loaded (/etc/systemd/system/meshcentral.service; enabled; vendor preset: enabled)
Active: inactive (dead) since Sun 2019-05-05 15:37:29 BST; 2s ago
Process: 2954 ExecStart=/usr/bin/node /home/pi/node_modules/meshcentral (code=killed, signal=TERM)
Main PID: 2954 (code=killed, signal=TERM)
May 05 15:37:24 raspberrypi node[2954]: at ChildProcess.emit (events.js:214:7)
May 05 15:37:24 raspberrypi node[2954]: at maybeClose (internal/child_process.js:915:16)
May 05 15:37:24 raspberrypi node[2954]: at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
May 05 15:37:24 raspberrypi node[2954]: killed: false,
May 05 15:37:24 raspberrypi node[2954]: code: 1,
May 05 15:37:24 raspberrypi node[2954]: signal: null,
May 05 15:37:24 raspberrypi node[2954]: cmd: '/usr/bin/node /home/pi/node_modules/meshcentral --launch' }
May 05 15:37:24 raspberrypi node[2954]: ERROR: MeshCentral failed with critical error, check MeshErrors.txt. Restarting in 5 seconds...
May 05 15:37:29 raspberrypi systemd[1]: Stopping MeshCentral Server...
May 05 15:37:29 raspberrypi systemd[1]: Stopped MeshCentral Server.
pi@raspberrypi:~ $ ps axu | grep mesh
pi 3535 0.0 0.0 4368 580 pts/0 S+ 15:37 0:00 grep --color=auto mesh
pi@raspberrypi:~ $ tree -augp /home/pi/meshcentral-data
/home/pi/meshcentral-data
+-- [-rw-r--r-- pi pi ] agentserver-cert-private.key
+-- [-rw-r--r-- pi pi ] agentserver-cert-public.crt
+-- [-rw-r--r-- pi pi ] config.json
+-- [-rw-r--r-- root root ] meshcentral.db
+-- [-rw-r--r-- root root ] meshcentral-events.db
+-- [-rw-r--r-- root root ] meshcentral-power.db
+-- [-rw-r--r-- pi pi ] meshcentral-smbios.db
+-- [-rw-r--r-- root root ] meshcentral-stats.db
+-- [-rw-r--r-- pi pi ] mesherrors.txt
+-- [-rw-r--r-- pi pi ] mpsserver-cert-private.key
+-- [-rw-r--r-- pi pi ] mpsserver-cert-public.crt
+-- [-rw-r--r-- pi pi ] root-cert-private.key
+-- [-rw-r--r-- pi pi ] root-cert-public.crt
+-- [-rw-r--r-- pi pi ] serverstate.txt
+-- [-rw-r--r-- pi pi ] webserver-cert-private.key
+-- [-rw-r--r-- pi pi ] webserver-cert-public.crt
0 directories, 16 files
pi@raspberrypi:~ $ sudo chown -R -c pi:pi /home/pi/meshcentral-data
changed ownership of '/home/pi/meshcentral-data/meshcentral-events.db' from root:root to pi:pi
changed ownership of '/home/pi/meshcentral-data/meshcentral.db' from root:root to pi:pi
changed ownership of '/home/pi/meshcentral-data/meshcentral-power.db' from root:root to pi:pi
changed ownership of '/home/pi/meshcentral-data/meshcentral-stats.db' from root:root to pi:pi
pi@raspberrypi:~ $ systemctl status meshcentral.service
? meshcentral.service - MeshCentral Server
Loaded: loaded (/etc/systemd/system/meshcentral.service; enabled; vendor preset: enabled)
Active: inactive (dead) since Sun 2019-05-05 15:37:29 BST; 1min 12s ago
Process: 2954 ExecStart=/usr/bin/node /home/pi/node_modules/meshcentral (code=killed, signal=TERM)
Main PID: 2954 (code=killed, signal=TERM)
May 05 15:37:24 raspberrypi node[2954]: at ChildProcess.emit (events.js:214:7)
May 05 15:37:24 raspberrypi node[2954]: at maybeClose (internal/child_process.js:915:16)
May 05 15:37:24 raspberrypi node[2954]: at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
May 05 15:37:24 raspberrypi node[2954]: killed: false,
May 05 15:37:24 raspberrypi node[2954]: code: 1,
May 05 15:37:24 raspberrypi node[2954]: signal: null,
May 05 15:37:24 raspberrypi node[2954]: cmd: '/usr/bin/node /home/pi/node_modules/meshcentral --launch' }
May 05 15:37:24 raspberrypi node[2954]: ERROR: MeshCentral failed with critical error, check MeshErrors.txt. Restarting in 5 seconds...
May 05 15:37:29 raspberrypi systemd[1]: Stopping MeshCentral Server...
May 05 15:37:29 raspberrypi systemd[1]: Stopped MeshCentral Server.
pi@raspberrypi:~ $ systemctl start meshcentral.service
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to start 'meshcentral.service'.
Multiple identities can be used for authentication:
1. ,,, (pi)
2. root
Choose identity to authenticate as (1-2): 1
Password:
==== AUTHENTICATION COMPLETE ===
pi@raspberrypi:~ $ systemctl status meshcentral.service
? meshcentral.service - MeshCentral Server
Loaded: loaded (/etc/systemd/system/meshcentral.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2019-05-05 15:38:57 BST; 2s ago
Main PID: 3994 (node)
CGroup: /system.slice/meshcentral.service
+-3994 /usr/bin/node /home/pi/node_modules/meshcentral
May 05 15:38:57 raspberrypi systemd[1]: Started MeshCentral Server.
pi@raspberrypi:~ $ nmap localhost
Starting Nmap 7.40 ( https://nmap.org ) at 2019-05-05 15:39 BST
Nmap scan report for localhost (127.0.0.1)
Host is up (0.00028s latency).
Other addresses for localhost (not scanned): ::1
Not shown: 997 closed ports
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
443/tcp open https
Nmap done: 1 IP address (1 host up) scanned in 0.29 seconds
pi@raspberrypi:~ $ systemctl status meshcentral.service
? meshcentral.service - MeshCentral Server
Loaded: loaded (/etc/systemd/system/meshcentral.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2019-05-05 15:38:57 BST; 14s ago
Main PID: 3994 (node)
CGroup: /system.slice/meshcentral.service
+-3994 /usr/bin/node /home/pi/node_modules/meshcentral
+-4021 /bin/sh -c /usr/bin/node /home/pi/node_modules/meshcentral --launch
+-4022 /usr/bin/node /home/pi/node_modules/meshcentral --launch
May 05 15:38:57 raspberrypi systemd[1]: Started MeshCentral Server.
May 05 15:39:04 raspberrypi node[3994]: MeshCentral HTTP redirection server running on port 80.
May 05 15:39:04 raspberrypi node[3994]: MeshCentral v0.3.3-t, LAN mode, Production mode.
May 05 15:39:05 raspberrypi node[3994]: MeshCentral HTTPS server running on port 443.
pi@raspberrypi:~ $
Thank you! It seems to work now and starts on reboot automatically.
At page 16 of install guide v0.0.6 it says:
After that, we can run MeshCentral for the first time. We want to run in WAN-only mode since we will not be managing any computers on the same local network at this server. We also want to create a server with a certificate name that is the same at the AWS instance name. So, we will use “--wanonly” and “--cert [name]” arguments to get the server started. For example:
node node_modules/meshcentral --lanonly --fastcert
At this point, the server will create its certificates and start running. MeshCentral HTTP redirection web server running on port 80.
Generating certificates, may take a few minutes...
Generating root certificate...
Generating HTTPS certificate...
Generating MeshAgent certificate...
Generating Intel AMT MPS certificate...
Generating Intel AMT console certificate...
Server name not configured, running in LAN-only mode.
MeshCentral HTTPS web server running on port 443.
Server has no users, next new account will be site administrator.
Although, I don't remember, why I issued it with sudo again after line 21 (history, first post).
So, if you install MeshCentral under root and then use to systemd to run it under a normal account, systemd will not have access for any of the MeshCentral files. You can fix this with "sudo chown -r pi " and "sudo chgrp -r pi " to make the file return back to the normal "pi" user, or delete and start over.
I will add a warning in the documentation about not installing MeshCentral as root.
I updated the MeshCentral installer's guide yesterday with a new warning box not to run "sudo npm install meshcentral". I will close this issue. Feel free to re-open if needed.
Hm, I didn't used sudo npm ..
, but
sudo node node_modules/meshcentral --lanonly --fastcert
Please, see the history in my first post.
Hello,
I installed MeshCentral accordingly to the install instructions to the raspberry pi install.
`
`
Maybe I didn't do it right to use sudo at line 22 (I think, I issued it, due to line 21, without sudo didn't worked?)
22 sudo node node_modules/meshcentral --lanonly --fastcert
When I use
systemctl start meshcentral.service
I receive an error, and the https server didn't show up.`
`
But it works, if I use sudo
`
`
How can I set the propper permissions at this time, so that the services are working, and I can start the node just with pi instead with sudo?