windows: 提示用户输入 iso 直链

This commit is contained in:
bin456789 2025-05-16 19:06:07 +08:00
parent 2b9c82e97d
commit 19198a6146
No known key found for this signature in database
GPG Key ID: EE301B386DE6C11B
3 changed files with 32 additions and 31 deletions

View File

@ -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 <https://massgrave.dev/genuine-installation-media>, a site that collects official ISOs.
- Systems marked with \* do not support automatic ISO searching.
@ -384,7 +381,7 @@ bash reinstall.sh windows \
</details>
#### Optional parameters
#### Optional Parameters
- `--password PASSWORD` Set Password
- `--allow-ping` Configure Windows Firewall to Allow Ping Responses

View File

@ -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
- 脚本会从 <https://massgrave.dev/genuine-installation-media> 查找 ISO该网站专门提供官方 ISO 下载
- 上面带 \* 的系统不支持自动查找 ISO

View File

@ -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/&amp;/\&/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
# 判断 iso 架构是否兼容
# https://gitlab.com/libosinfo/osinfo-db/-/tree/main/data/os/microsoft.com?ref_type=heads