mirror of
https://github.com/bin456789/reinstall.git
synced 2025-06-29 15:49:51 +00:00
core: 不使用 ipcalc
This commit is contained in:
parent
9732c8557d
commit
90ebc1b123
@ -16,7 +16,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 automatically retrieves the ISO link and installs `Virtio` and other drivers.
|
||||
- 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` and other special network configurations
|
||||
- Specially optimized for low-spec servers, requires less memory than the official netboot
|
||||
|
@ -16,7 +16,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 需要更少的内存
|
||||
|
@ -6,8 +6,8 @@ set confhome=https://raw.githubusercontent.com/bin456789/reinstall/main
|
||||
set confhome_cn=https://gitlab.com/bin456789/reinstall/-/raw/main
|
||||
rem set confhome_cn=https://www.ghproxy.cc/https://raw.githubusercontent.com/bin456789/reinstall/main
|
||||
|
||||
set pkgs=curl,cpio,p7zip,ipcalc,dos2unix,jq,xz,gzip,zstd,openssl,bind-utils,libiconv,binutils
|
||||
set cmds=curl,cpio,p7zip,ipcalc,dos2unix,jq,xz,gzip,zstd,openssl,nslookup,iconv,ar
|
||||
set pkgs=curl,cpio,p7zip,dos2unix,jq,xz,gzip,zstd,openssl,bind-utils,libiconv,binutils
|
||||
set cmds=curl,cpio,p7zip,dos2unix,jq,xz,gzip,zstd,openssl,nslookup,iconv,ar
|
||||
|
||||
rem 65001 代码页会乱码
|
||||
|
||||
@ -202,7 +202,6 @@ exit /b 1
|
||||
set "cmds_space=%cmds:,= %"
|
||||
for %%c in (%cmds_space%) do (
|
||||
if not exist "%SystemDrive%\cygwin\bin\%%c" if not exist "%SystemDrive%\cygwin\bin\%%c.exe" (
|
||||
echo %%c not found.
|
||||
exit /b 1
|
||||
)
|
||||
)
|
||||
|
19
reinstall.sh
19
reinstall.sh
@ -126,11 +126,24 @@ curl() {
|
||||
done
|
||||
}
|
||||
|
||||
mask2cidr() {
|
||||
local x=${1##*255.}
|
||||
set -- 0^^^128^192^224^240^248^252^254^ $(((${#1} - ${#x}) * 2)) ${x%%.*}
|
||||
x=${1%%"$3"*}
|
||||
echo $(($2 + (${#x} / 4)))
|
||||
}
|
||||
|
||||
is_in_china() {
|
||||
[ "$force_cn" = 1 ] && return 0
|
||||
|
||||
if [ -z "$_loc" ]; then
|
||||
# www.cloudflare.com/dash.cloudflare.com 国内访问的是美国服务器,而且部分地区被墙
|
||||
# 备用 www.bose.cn
|
||||
# 备用 www.qualcomm.cn
|
||||
# 备用 www.prologis.cn
|
||||
# 备用 www.garmin.com.cn
|
||||
# 备用 www.autodesk.com.cn
|
||||
# 备用 www.keysight.com.cn
|
||||
_loc=$(curl -L http://www.visa.cn/cdn-cgi/trace | grep '^loc=' | cut -d= -f2)
|
||||
if [ -z "$_loc" ]; then
|
||||
error_and_exit "Can not get location."
|
||||
@ -1475,7 +1488,7 @@ Continue with DD?
|
||||
fi
|
||||
done
|
||||
|
||||
iso=$(curl -L https://fnnas.com | grep -o 'https://[^"]*\.iso' | head -1)
|
||||
iso=$(curl -L https://fnnas.com/ | grep -o 'https://[^"]*\.iso' | head -1)
|
||||
test_url "$iso" 'iso'
|
||||
eval "${step}_iso='$iso'"
|
||||
}
|
||||
@ -2380,7 +2393,9 @@ collect_netconf() {
|
||||
ip=${ips[i]}
|
||||
subnet=${subnets[i]}
|
||||
if [[ "$ip" = *.* ]]; then
|
||||
cidr=$(ipcalc -b "$ip/$subnet" | grep Netmask: | awk '{print $NF}')
|
||||
# ipcalc 依赖 perl,会使 cygwin 增加 ~50M
|
||||
# cidr=$(ipcalc -b "$ip/$subnet" | grep Netmask: | awk '{print $NF}')
|
||||
cidr=$(mask2cidr "$subnet")
|
||||
ipv4_addr="$ip/$cidr"
|
||||
ipv4_gateway="$gateway"
|
||||
ipv4_mac="$mac_addr"
|
||||
|
Loading…
x
Reference in New Issue
Block a user