mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-17 11:50:23 +08:00
Make kvmd-net start/stop work without error while changing configuration (#76)
This commit is contained in:
parent
9f44a120a7
commit
04f9bbe568
@ -68,11 +68,16 @@ def _rmdir(path: str) -> None:
|
|||||||
os.rmdir(path)
|
os.rmdir(path)
|
||||||
|
|
||||||
|
|
||||||
def _unlink(path: str) -> None:
|
def _unlink(path: str, optional: bool=False) -> None:
|
||||||
get_logger().info("RM ------ %s", path)
|
logger = get_logger()
|
||||||
|
if optional and not os.access(path, os.F_OK):
|
||||||
|
logger.info("SKIP ---- %s", path)
|
||||||
|
return
|
||||||
|
logger.info("RM ------ %s", path)
|
||||||
os.unlink(path)
|
os.unlink(path)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def _write(path: str, text: str, optional: bool=False) -> None:
|
def _write(path: str, text: str, optional: bool=False) -> None:
|
||||||
logger = get_logger()
|
logger = get_logger()
|
||||||
if optional and not os.access(path, os.F_OK):
|
if optional and not os.access(path, os.F_OK):
|
||||||
@ -267,8 +272,7 @@ def _cmd_stop(config: Section) -> None:
|
|||||||
logger.info("Disabling gadget %r ...", config.otg.gadget)
|
logger.info("Disabling gadget %r ...", config.otg.gadget)
|
||||||
_write(join(gadget_path, "UDC"), "")
|
_write(join(gadget_path, "UDC"), "")
|
||||||
|
|
||||||
if config.otg.devices.ethernet.driver == "rndis":
|
_unlink(join(gadget_path, "os_desc/c.1"), True)
|
||||||
_unlink(join(gadget_path, "os_desc/c.1"))
|
|
||||||
|
|
||||||
config_path = join(gadget_path, "configs/c.1")
|
config_path = join(gadget_path, "configs/c.1")
|
||||||
for func in os.listdir(config_path):
|
for func in os.listdir(config_path):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user