From 19198a61463061474bab5fa4c86a5d0c11552095 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Fri, 16 May 2025 19:06:07 +0800 Subject: [PATCH] =?UTF-8?q?windows:=20=E6=8F=90=E7=A4=BA=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E8=BE=93=E5=85=A5=20iso=20=E7=9B=B4=E9=93=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.en.md | 13 +++++-------- README.md | 7 ++----- reinstall.sh | 43 +++++++++++++++++++++++++------------------ 3 files changed, 32 insertions(+), 31 deletions(-) diff --git a/README.en.md b/README.en.md index e50f003..a0086b4 100644 --- a/README.en.md +++ b/README.en.md @@ -15,7 +15,7 @@ One-Click Script to Reinstall System [中文](README.md) ## Highlights - One-click Linux installation: Supports 19 common distributions. -- One-click Windows installation: Uses the official ISO for installation instead of custom images. The script can automatically ~~retrieves the ISO link~~ and installs common drivers like `Virtio`. +- One-click Windows installation: Uses the official ISO for installation instead of custom images. The script can automatically retrieves the ISO link and installs common drivers like `Virtio`. - Supports installation in any direction, i.e., `Linux to Linux`, `Linux to Windows`, `Windows to Windows`, `Windows to Linux` - No need to input IP parameters; automatically recognizes dynamic and static IPs, supports `/32`, `/128`, `gateway outside subnet`, `IPv6 only`, `dual NIC` - Specially optimized for low-spec servers, requires less memory than the official netboot @@ -211,7 +211,7 @@ bash reinstall.sh ubuntu --installer bash reinstall.sh dd --img "https://example.com/xxx.xz" ``` -#### Optional parameters +#### Optional Parameters - `--allow-ping` Configure Windows Firewall to Allow Ping Responses (DD Windows only) - `--rdp-port PORT` Change RDP port (DD Windows only) @@ -234,7 +234,7 @@ bash reinstall.sh dd --img "https://example.com/xxx.xz" bash reinstall.sh alpine --hold=1 ``` -#### Optional parameters +#### Optional Parameters - `--password PASSWORD` Set password - `--ssh-port PORT` Change SSH port @@ -278,10 +278,7 @@ bash reinstall.sh netboot.xyz - Hyper-V Server \* - Azure Stack HCI \* -#### ~~Method 1: Let the Script Automatically Search for ISO~~ - -> [!CAUTION] -> The ISO repository currently prohibits direct link downloads, so this method is no longer effective. +#### Method 1: Let the Script Automatically Search for ISO - The script will search for ISOs from , a site that collects official ISOs. - Systems marked with \* do not support automatic ISO searching. @@ -384,7 +381,7 @@ bash reinstall.sh windows \ -#### Optional parameters +#### Optional Parameters - `--password PASSWORD` Set Password - `--allow-ping` Configure Windows Firewall to Allow Ping Responses diff --git a/README.md b/README.md index af7c6c5..d326d5a 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ ## 亮点 - 一键安装 Linux,支持 19 种常见发行版 -- 一键安装 Windows,使用官方 ISO 安装而非自制镜像,~~脚本会自动获取 ISO 链接~~、自动安装 Virtio 等常见驱动 +- 一键安装 Windows,使用官方 ISO 安装而非自制镜像,脚本会自动获取 ISO 链接、自动安装 Virtio 等常见驱动 - 支持任意方向重装,即 `Linux to Linux`、`Linux to Windows`、`Windows to Windows`、`Windows to Linux` - 无需填写 IP 参数,自动识别动静态,支持 `/32`、`/128`、`网关不在子网范围内`、`纯 IPv6`、`双网卡` - 专门适配低配小鸡,比官方 netboot 需要更少的内存 @@ -278,10 +278,7 @@ bash reinstall.sh netboot.xyz - Hyper-V Server \* - Azure Stack HCI \* -#### ~~方法 1: 让脚本自动查找 ISO~~ - -> [!CAUTION] -> 目前该 ISO 仓库禁止了直链下载,因此该方法已失效 +#### 方法 1: 让脚本自动查找 ISO - 脚本会从 查找 ISO,该网站专门提供官方 ISO 下载 - 上面带 \* 的系统不支持自动查找 ISO diff --git a/reinstall.sh b/reinstall.sh index 6aa122f..b6ee519 100644 --- a/reinstall.sh +++ b/reinstall.sh @@ -93,14 +93,20 @@ info() { shift msg=$* else - msg=$(to_upper <<<"$@") + msg="***** $(to_upper <<<"$*") *****" fi - - echo_color_text '\e[32m' "***** $msg *****" >&2 + echo_color_text '\e[32m' "$msg" >&2 } warn() { - echo_color_text '\e[33m' "Warning: $*" >&2 + local msg + if [ "$1" = false ]; then + shift + msg=$* + else + msg="Warning: $*" + fi + echo_color_text '\e[33m' "$msg" >&2 } error() { @@ -1423,25 +1429,26 @@ Continue? if [[ "$iso" = magnet:* ]]; then : # 不测试磁力链接 else - iso_tested=false + # 需要用户输入 massgrave.dev 直链 + if grep -Eiq '\.massgrave\.dev/.*\.(iso|img)$' <<<"$iso"; then + info "Set Direct link" + # MobaXterm 不支持 + # printf '\e]8;;http://example.com\e\\This is a link\e]8;;\e\\\n' - # 获取 massgrave.dev 直链 - if grep -Eiq '\.massgrave\.dev/.*\.(iso|img)' <<<"$iso"; then - # 如果已经是 iso 直链则跳过下面的 iso 测试 - if test_url_grace "$iso" iso; then - iso_tested=true - else - msg="Could not find direct link for $iso" - if ! iso=$(grep -oE 'https?.*\.iso[^"]*' $tmp/img-test | sed 's/&/\&/g' | grep .); then - error_and_exit "$msg" - fi + # MobaXterm 不显示为超链接 + # info false "请在浏览器中打开 $iso 获取直链并粘贴到这里。" + # info false "Please open $iso in browser to get the direct link and paste it here." + + echo "请在浏览器中打开 $iso 获取直链并粘贴到这里。" + echo "Please open $iso in browser to get the direct link and paste it here." + IFS= read -r -p "Direct Link: " iso + if [ -z "$iso" ]; then + error_and_exit "ISO Link is empty." fi fi # 测试是否是 iso - if ! $iso_tested; then - test_url "$iso" iso - fi + test_url "$iso" iso # 判断 iso 架构是否兼容 # https://gitlab.com/libosinfo/osinfo-db/-/tree/main/data/os/microsoft.com?ref_type=heads