file_manager: allow directories in "/etc/moonraker" to be registered
This may be useful for system packaging options that do not wish to put configuration in the home directory. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
684ff07ba2
commit
9a309ffd59
|
@ -44,12 +44,13 @@ config_path:
|
|||
# The path to a directory where configuration files are located. This
|
||||
# directory may contain Klipper config files (printer.cfg) or Moonraker
|
||||
# config files (moonraker.conf). Clients may also write their own config
|
||||
# files to this directory. This path must be located within the user's
|
||||
# HOME directory, but may not be the home directory itself. When this
|
||||
# option is set the contents of the directory will be served to connected
|
||||
# clients, allowing them to modify the various configuration files. NOTE:
|
||||
# If the config_path is not set, clients will not be able to save their
|
||||
# UI configuration to disk.
|
||||
# files to this directory. There are restrictions on the location of
|
||||
# this path, it must be located within the users HOME directory or within
|
||||
# "/etc/moonraker". The path may not be the HOME directory itself. It is
|
||||
# valid for the path to be "/etc/moonraker", however this is not recommended.
|
||||
# Something like "/etc/moonraker/config" would be a more appropriate option.
|
||||
# If you choose to locate files in "/etc/moonraker" be sure that Moonraker
|
||||
# has read/write permissions in this directory.
|
||||
```
|
||||
## authorization
|
||||
|
||||
|
|
|
@ -150,9 +150,14 @@ path: ~/gcode_files
|
|||
```
|
||||
NOTES:
|
||||
- While Klipper does not set any hard limits on the location of the
|
||||
`path` option for the `virtual_sdcard`, Moonraker requires that the path
|
||||
be located within the HOME directory, it cannot however be the HOME
|
||||
directory. If you wish to host your files elsewhere, use a symlink.
|
||||
`path` option for the `virtual_sdcard`, Moonraker does have specific
|
||||
requirements for the location of this folder:
|
||||
- It must be directory located in the HOME path or in `/etc/moonraker`
|
||||
- It may not be the HOME directory itself. It is ok for this folder
|
||||
to be `/etc/moonraker`, however that is not recommended. Something
|
||||
like `/etc/moonraker/gcode_files` would be more appropriate.
|
||||
- If you choose to place files in `/etc/moonraker` you must be sure that
|
||||
Moonraker has permission to read/write to the directory.
|
||||
- Upon first starting Moonraker is not aware of the gcode file path, thus
|
||||
it cannot serve gcode files, add directories, etc. After Klippy enters
|
||||
the "ready" state it sends Moonraker the gcode file path.
|
||||
|
|
|
@ -15,6 +15,7 @@ from tornado.locks import Event
|
|||
|
||||
VALID_GCODE_EXTS = ['.gcode', '.g', '.gco']
|
||||
FULL_ACCESS_ROOTS = ["gcodes", "config"]
|
||||
ETC_DIR = "/etc/moonraker"
|
||||
METADATA_SCRIPT = os.path.normpath(os.path.join(
|
||||
os.path.dirname(__file__), "../../scripts/extract_metadata.py"))
|
||||
|
||||
|
@ -85,8 +86,8 @@ class FileManager:
|
|||
return False
|
||||
home = os.path.expanduser('~')
|
||||
path = os.path.normpath(os.path.expanduser(path))
|
||||
if not os.path.isdir(path) or not path.startswith(home) or \
|
||||
path == home:
|
||||
if not os.path.isdir(path) or path == home or \
|
||||
not (path.startswith(home) or path.startswith(ETC_DIR)):
|
||||
logging.info(
|
||||
f"\nSupplied path ({path}) for ({root}) not valid. Please\n"
|
||||
"check that the path exists and is a subfolder in the HOME\n"
|
||||
|
|
Loading…
Reference in New Issue