X-Git-Url: https://glassweightruler.freedombox.rocks/gitweb/waydroid.git/blobdiff_plain/1be55b971dadcf952aeed25d7c84efc2b71d4c85..ff4cf1c83f09e639504209dec68855cdf3c69bce:/tools/helpers/lxc.py?ds=sidebyside diff --git a/tools/helpers/lxc.py b/tools/helpers/lxc.py index 19a7ceb..cac4bb5 100644 --- a/tools/helpers/lxc.py +++ b/tools/helpers/lxc.py @@ -132,8 +132,8 @@ def generate_nodes_lxc_config(args): LXC_APPARMOR_PROFILE = "lxc-waydroid" def get_apparmor_status(args): enabled = False - if shutil.which("aa-status"): - enabled = (tools.helpers.run.user(args, ["aa-status", "--quiet"], check=False) == 0) + if shutil.which("aa-enabled"): + enabled = (tools.helpers.run.user(args, ["aa-enabled", "--quiet"], check=False) == 0) if not enabled and shutil.which("systemctl"): enabled = (tools.helpers.run.user(args, ["systemctl", "is-active", "-q", "apparmor"], check=False) == 0) try: @@ -367,8 +367,11 @@ def unfreeze(args): tools.helpers.run.user(args, command) def shell(args): - if status(args) != "RUNNING": - logging.error("WayDroid container is {}".format(status(args))) + state = status(args) + if state == "FROZEN": + unfreeze(args) + elif state != "RUNNING": + logging.error("WayDroid container is {}".format(state)) return command = ["lxc-attach", "-P", tools.config.defaults["lxc"], "-n", "waydroid", "--"] @@ -377,11 +380,18 @@ def shell(args): else: command.append("/system/bin/sh") subprocess.run(command, env={"PATH": os.environ['PATH'] + ":/system/bin:/vendor/bin"}) + if state == "FROZEN": + freeze(args) def logcat(args): - if status(args) != "RUNNING": - logging.error("WayDroid container is {}".format(status(args))) + state = status(args) + if state == "FROZEN": + unfreeze(args) + elif state != "RUNNING": + logging.error("WayDroid container is {}".format(state)) return command = ["lxc-attach", "-P", tools.config.defaults["lxc"], "-n", "waydroid", "--", "/system/bin/logcat"] subprocess.run(command) + if state == "FROZEN": + freeze(args)