diff --git a/reinstall.sh b/reinstall.sh index 6563303..564e272 100644 --- a/reinstall.sh +++ b/reinstall.sh @@ -66,7 +66,7 @@ curl() { # 添加 -f, --fail,不然 404 退出码也为0 # 32位 cygwin 已停止更新,证书可能有问题,先添加 --insecure grep -o 'http[^ ]*' <<<"$@" >&2 - command curl --insecure --connect-timeout 5 --retry 2 --retry-delay 1 -f "$@" + command curl --insecure --connect-timeout 10 --retry 5 --retry-delay 1 -f "$@" } is_in_china() { @@ -653,12 +653,6 @@ verify_os_args() { if [ -z "$iso" ] || [ -z "$image_name" ]; then error_and_exit "Install Windows need --iso and --image-name" fi - # 防止常见错误 - # --image-name 肯定大于等于3个单词 - if [ "$(echo "$image_name" | wc -w)" -lt 3 ] || - [[ "$(to_lower <<<"$image_name")" != windows* ]]; then - error_and_exit "--image-name wrong." - fi ;; esac } @@ -992,7 +986,7 @@ get_disk_by_part() { get_part_num_by_part() { dev_part=$1 - grep -o '[0-9]*' <<<"$dev_part" | tail -1 + grep -oE '[0-9]*$' <<<"$dev_part" } grep_efi_index() { diff --git a/trans.sh b/trans.sh index e12ac9d..1e94aaa 100644 --- a/trans.sh +++ b/trans.sh @@ -55,7 +55,7 @@ add_community_repo() { # busybox 的 wget 没有重试功能 wget() { - for i in 1 2 3; do + for i in $(seq 5); do command wget "$@" && return done } @@ -102,17 +102,20 @@ download() { # Exception: [AbstractCommand.cc:351] errorCode=1 URI=https://aka.ms/manawindowsdrivers # -> [SocketCore.cc:1019] errorCode=1 SSL/TLS handshake failure: `not signed by known authorities or invalid' + # 用 if 的话,报错不会中断脚本 + # if aria2c xxx; then + # return + # fi + echo "$url" - for i in 1 2 3; do - if stdbuf -oL -eL \ + for i in $(seq 5); do + stdbuf -oL -eL \ aria2c -x4 \ --allow-overwrite=true \ --summary-interval=0 \ --user-agent=Wget/1.21.1 \ --max-tries 1 \ - $save $url; then - return - fi + $save $url && return done } @@ -120,7 +123,7 @@ update_part() { sleep 1 # 玄学 - for i in 1 2 3; do + for i in $(seq 3); do sync partprobe /dev/$xda 2>/dev/null @@ -1961,19 +1964,21 @@ install_windows() { # aws nitro # 只有 x64 位驱动 # 可能不支持 vista + # 未打补丁的 win7 无法使用 sha256 签名的驱动 # https://docs.aws.amazon.com/zh_cn/AWSEC2/latest/WindowsGuide/aws-nvme-drivers.html # https://docs.aws.amazon.com/zh_cn/AWSEC2/latest/WindowsGuide/enhanced-networking-ena.html nvme_ver=$( case "$nt_ver" in - 6.0 | 6.1) echo 1.3.2 ;; + 6.0 | 6.1) echo 1.3.2 ;; # sha1 签名 *) echo Latest ;; esac ) ena_ver=$( case "$nt_ver" in - 6.0 | 6.1) echo 2.2.3 ;; + 6.0 | 6.1) echo 2.1.4 ;; # sha1 签名 + # 6.0 | 6.1) echo 2.2.3 ;; # sha256 签名 6.2 | 6.3) echo 2.6.0 ;; *) echo Latest ;; esac @@ -1995,7 +2000,8 @@ install_windows() { aws_pv_ver=$( case "$nt_ver" in - 6.0 | 6.1) echo 8.3.5 ;; + 6.0 | 6.1) echo 8.3.2 ;; # sha1 签名 + # 6.0 | 6.1) echo 8.3.5 ;; # sha256 签名 *) echo Latest ;; esac ) @@ -2092,7 +2098,7 @@ install_windows() { grep -i EVAL "$ei_cfg"; then # 评估版 iso 需要删除 autounattend.xml 里面的 # 否则会出现 Windows Cannot find Microsoft software license terms - sed -i "/%Key%/d" /tmp/autounattend.xml + sed -i "/%key%/d" /tmp/autounattend.xml else # vista 需密钥,密钥可与 edition 不一致 # 其他系统要空密钥