docs: update "machine" component documentation

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Eric Callahan 2022-08-21 07:16:15 -04:00
parent db7474aa88
commit e3cafb58bc
No known key found for this signature in database
GPG Key ID: 5A1EB336DFB4C71B
2 changed files with 66 additions and 1 deletions

View File

@ -127,6 +127,12 @@ provider: systemd_dbus
# and run service actions (ie: start, restart, stop). This can be "none", # and run service actions (ie: start, restart, stop). This can be "none",
# "systemd_dbus", or "systemd_cli". If the provider is set to "none" service # "systemd_dbus", or "systemd_cli". If the provider is set to "none" service
# action APIs will be disabled. The default is systemd_dbus. # action APIs will be disabled. The default is systemd_dbus.
sudo_password:
# The password for the linux user. When set Moonraker can run linux commands
# that require elevated permissions. This option accepts Jinja2 Templates,
# see the [secrets] section for details. It is strongly recommended to only
# set this option when required and to use the aforementioned secrets module
# when doing so. The default is no sudo password is set.
``` ```
!!! Note !!! Note
@ -138,7 +144,9 @@ provider: systemd_dbus
service. This service is necessary for the DBus provider to issue service. This service is necessary for the DBus provider to issue
`reboot` and `shutdown` commands. In this scenario, Moonraker will fall `reboot` and `shutdown` commands. In this scenario, Moonraker will fall
back to CLI based `reboot` and `shutdown` commands. These commands require back to CLI based `reboot` and `shutdown` commands. These commands require
that Moonraker be able to run `sudo` commands without a password. that Moonraker be able to run `sudo` commands without a password or that the
`sudo_password` option is set.
Alternatively it may be possible to enable the `systemd-logind` service, Alternatively it may be possible to enable the `systemd-logind` service,
consult with your distributions's documentation. consult with your distributions's documentation.

View File

@ -1356,6 +1356,63 @@ object reports total cpu usage, while each `cpuX` field is usage per core.
The `websocket_connections` field reports the number of active websockets The `websocket_connections` field reports the number of active websockets
currently connected to moonraker. currently connected to moonraker.
#### Check sudo access
Checks if Moonraker has permission to run commands as root.
HTTP request:
```http
GET /machine/sudo
```
JSON-RPC request:
```json
{
"jsonrpc": "2.0",
"method": "machine.sudo",
"id": 7896
}
```
Returns:
An object in the following format:
```json
{
"sudo_access": true
}
```
#### Set sudo password
Sets/updates the sudo password currently used by Moonraker. When
the password is set using this endpoint the change is not persistent
across restarts.
HTTP request:
```http
POST /machine/sudo/password
Content-Type: application/json
{
"password": "linux_user_password"
}
```
JSON-RPC request:
```json
{
"jsonrpc": "2.0",
"method": "machine.sudo.password",
"params": {
"password": "linux_user_password"
},
"id": 7896
}
```
Returns:
`ok` on success. If the new password does not grant root permissions
the request will return with an error.
### File Operations ### File Operations
Most file operations are available over both APIs, however file upload and Most file operations are available over both APIs, however file upload and