添加linux支持(移除多盘支持)(未测试)
This commit is contained in:
parent
468d7bdede
commit
125cf129ac
|
@ -9,6 +9,7 @@ import os
|
||||||
import shutil
|
import shutil
|
||||||
import json
|
import json
|
||||||
import platform
|
import platform
|
||||||
|
import string
|
||||||
|
|
||||||
############ Config ############
|
############ Config ############
|
||||||
KEYWORD = "winpe"
|
KEYWORD = "winpe"
|
||||||
|
@ -16,28 +17,51 @@ PYTHON = "python"
|
||||||
DISK = "{disk}"
|
DISK = "{disk}"
|
||||||
################################
|
################################
|
||||||
|
|
||||||
# if you using Linux based OS, please run this command: mount /dev/sdX /mnt/disk --mkdir
|
|
||||||
# DISK = "/mnt/disk"
|
|
||||||
|
|
||||||
|
|
||||||
def find_disk():
|
def find_disk():
|
||||||
if platform.system() == 'Linux':
|
|
||||||
if "{disk}" in DISK:
|
|
||||||
raise OSError(
|
|
||||||
"Cannot auto find the Ventoy disk in Linux! Please change \"DISK\"")
|
|
||||||
elif platform.system() == 'Windows':
|
|
||||||
ventoy_drives = []
|
ventoy_drives = []
|
||||||
|
if platform.system() == 'Linux':
|
||||||
|
mount_point = "/mnt/prinjector_mount_point"
|
||||||
|
if not os.path.exists(mount_point):
|
||||||
|
os.mkdir(mount_point)
|
||||||
|
elif len(os.listdir(mount_point)):
|
||||||
|
raise OSError("Mount point {} not empty!".format(mount_point))
|
||||||
|
|
||||||
|
i: int = 97
|
||||||
|
while os.path.exists(f"/dev/sd{chr(i)}"):
|
||||||
|
j: int = 1
|
||||||
|
this_disk = f"/dev/sd{chr(i)}{str(j)}"
|
||||||
|
while os.path.exists(this_disk):
|
||||||
|
os.system(f"mount /dev/sd{chr(i)}{str(j)} {mount_point}")
|
||||||
|
if os.path.exists(mount_point+"/ventoy/ventoy.json"):
|
||||||
|
return mount_point
|
||||||
|
j += 1
|
||||||
|
os.system(f"umount {mount_point}")
|
||||||
|
i += 1
|
||||||
|
|
||||||
|
i: int = 0
|
||||||
|
while os.path.exists(f"/dev/nvme{str(i)}"):
|
||||||
|
j: int = 1
|
||||||
|
while os.path.exists(f"/dev/nvme{str(i)}n{str(j)}"):
|
||||||
|
k: int = 1
|
||||||
|
while os.path.exists(f"/dev/nvme{str(i)}n{str(j)}p{str(k)}"):
|
||||||
|
os.system(
|
||||||
|
f"mount /dev/nvme{str(i)}n{str(j)}p{str(k)} {mount_point}")
|
||||||
|
if os.path.exists(mount_point+"/ventoy/ventoy.json"):
|
||||||
|
return mount_point
|
||||||
|
k += 1
|
||||||
|
os.system(f"umount {mount_point}")
|
||||||
|
j += 1
|
||||||
|
i += 1
|
||||||
|
|
||||||
|
elif platform.system() == 'Windows':
|
||||||
for i in "CDEFGHIJKABLMNOPQRSTUVWYZ":
|
for i in "CDEFGHIJKABLMNOPQRSTUVWYZ":
|
||||||
this_disk = i+":"
|
this_disk = i+":"
|
||||||
if os.path.exists(this_disk + "/ventoy/ventoy.json"):
|
if os.path.exists(this_disk + "/ventoy/ventoy.json"):
|
||||||
ventoy_drives.append(this_disk)
|
return this_disk
|
||||||
if len(ventoy_drives) != 1:
|
|
||||||
for (index, value) in enumerate(ventoy_drives):
|
|
||||||
print(f"{i}:{ventoy_drives[i]}", end=" ")
|
|
||||||
return ventoy_drives[int(input("Please choose your Ventoy device:"))]
|
|
||||||
else:
|
else:
|
||||||
raise OSError(f"Unsupported operating system:{platform.system()}")
|
raise OSError(f"Unsupported operating system:{platform.system()}")
|
||||||
|
|
||||||
raise OSError(
|
raise OSError(
|
||||||
"Cannot find the Ventoy disk!(try to run ventoyPlugson once)")
|
"Cannot find the Ventoy disk!(try to run ventoyPlugson once)")
|
||||||
|
|
||||||
|
@ -109,7 +133,7 @@ print("Writing version info")
|
||||||
shutil.copyfile("version", DISK+"/PEinjector/VERSION")
|
shutil.copyfile("version", DISK+"/PEinjector/VERSION")
|
||||||
|
|
||||||
|
|
||||||
print("Making dir")
|
print("Creating dir")
|
||||||
if not os.path.exists(DISK+"/PEinjector/install"):
|
if not os.path.exists(DISK+"/PEinjector/install"):
|
||||||
os.mkdir(DISK+"/PEinjector/install")
|
os.mkdir(DISK+"/PEinjector/install")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue