core: 不重要的优化

This commit is contained in:
bin456789 2024-08-07 21:46:45 +08:00
parent 048ee61ecc
commit 78d2454327
No known key found for this signature in database
GPG Key ID: EE301B386DE6C11B
4 changed files with 21 additions and 27 deletions

View File

@ -17,7 +17,7 @@ Reinstall server with one-click [中文](README.md)
- Specifically tailored for low-spec machines, addressing insufficient memory that prevents network installation. - Specifically tailored for low-spec machines, addressing insufficient memory that prevents network installation.
- Automatically detect dynamic and static IPv4 / IPv6, eliminating the need to fill in IP / subnet mask / gateway. - Automatically detect dynamic and static IPv4 / IPv6, eliminating the need to fill in IP / subnet mask / gateway.
- Support ARM, BIOS, EFI boot, with original system supporting LVM, BTRFS. - Support ARM, BIOS, EFI boot, with original system supporting LVM, BTRFS.
- No third-party custom packages included, all resources obtained in real-time from source sites. - No homemade packages included, all resources obtained in real-time from source sites.
- Includes many comments. - Includes many comments.
## System Requirements ## System Requirements

View File

@ -17,7 +17,7 @@
- 专门适配低配小鸡,解决内存过少导致无法进行网络安装 - 专门适配低配小鸡,解决内存过少导致无法进行网络安装
- 自动判断动静态 IPv4 / IPv6无需填写 IP / 掩码 / 网关 - 自动判断动静态 IPv4 / IPv6无需填写 IP / 掩码 / 网关
- 支持 ARM支持 BIOS、EFI 引导,原系统支持 LVM、BTRFS - 支持 ARM支持 BIOS、EFI 引导,原系统支持 LVM、BTRFS
- 不含第三方自制包,所有资源均实时从源站点获得 - 不含自制包,所有资源均实时从源站点获得
- 有很多注释 - 有很多注释
## 配置要求 ## 配置要求

View File

@ -104,13 +104,14 @@ curl() {
} }
is_in_china() { is_in_china() {
if [ -z $_is_in_china ]; then if [ -z "$_loc" ]; then
# 部分地区 www.cloudflare.com 被墙 # 部分地区 www.cloudflare.com 被墙
curl -L http://dash.cloudflare.com/cdn-cgi/trace | _loc=$(curl -L http://dash.cloudflare.com/cdn-cgi/trace | grep '^loc=' | cut -d= -f2)
grep -qx 'loc=CN' && _is_in_china=true || if [ -z "$_loc" ]; then
_is_in_china=false error_and_exit "Can not get location."
fi fi
$_is_in_china fi
[ "$_loc" = CN ]
} }
is_in_windows() { is_in_windows() {
@ -1893,6 +1894,8 @@ add_efi_entry_in_windows() {
get_maybe_efi_dirs_in_linux() { get_maybe_efi_dirs_in_linux() {
# arch云镜像efi分区挂载在/efi且使用 autofs挂载后会有两个 /efi 条目 # arch云镜像efi分区挂载在/efi且使用 autofs挂载后会有两个 /efi 条目
# openEuler 云镜像 boot 分区是 vfat 格式,但 vfat 可以当 efi 分区用
# TODO: 最好通过 lsblk/blkid 检查是否为 efi 分区类型
mount | awk '$5=="vfat" || $5=="autofs" {print $3}' | grep -E '/boot|/efi' | sort -u mount | awk '$5=="vfat" || $5=="autofs" {print $3}' | grep -E '/boot|/efi' | sort -u
} }

View File

@ -757,7 +757,7 @@ EOF
{ {
echo echo
if [ -n "$enpx" ] && [ "$enpx" != "$ethx" ]; then if [ -n "$enpx" ] && [ "$enpx" != "$ethx" ]; then
echo rename $enpx=$ethx >>$conf_file echo rename $enpx=$ethx
fi fi
echo $mode $ethx echo $mode $ethx
} >>$conf_file } >>$conf_file
@ -2234,15 +2234,15 @@ get_ci_installer_part_size() {
# https://cloud-images.ubuntu.com/releases/24.04/release/ubuntu-24.04-server-cloudimg-amd64.img 500m # https://cloud-images.ubuntu.com/releases/24.04/release/ubuntu-24.04-server-cloudimg-amd64.img 500m
# https://gentoo.osuosl.org/experimental/amd64/openstack/gentoo-openstack-amd64-systemd-latest.qcow2 800m # https://gentoo.osuosl.org/experimental/amd64/openstack/gentoo-openstack-amd64-systemd-latest.qcow2 800m
# openeuler 20.03 3g
if [ "$distro" = openeuler ]; then
echo 3GiB
else
if get_http_file_size_to size_bytes $img >&2 && [ -n "$size_bytes" ]; then if get_http_file_size_to size_bytes $img >&2 && [ -n "$size_bytes" ]; then
# 额外 +100M 文件系统保留大小 和 qcow2 写入空间 # 额外 +100M 文件系统保留大小 和 qcow2 写入空间
size_bytes_mb=$((size_bytes / 1024 / 1024 + 100)) size_bytes_mb=$((size_bytes / 1024 / 1024 + 100))
# 最少 1g ,因为可能要用作临时 swap # 最少 1g ,因为可能要用作临时 swap
echo "$((size_bytes_mb / 1024 + 1))GiB" echo "$((size_bytes_mb / 1024 + 1))GiB"
else
# openeuler 20.03 3g
if [ "$distro" = openeuler ] && [ "$releasever" = 20.03 ]; then
echo 3GiB
else else
# 如果没获取到文件大小 # 如果没获取到文件大小
echo 2GiB echo 2GiB
@ -2338,13 +2338,7 @@ install_qcow_by_copy() {
# alma 9 boot 分区的类型不是规定的 uuid # alma 9 boot 分区的类型不是规定的 uuid
# openeuler boot 分区是 fat 格式 # openeuler boot 分区是 fat 格式
boot_part=$(lsblk /dev/nbd0p* --sort SIZE -no NAME,FSTYPE | grep -E 'ext4|xfs|fat' | awk '{print $1}' | boot_part=$(lsblk /dev/nbd0p* --sort SIZE -no NAME,FSTYPE | grep -E 'ext4|xfs|fat' | awk '{print $1}' |
grep -vx "$os_part" | { grep -vx "$os_part" | grep -vx "$efi_part" | tail -1 | awk '{print $1}')
if [ -n "$efi_part" ]; then
grep -vx "$efi_part"
else
cat
fi
} | tail -1 | awk '{print $1}')
if $is_lvm_image; then if $is_lvm_image; then
os_part="mapper/$os_part" os_part="mapper/$os_part"
@ -3240,9 +3234,7 @@ install_windows() {
if is_virt_contains kvm && if is_virt_contains kvm &&
! is_virt_contains aws; then ! is_virt_contains aws; then
# 要区分 win10 / win11 驱动,虽然他们的 NT 版本号都是 10.0 # 要区分 win10 / win11 驱动,虽然他们的 NT 版本号都是 10.0,但驱动文件有区别
# 但他们可能用不同的编译器编译
# 未来 inf 也有可能不同
# https://github.com/virtio-win/kvm-guest-drivers-windows/commit/9af43da9e16e2d4bf4ea4663cdc4f29275fff48f # https://github.com/virtio-win/kvm-guest-drivers-windows/commit/9af43da9e16e2d4bf4ea4663cdc4f29275fff48f
# vista >>> 2k8 # vista >>> 2k8
# 10 >>> w10 # 10 >>> w10
@ -3250,7 +3242,6 @@ install_windows() {
virtio_sys=$( virtio_sys=$(
case "$(echo "$product_ver" | to_lower)" in case "$(echo "$product_ver" | to_lower)" in
'vista') echo 2k8 ;; # 没有 vista 文件夹 'vista') echo 2k8 ;; # 没有 vista 文件夹
'2025') echo 2k22 ;; # 暂时没有
*) *)
case "$product_type" in case "$product_type" in
WinNT) echo "w$product_ver" ;; WinNT) echo "w$product_ver" ;;