From ffa7b63d93e7449a6402bb67e4446e3484f77a5c Mon Sep 17 00:00:00 2001 From: bin456789 Date: Sun, 31 Mar 2024 00:47:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.en.md | 3 --- README.md | 2 -- cloud-init-fix-onlink.sh | 4 ++-- reinstall.sh | 35 ++++++++++++++++++++--------------- trans.sh | 4 +++- ttys.sh | 11 +++++------ windows-setup.bat | 18 ++++++++++++------ 7 files changed, 42 insertions(+), 35 deletions(-) diff --git a/README.en.md b/README.en.md index 3357c62..537e18a 100644 --- a/README.en.md +++ b/README.en.md @@ -11,7 +11,6 @@ One-click reinstallation script ## Highlights - Installing using official cloud images (Cloud Image) allows bypassing the [memory requirements](https://access.redhat.com/articles/rhel-limits#minimum-required-memory-3) of traditional network installations, resulting in faster installation speed. -- Using official cloud images for installation ensures fast installation speed and can also avoid issues with netboot installation on machines with limited memory. - Compatible with 512M + 5G small servers and supports installing Alpine on 256M small servers. - Compatible with all network conditions, including dynamic/static IPv4/IPv6 and pure IPv4/IPv6. - Supports installing Windows using the official ISO. @@ -92,7 +91,6 @@ Parameters: ### Feature 2: DD - Supports gzip, xz formats. - - For machines with static IP, DD Windows, and the script will automatically configure the IP. ```bash @@ -102,7 +100,6 @@ bash reinstall.sh dd --img https://example.com/xxx.xz ### Feature 3: Reboot to Alpine Rescue System (Live OS) - Can be connected via SSH to perform manual DD, modify partitions, manually install Arch / Gentoo, etc. - - If the disk content is not modified, rebooting again will return to the original system. ```bash diff --git a/README.md b/README.md index dd06444..6c38a14 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,6 @@ bash reinstall.sh centos 7|8|9 (8|9 为 stream 版本) ### 功能 2: DD - 支持 gzip、xz 格式 - - 静态 IP 的机器 DD Windows,会自动配置好 IP ```bash @@ -101,7 +100,6 @@ bash reinstall.sh dd --img https://example.com/xxx.xz ### 功能 3: 重启到 Alpine 救援系统 (Live OS) - 可用 ssh 连接,进行手动 DD、修改分区、手动安装 Arch / Gentoo 等操作 - - 如果没有修改硬盘内容,再次重启将回到原系统 ```bash diff --git a/cloud-init-fix-onlink.sh b/cloud-init-fix-onlink.sh index e9c474f..6621c43 100644 --- a/cloud-init-fix-onlink.sh +++ b/cloud-init-fix-onlink.sh @@ -116,7 +116,7 @@ fix_networkd_conf() { # Gateway=2602::1 # GatewayOnLink=yes - if ! confs=$(ls /etc/systemd/network/10-cloud-init-*.network); then + if ! confs=$(ls /etc/systemd/network/10-cloud-init-*.network 2>/dev/null); then return fi @@ -163,7 +163,7 @@ fix_wicked_conf() { # default 1.1.1.1 - - # default 2602::1 - - - if ! confs=$(ls /etc/sysconfig/network/ifroute-*); then + if ! confs=$(ls /etc/sysconfig/network/ifroute-* 2>/dev/null); then return fi diff --git a/reinstall.sh b/reinstall.sh index fde6b83..6d466c8 100644 --- a/reinstall.sh +++ b/reinstall.sh @@ -1528,25 +1528,25 @@ EOF } mod_initrd_alpine() { - # virt 内核添加 ipv6 模块 + # hack 1 virt 内核添加 ipv6 模块 if virt_dir=$(ls -d $tmp_dir/lib/modules/*-virt 2>/dev/null); then ipv6_dir=$virt_dir/kernel/net/ipv6 - mkdir -p $ipv6_dir - modloop_file=/tmp/modloop_file - modloop_dir=/tmp/modloop_dir - curl -Lo $modloop_file $nextos_modloop - if is_in_windows; then - # cygwin 没有 unsquashfs - 7z e $modloop_file ipv6.ko -r -y -o$ipv6_dir - else - install_pkg unsquashfs - mkdir_clear $modloop_dir - unsquashfs -f -d $modloop_dir $modloop_file 'modules/*/kernel/net/ipv6/ipv6.ko' - find $modloop_dir -name ipv6.ko -exec cp {} $ipv6_dir/ \; + if ! [ -f $ipv6_dir/ipv6.ko ]; then + mkdir -p $ipv6_dir + modloop_file=/tmp/modloop_file + modloop_dir=/tmp/modloop_dir + curl -Lo $modloop_file $nextos_modloop + if is_in_windows; then + # cygwin 没有 unsquashfs + 7z e $modloop_file ipv6.ko -r -y -o$ipv6_dir + else + install_pkg unsquashfs + mkdir_clear $modloop_dir + unsquashfs -f -d $modloop_dir $modloop_file 'modules/*/kernel/net/ipv6/ipv6.ko' + find $modloop_dir -name ipv6.ko -exec cp {} $ipv6_dir/ \; + fi fi fi - - # hack 1 添加 ipv6 模块 insert_into_file init after 'configure_ip\(\)' </dev/null 2>&1; then + if stty -g -F "/dev/$tty" >/dev/null 2>&1; then if $is_first; then is_first=false else @@ -19,7 +17,8 @@ for tty in ttyS0 ttyAMA0 tty0; do printf "%s" "$prefix$tty" - if [ "$prefix" = "console=" ] && [ "$tty" = ttyS0 ]; then + if [ "$prefix" = "console=" ] && + { [ "$tty" = ttyS0 ] || [ "$tty" = ttyAMA0 ]; }; then printf ",115200n8" fi fi diff --git a/windows-setup.bat b/windows-setup.bat index 175b34e..02c8ebc 100644 --- a/windows-setup.bat +++ b/windows-setup.bat @@ -20,11 +20,7 @@ for %%F in ("X:\drivers\*.inf") do ( ) rem 等待加载分区 -rem 没有 timeout 命令 -rem 没有加载网卡驱动,无法用 ping 来等待 -echo wscript.sleep(5000) > X:\sleep.vbs -cscript //nologo X:\sleep.vbs -del X:\sleep.vbs +call :sleep 5000 echo rescan | diskpart rem 判断 efi 还是 bios @@ -110,4 +106,14 @@ rename X:\setup.exe.disabled setup.exe rem 运行 X:\setup.exe 的话 rem vista 会找不到安装源 rem server 23h2 会无法运行 -Y:\setup.exe /emsport:COM1 /emsbaudrate:115200 +rem Y:\setup.exe /emsport:COM1 /emsbaudrate:115200 +Y:\setup.exe +exit /b + +:sleep +rem 没有 timeout 命令 +rem 没有加载网卡驱动,无法用 ping 来等待 +echo wscript.sleep(%~1) > X:\sleep.vbs +cscript //nologo X:\sleep.vbs +del X:\sleep.vbs +exit /b