diff --git a/ovos_PHAL_plugin_system/__init__.py b/ovos_PHAL_plugin_system/__init__.py index 9c87845..4a07d05 100644 --- a/ovos_PHAL_plugin_system/__init__.py +++ b/ovos_PHAL_plugin_system/__init__.py @@ -61,6 +61,7 @@ def __init__(self, bus=None, config=None): self.bus.on("system.mycroft.service.restart.start", self.handle_mycroft_restarting) self.core_service_name = config.get("core_service") or "ovos.service" + self.core_service_is_user = config.get("core_service_is_user", True) # In Debian, ssh stays active, but sshd is removed when ssh is disabled self.ssh_service = config.get("ssh_service") or "sshd.service" self.use_root = config.get("sudo", True) @@ -287,15 +288,13 @@ def handle_mycroft_restarting(self, message: Message): def handle_mycroft_restart_request(self, message: Message): service = self.core_service_name self.bus.emit(message.forward("system.mycroft.service.restart.start", message.data)) - # TODO - clean up this mess + try: - restart_service(service, sudo=False, user=True) - except: - try: - restart_service(service, sudo=True, user=False) - except: - LOG.error("No mycroft or ovos service installed") - return False + restart_service(service, sudo=self.use_root, + user=self.core_service_is_user) + except Exception as e: + LOG.error(f"Failed to restart service: {e}") + self.gui.clear() # Release the GUI def handle_ssh_status(self, message: Message): """