diff --git a/kiauh/components/moonraker/moonraker.py b/kiauh/components/moonraker/moonraker.py index aa0e03b..994cba0 100644 --- a/kiauh/components/moonraker/moonraker.py +++ b/kiauh/components/moonraker/moonraker.py @@ -35,12 +35,17 @@ class Moonraker(BaseInstance): self.backup_dir = self.data_dir.joinpath("backup") self.certs_dir = self.data_dir.joinpath("certs") self._db_dir = self.data_dir.joinpath("database") + self._comms_dir = self.data_dir.joinpath("comms") self.log = self.log_dir.joinpath("moonraker.log") @property def db_dir(self) -> Path: return self._db_dir + @property + def comms_dir(self) -> Path: + return self._comms_dir + def create(self, create_example_cfg: bool = False) -> None: Logger.print_status("Creating new Moonraker Instance ...") service_template_path = MODULE_PATH.joinpath("assets/moonraker.service") diff --git a/kiauh/components/moonraker/moonraker_utils.py b/kiauh/components/moonraker/moonraker_utils.py index e7ea965..a2a8c22 100644 --- a/kiauh/components/moonraker/moonraker_utils.py +++ b/kiauh/components/moonraker/moonraker_utils.py @@ -150,13 +150,27 @@ def moonraker_to_multi_conversion(new_name: str) -> None: return Logger.print_status("Convert Moonraker single to multi instance ...") + # remove the old single instance im.current_instance = im.instances[0] im.stop_instance() im.disable_instance() im.delete_instance() - # create a new klipper instance with the new name - im.current_instance = Moonraker(suffix=new_name) + + # create a new moonraker instance with the new name + new_instance = Moonraker(suffix=new_name) + im.current_instance = new_instance + + # patch the server sections klippy_uds_address value to match the new printer_data foldername + cm = ConfigManager(new_instance.cfg_file) + if cm.config.has_section("server"): + cm.set_value( + "server", + "klippy_uds_address", + str(new_instance.comms_dir.joinpath("klippy.sock")), + ) + cm.write_config() + # create, enable and start the new moonraker instance im.create_instance() im.enable_instance()