]> glassweightruler.freedombox.rocks Git - waydroid.git/commitdiff
tools: Add restart container
authorErfan Abdi <erfangplus@gmail.com>
Thu, 2 Sep 2021 12:48:22 +0000 (17:18 +0430)
committerErfan Abdi <erfangplus@gmail.com>
Thu, 2 Sep 2021 12:48:22 +0000 (17:18 +0430)
tools/__init__.py
tools/actions/container_manager.py
tools/helpers/arguments.py

index 555ea00c38ba46b02ce3f83f4b8e6fbe6f3ee2f9..13a6110b15ec0e266957376a4a5977d22bfb8271 100644 (file)
@@ -63,6 +63,8 @@ def main():
                 actions.container_manager.start(args)
             elif args.subaction == "stop":
                 actions.container_manager.stop(args)
+            if args.subaction == "restart":
+                actions.container_manager.restart(args)
             elif args.subaction == "freeze":
                 actions.container_manager.freeze(args)
             elif args.subaction == "unfreeze":
index ce04180b1414f1fdf478c888bd27b93effc184e1..776ced94a61a6fc7e99080d9f1ec2a6b729f1ae2 100644 (file)
@@ -213,6 +213,14 @@ def stop(args):
     else:
         logging.error("WayDroid container is {}".format(status))
 
+def restart(args):
+    status = helpers.lxc.status(args)
+    if status == "RUNNING":
+        helpers.lxc.stop(args)
+        helpers.lxc.start(args)
+    else:
+        logging.error("WayDroid container is {}".format(status))
+
 def freeze(args):
     status = helpers.lxc.status(args)
     if status == "RUNNING":
index 1879c76f1a8c3e002ad01023c43adee46b0e1be4..a7aa919927261cfea3d15d9838514db2de40b41f 100644 (file)
@@ -66,6 +66,7 @@ def arguments_container(subparser):
     sub = ret.add_subparsers(title="subaction", dest="subaction")
     sub.add_parser("start", help="start container")
     sub.add_parser("stop", help="start container")
+    sub.add_parser("restart", help="restart container")
     sub.add_parser("freeze", help="freeze container")
     sub.add_parser("unfreeze", help="unfreeze container")
     return ret