This commit is contained in:
Rikka
2023-05-27 16:55:29 +08:00
parent 6922bdba0d
commit 48ea54fc3e
14 changed files with 336 additions and 300 deletions
+20 -30
View File
@@ -1,22 +1,22 @@
import configparser
import os
import sys
import dbus
# import dbus
from tools.helper import run
from tools.logger import Logger
def DBusContainerService(object_path="/ContainerManager", intf="id.waydro.ContainerManager"):
return dbus.Interface(dbus.SystemBus().get_object("id.waydro.Container", object_path), intf)
# def DBusContainerService(object_path="/ContainerManager", intf="id.waydro.ContainerManager"):
# return dbus.Interface(dbus.SystemBus().get_object("id.waydro.Container", object_path), intf)
def DBusSessionService(object_path="/SessionManager", intf="id.waydro.SessionManager"):
return dbus.Interface(dbus.SessionBus().get_object("id.waydro.Session", object_path), intf)
# def DBusSessionService(object_path="/SessionManager", intf="id.waydro.SessionManager"):
# return dbus.Interface(dbus.SessionBus().get_object("id.waydro.Session", object_path), intf)
def use_dbus():
try:
DBusContainerService()
except:
return False
return True
# def use_dbus():
# try:
# DBusContainerService()
# except:
# return False
# return True
def use_overlayfs():
cfg = configparser.ConfigParser()
@@ -34,30 +34,20 @@ def use_overlayfs():
return False
def get_session():
return DBusContainerService().GetSession()
# def get_session():
# return DBusContainerService().GetSession()
def stop():
if use_dbus():
session = DBusContainerService().GetSession()
if session:
DBusContainerService().Stop(False)
else:
# if use_dbus():
# session = DBusContainerService().GetSession()
# if session:
# DBusContainerService().Stop(False)
# else:
run(["waydroid", "container", "stop"])
def start(*session):
if use_dbus() and session:
DBusContainerService().Start(session[0])
else:
run(["systemctl", "restart", "waydroid-container.service"])
def is_running():
if use_dbus():
if DBusContainerService().GetSession():
return True
return False
else:
return "Session:\tRUNNING" in run(["waydroid", "status"]).stdout.decode()
def upgrade():
run(["waydroid", "upgrade", "-o"], ignore=r"\[.*\] Stopping container\n\[.*\] Starting container")
-3
View File
@@ -131,6 +131,3 @@ def check_root():
if os.geteuid() != 0:
Logger.error("This script must be run as root. Aborting.")
sys.exit(1)
def upgrade():
run(["waydroid", "upgrade", "-o"], ignore=r"\[.*\] Stopping container\n\[.*\] Starting container")