From e3cafb58bcdafe08035f57b42e1b042288f0f203 Mon Sep 17 00:00:00 2001 From: Eric Callahan Date: Sun, 21 Aug 2022 07:16:15 -0400 Subject: [PATCH] docs: update "machine" component documentation Signed-off-by: Eric Callahan --- docs/configuration.md | 10 +++++++- docs/web_api.md | 57 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 1 deletion(-) diff --git a/docs/configuration.md b/docs/configuration.md index 165d46e..0c5c615 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -127,6 +127,12 @@ provider: systemd_dbus # 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 # 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 @@ -138,7 +144,9 @@ provider: systemd_dbus service. This service is necessary for the DBus provider to issue `reboot` and `shutdown` commands. In this scenario, Moonraker will fall 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, consult with your distributions's documentation. diff --git a/docs/web_api.md b/docs/web_api.md index 9f7c085..b30a878 100644 --- a/docs/web_api.md +++ b/docs/web_api.md @@ -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 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 Most file operations are available over both APIs, however file upload and