mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-12 17:20:30 +08:00
deprecated X-kvmd.[otgmsd|pst]-root
This commit is contained in:
parent
8682a4ac90
commit
b906d7f74c
@ -38,8 +38,7 @@ _FSTAB_PATH = "/etc/fstab"
|
|||||||
# =====
|
# =====
|
||||||
@dataclasses.dataclass(frozen=True)
|
@dataclasses.dataclass(frozen=True)
|
||||||
class _Storage:
|
class _Storage:
|
||||||
mount_path: str
|
path: str
|
||||||
root_path: str
|
|
||||||
user: str
|
user: str
|
||||||
|
|
||||||
|
|
||||||
@ -56,11 +55,10 @@ def _find_storage(target: str) -> _Storage:
|
|||||||
if line and not line.startswith("#"):
|
if line and not line.startswith("#"):
|
||||||
parts = line.split()
|
parts = line.split()
|
||||||
if len(parts) == 6:
|
if len(parts) == 6:
|
||||||
options = dict(re.findall(r"X-kvmd\.%s-(root|user)=([^,]+)" % (target), parts[3]))
|
options = dict(re.findall(r"X-kvmd\.%s-(user)=([^,]+)" % (target), parts[3]))
|
||||||
if options:
|
if options:
|
||||||
return _Storage(
|
return _Storage(
|
||||||
mount_path=parts[1],
|
path=parts[1],
|
||||||
root_path=options.get("root", ""),
|
|
||||||
user=options.get("user", ""),
|
user=options.get("user", ""),
|
||||||
)
|
)
|
||||||
raise SystemExit(f"Can't find {target!r} mountpoint in {_FSTAB_PATH}")
|
raise SystemExit(f"Can't find {target!r} mountpoint in {_FSTAB_PATH}")
|
||||||
@ -112,10 +110,10 @@ def main() -> None:
|
|||||||
rw = (sys.argv[1] == "rw")
|
rw = (sys.argv[1] == "rw")
|
||||||
|
|
||||||
storage = _find_storage(target)
|
storage = _find_storage(target)
|
||||||
_remount(storage.mount_path, rw)
|
_remount(storage.path, rw)
|
||||||
if rw and storage.root_path:
|
if rw:
|
||||||
for name in dirs:
|
for name in dirs:
|
||||||
path = os.path.join(storage.root_path, name)
|
path = os.path.join(storage.path, name)
|
||||||
_mkdir(path)
|
_mkdir(path)
|
||||||
if storage.user:
|
if storage.user:
|
||||||
_chown(path, storage.user)
|
_chown(path, storage.user)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user