mirror of
https://github.com/bin456789/reinstall.git
synced 2025-01-19 04:49:13 +08:00
windows: 添加 image-name 纠错机制
This commit is contained in:
parent
1fb1a26dd4
commit
115b8c4e56
32
trans.sh
32
trans.sh
@ -2719,14 +2719,34 @@ install_windows() {
|
|||||||
|
|
||||||
# 匹配映像版本
|
# 匹配映像版本
|
||||||
# 需要整行匹配,因为要区分 Windows 10 Pro 和 Windows 10 Pro for Workstations
|
# 需要整行匹配,因为要区分 Windows 10 Pro 和 Windows 10 Pro for Workstations
|
||||||
# TODO: 如果无法匹配,等待用户输入?安装第一个?
|
image_count=$(wiminfo $install_wim | grep "^Image Count:" | cut -d: -f2 | xargs)
|
||||||
image_count=$(wiminfo $install_wim | grep "Image Count:" | cut -d: -f2 | xargs)
|
all_image_names=$(wiminfo $install_wim | grep ^Name: | sed 's/^Name: *//')
|
||||||
|
|
||||||
if [ "$image_count" = 1 ]; then
|
if [ "$image_count" = 1 ]; then
|
||||||
# 只有一个版本就使用第一个版本
|
# 只有一个版本就用那个版本
|
||||||
image_name=$(wiminfo $install_wim | grep -ix "Name:[[:space:]]*.*" | cut -d: -f2 | xargs)
|
image_name=$all_image_names
|
||||||
else
|
else
|
||||||
# 否则改成正确的大小写
|
while true; do
|
||||||
image_name=$(wiminfo $install_wim | grep -ix "Name:[[:space:]]*$image_name" | cut -d: -f2 | xargs)
|
# 匹配成功
|
||||||
|
# 改成正确的大小写
|
||||||
|
if matched_image_name=$(echo "$all_image_names" | grep -ix "$image_name"); then
|
||||||
|
image_name=$matched_image_name
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 匹配失败
|
||||||
|
error "Invalid image name: $image_name"
|
||||||
|
echo "Choose a correct image name by one of follow command and continue:"
|
||||||
|
while read -r line; do
|
||||||
|
echo " echo '$line' >/image-name"
|
||||||
|
done < <(echo "$all_image_names")
|
||||||
|
|
||||||
|
# sleep 直到有输入
|
||||||
|
echo >/image-name
|
||||||
|
until [ -f /image-name ] && image_name=$(xargs </image-name) && [ -n "$image_name" ]; do
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
echo "Image Name: $image_name"
|
echo "Image Name: $image_name"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user