]> glassweightruler.freedombox.rocks Git - waydroid.git/commitdiff
initializer: Restart container through DBus
authorAlessandro Astone <ales.astone@gmail.com>
Sun, 29 Jan 2023 21:41:36 +0000 (22:41 +0100)
committerAlessandro Astone <ales.astone@gmail.com>
Sun, 29 Jan 2023 22:09:27 +0000 (23:09 +0100)
tools/actions/initializer.py

index d886fa1fb48cdad6db892c567961395e0677a757..ed885f5c5361f614ea438006525ac3a0fce36e1c 100644 (file)
@@ -113,8 +113,13 @@ def init(args):
             status = helpers.lxc.status(args)
         if status != "STOPPED":
             logging.info("Stopping container")
-            helpers.lxc.stop(args)
-        helpers.images.umount_rootfs(args)
+            try:
+                container = tools.helpers.ipc.DBusContainerService()
+                args.session = container.GetSession()
+                container.Stop(False)
+            except Exception as e:
+                logging.debug(e)
+                tools.actions.container_manager.stop(args)
         if args.images_path not in tools.config.defaults["preinstalled_images_paths"]:
             helpers.images.get(args)
         else:
@@ -134,8 +139,11 @@ def init(args):
         helpers.lxc.make_base_props(args)
         if status != "STOPPED":
             logging.info("Starting container")
-            helpers.images.mount_rootfs(args, args.images_path)
-            helpers.lxc.start(args)
+            try:
+                container.Start(args.session)
+            except Exception as e:
+                logging.debug(e)
+                logging.error("Failed to restart container. Please do so manually.")
 
         if "running_init_in_service" not in args or not args.running_init_in_service:
             try: