machine: move default allowed services to an asset file
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
98bb40bd80
commit
affe196ff6
|
@ -0,0 +1,10 @@
|
||||||
|
klipper_mcu
|
||||||
|
webcamd
|
||||||
|
MoonCord
|
||||||
|
KlipperScreen
|
||||||
|
moonraker-telegram-bot
|
||||||
|
moonraker-obico
|
||||||
|
sonar
|
||||||
|
crowsnest
|
||||||
|
octoeverywhere
|
||||||
|
ratos-configurator
|
|
@ -56,18 +56,6 @@ if TYPE_CHECKING:
|
||||||
SudoReturn = Union[Awaitable[Tuple[str, bool]], Tuple[str, bool]]
|
SudoReturn = Union[Awaitable[Tuple[str, bool]], Tuple[str, bool]]
|
||||||
SudoCallback = Callable[[], SudoReturn]
|
SudoCallback = Callable[[], SudoReturn]
|
||||||
|
|
||||||
DEFAULT_ALLOWED_SERVICES = [
|
|
||||||
"klipper_mcu",
|
|
||||||
"webcamd",
|
|
||||||
"MoonCord",
|
|
||||||
"KlipperScreen",
|
|
||||||
"moonraker-telegram-bot",
|
|
||||||
"moonraker-obico",
|
|
||||||
"sonar",
|
|
||||||
"crowsnest",
|
|
||||||
"octoeverywhere",
|
|
||||||
"ratos-configurator"
|
|
||||||
]
|
|
||||||
CGROUP_PATH = "/proc/1/cgroup"
|
CGROUP_PATH = "/proc/1/cgroup"
|
||||||
SCHED_PATH = "/proc/1/sched"
|
SCHED_PATH = "/proc/1/sched"
|
||||||
SYSTEMD_PATH = "/etc/systemd/system"
|
SYSTEMD_PATH = "/etc/systemd/system"
|
||||||
|
@ -198,14 +186,14 @@ class Machine:
|
||||||
fpath = pathlib.Path(data_path).joinpath("moonraker.asvc")
|
fpath = pathlib.Path(data_path).joinpath("moonraker.asvc")
|
||||||
fm: FileManager = self.server.lookup_component("file_manager")
|
fm: FileManager = self.server.lookup_component("file_manager")
|
||||||
fm.add_reserved_path("allowed_services", fpath, False)
|
fm.add_reserved_path("allowed_services", fpath, False)
|
||||||
|
default_svcs = source_info.read_asset("default_allowed_services") or ""
|
||||||
try:
|
try:
|
||||||
if not fpath.exists():
|
if not fpath.exists():
|
||||||
fpath.write_text("\n".join(DEFAULT_ALLOWED_SERVICES))
|
fpath.write_text(default_svcs)
|
||||||
data = fpath.read_text()
|
data = fpath.read_text()
|
||||||
except Exception:
|
except Exception:
|
||||||
logging.exception("Failed to read allowed_services.txt")
|
logging.exception("Failed to read moonraker.asvc")
|
||||||
self._allowed_services = DEFAULT_ALLOWED_SERVICES
|
data = default_svcs
|
||||||
else:
|
|
||||||
svcs = [svc.strip() for svc in data.split("\n") if svc.strip()]
|
svcs = [svc.strip() for svc in data.split("\n") if svc.strip()]
|
||||||
for svc in svcs:
|
for svc in svcs:
|
||||||
if svc.endswith(".service"):
|
if svc.endswith(".service"):
|
||||||
|
|
Loading…
Reference in New Issue