From efb1614b6bda8e448a049d6654c329bc961fa505 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Wed, 5 Mar 2025 22:34:59 +0800 Subject: [PATCH 001/127] =?UTF-8?q?core:=20=E4=BF=AE=E5=A4=8D=E6=96=B0?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E6=B2=A1=E6=9C=89=20/usr/lib/systemd/system-?= =?UTF-8?q?preset=20=E6=96=87=E4=BB=B6=E5=A4=B9=E6=97=B6=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fix-eth-name.service | 1 + trans.sh | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/fix-eth-name.service b/fix-eth-name.service index 1380c73..39a4cbd 100644 --- a/fix-eth-name.service +++ b/fix-eth-name.service @@ -22,6 +22,7 @@ ExecStart=/usr/bin/env bash /fix-eth-name.sh ExecStart=/usr/bin/env rm -f /fix-eth-name.sh ExecStart=/usr/bin/env rm -f /etc/systemd/system/fix-eth-name.service ExecStart=/usr/bin/env rm -f /etc/systemd/system/multi-user.target.wants/fix-eth-name.service +ExecStart=/usr/bin/env rm -f /lib/systemd/system-preset/01-fix-eth-name.preset ExecStart=/usr/bin/env rm -f /usr/lib/systemd/system-preset/01-fix-eth-name.preset [Install] diff --git a/trans.sh b/trans.sh index 293f20b..d587d12 100644 --- a/trans.sh +++ b/trans.sh @@ -1681,7 +1681,13 @@ add_fix_eth_name_systemd_service() { # 因此需要设置 fix-eth-name 的 preset 状态 # 不然首次开机 /etc/systemd/system/multi-user.target.wants/fix-eth-name.service 会被删除 # 通常 /etc/systemd/system-preset/ 文件夹要新建,因此不放在这里 - echo 'enable fix-eth-name.service' >"$os_dir/usr/lib/systemd/system-preset/01-fix-eth-name.preset" + + # 可能是 /usr/lib/systemd/system-preset/ 或者 /lib/systemd/system-preset/ + if [ -d "$os_dir/usr/lib/systemd/system-preset" ]; then + echo 'enable fix-eth-name.service' >"$os_dir/usr/lib/systemd/system-preset/01-fix-eth-name.preset" + else + echo 'enable fix-eth-name.service' >"$os_dir/lib/systemd/system-preset/01-fix-eth-name.preset" + fi } basic_init() { From 61b3e4e7d2ed489b821b64d292d144784d81e466 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Thu, 6 Mar 2025 20:45:29 +0800 Subject: [PATCH 002/127] =?UTF-8?q?core:=20=E6=94=AF=E6=8C=81=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E9=87=8D=E5=91=BD=E5=90=8D=E4=BD=BF=E7=94=A8=20metali?= =?UTF-8?q?nk=20=E4=B8=8B=E8=BD=BD=E7=9A=84=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- trans.sh | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/trans.sh b/trans.sh index d587d12..c742bb1 100644 --- a/trans.sh +++ b/trans.sh @@ -161,24 +161,9 @@ download() { # 有ipv4地址无ipv4网关的情况下,aria2可能会用ipv4下载,而不是ipv6 # axel 在 lightsail 上会占用大量cpu - # aria2 下载 fedora 官方镜像链接会将meta4文件下载下来,而且占用了指定文件名,造成重命名失效。而且无法指定目录 # https://download.opensuse.org/distribution/leap/15.5/appliances/openSUSE-Leap-15.5-Minimal-VM.x86_64-kvm-and-xen.qcow2 # https://aria2.github.io/manual/en/html/aria2c.html#cmdoption-o - # 构造 aria2 参数 - save= - # 文件夹 - if [[ "$path" = '/*' ]]; then - save="$save -d /" - fi - # 文件名 - if [ -n "$path" ]; then - case "$(get_url_type "$url")" in - http) save="$save -o $path" ;; - bt) save="$save -O 1=$path" ;; - esac - fi - # 阿里云源限速,而且检测 user-agent 禁止 axel/aria2 下载 # aria2 默认 --max-tries 5 @@ -205,7 +190,20 @@ download() { url=$torrent fi - aria2c $save "$url" + # -o 设置 http 下载文件名 + # -O 设置 bt 首个文件的文件名 + aria2c "$url" \ + -d "$(dirname "$path")" \ + -o "$(basename "$path")" \ + -O "1=$(basename "$path")" + + # opensuse 官方镜像支持 metalink + # aira2 无法重命名用 metalink 下载的文件 + # 需用以下方法重命名 + if head -c 1024 "$path" | grep -Fq 'urn:ietf:params:xml:ns:metalink'; then + real_file=$(tr -d '\n' <"$path" | sed -E 's|.* Date: Thu, 6 Mar 2025 20:45:29 +0800 Subject: [PATCH 003/127] =?UTF-8?q?arch/gentoo:=20=E4=BD=BF=E7=94=A8=20bas?= =?UTF-8?q?ic=5Finit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- trans.sh | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/trans.sh b/trans.sh index c742bb1..b5c3556 100644 --- a/trans.sh +++ b/trans.sh @@ -1980,11 +1980,6 @@ EOF # preset-all 后多了很多服务,内存占用多了几十M chroot $os_dir systemctl preset-all fi - # 此时不能用 - # chroot $os_dir timedatectl set-timezone Asia/Shanghai - chroot $os_dir systemd-firstboot --force --timezone=Asia/Shanghai - # gentoo 不会自动创建 machine-id - clear_machine_id $os_dir # 网络配置 case "$network_app" in @@ -2026,21 +2021,10 @@ EOF ;; esac - # 修正网卡名 - add_fix_eth_name_systemd_service $os_dir - # arch gentoo 网络配置是用 alpine cloud-init 生成的 # cloud-init 版本够新,因此无需修复 onlink 网关 - # ssh - chroot $os_dir systemctl enable sshd - allow_root_password_login $os_dir - if is_need_change_ssh_port; then - change_ssh_port $os_dir $ssh_port - fi - - # 修改密码 - change_root_password $os_dir + basic_init $os_dir # ntp 用 systemd 自带的 # TODO: vm agent + 随机数生成器 From f8ca315d71d77befc573c181c861b6e5e6bf61b7 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Thu, 6 Mar 2025 20:45:30 +0800 Subject: [PATCH 004/127] =?UTF-8?q?core:=20=E5=88=A0=E9=99=A4=20cloud-init?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- trans.sh | 77 +++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 59 insertions(+), 18 deletions(-) diff --git a/trans.sh b/trans.sh index b5c3556..86f59a0 100644 --- a/trans.sh +++ b/trans.sh @@ -2978,22 +2978,44 @@ chroot_systemctl_disable() { done } -disable_cloud_init() { +remove_cloud_init() { os_dir=$1 - info "Disable Cloud-Init" - # 两种方法都可以 - - if [ -d $os_dir/etc/cloud ]; then - touch $os_dir/etc/cloud/cloud-init.disabled + if ! is_have_cmd_on_disk $os_dir cloud-init; then + return fi + info "Remove Cloud-Init" + + # 两种方法都可以 + if false && [ -d $os_dir/etc/cloud ]; then + touch $os_dir/etc/cloud/cloud-init.disabled + fi for name in cloud-init-local cloud-init cloud-config cloud-final; do for type in service socket; do # 服务不存在时会报错 chroot $os_dir systemctl disable "$name.$type" 2>/dev/null || true done done + + for pkg_mgr in dnf yum zypper apt-get; do + if is_have_cmd_on_disk $os_dir $pkg_mgr; then + case $pkg_mgr in + dnf | yum) + chroot $os_dir $pkg_mgr remove -y cloud-init + ;; + zypper) + # 加上 -u 才会删除依赖 + chroot $os_dir zypper remove -y -u cloud-init + ;; + apt-get) + chroot_apt_remove $os_dir cloud-init + chroot_apt_autoremove $os_dir + ;; + esac + break + fi + done } disable_jeos_firstboot() { @@ -3080,18 +3102,21 @@ EOF # 1. 禁用 selinux kdump # 2. 添加微码+固件 if [ -f $os_dir/etc/redhat-release ]; then + # 防止删除 cloud-init / 安装 firmware 时不够内存 + create_swap_if_ram_less_than 2048 $os_dir/swapfile + find_and_mount /boot find_and_mount /boot/efi mount_pseudo_fs $os_dir cp_resolv_conf $os_dir - disable_cloud_init $os_dir - # 可以直接用 alpine 的 cloud-init 生成 Network Manager 配置 create_cloud_init_network_config /net.cfg create_network_manager_config /net.cfg "$os_dir" rm /net.cfg + remove_cloud_init $os_dir + disable_selinux_kdump $os_dir if fw_pkgs=$(get_ucode_firmware_pkgs) && [ -n "$fw_pkgs" ]; then @@ -3116,7 +3141,7 @@ EOF find_and_mount /boot find_and_mount /boot/efi - disable_cloud_init $os_dir + remove_cloud_init $os_dir # 获取当前开启的 Components, 后面要用 if [ -f $os_dir/etc/apt/sources.list.d/debian.sources ]; then @@ -3282,7 +3307,6 @@ EOF find_and_mount /boot find_and_mount /boot/efi - disable_cloud_init $os_dir disable_jeos_firstboot $os_dir # opensuse leap @@ -3340,7 +3364,7 @@ EOF fi # 不能同时装 kernel-default-base 和 kernel-default - chroot $os_dir zypper remove -y kernel-default-base + chroot $os_dir zypper remove -y -u kernel-default-base # 固件+微码 if fw_pkgs=$(get_ucode_firmware_pkgs) && [ -n "$fw_pkgs" ]; then @@ -3367,11 +3391,11 @@ EOF chroot $os_dir zypper install -y $kernel fi - restore_resolv_conf $os_dir + # 最后才删除 cloud-init + # 因为生成 sysconfig 网络配置要用目标系统的 cloud-init + remove_cloud_init $os_dir - # 删除 swap - swapoff -a - rm -f $os_dir/swapfile + restore_resolv_conf $os_dir fi # arch 云镜像 @@ -3439,6 +3463,10 @@ EOF if [ -f "$ci_file" ]; then cat -n "$ci_file" fi + + # 删除 swap + swapoff -a + rm -f $os_dir/swapfile } modify_os_on_disk() { @@ -3516,6 +3544,10 @@ create_swap() { swapfile=$2 if ! grep $swapfile /proc/swaps; then + # 用兼容 btrfs 的方式创建 swapfile + truncate -s 0 $swapfile + # 如果分区不支持 chattr +C 会显示错误但返回值是 0 + chattr +C $swapfile 2>/dev/null fallocate -l ${swapsize}M $swapfile chmod 0600 $swapfile mkswap $swapfile @@ -4211,13 +4243,13 @@ EOF # 清理 rm -rf $os_dir/net.cfg $os_dir/out + # 删除 # Created by cloud-init on instance boot automatically, do not edit. # 修正网络配置问题并显示文件 - sed -i '/^IPV[46]_FAILURE_FATAL=/d' $os_dir/etc/sysconfig/network-scripts/ifcfg-* + sed -i -e '/^IPV[46]_FAILURE_FATAL=/d' -e '/^#/d' $os_dir/etc/sysconfig/network-scripts/ifcfg-* for file in "$os_dir/etc/sysconfig/network-scripts/ifcfg-"*; do if grep -q '^DHCPV6C=yes' "$file"; then sed -i '/^IPV6_AUTOCONF=no/d' "$file" fi - cat -n "$file" done else @@ -4307,6 +4339,9 @@ EOF # 网络配置 # 18.04+ netplan if is_have_cmd_on_disk $os_dir netplan; then + # 避免删除 cloud-init 后,minimal 镜像的 netplan.io 被 autoremove + chroot $os_dir apt-mark manual netplan.io + # 生成 cloud-init 网络配置 create_cloud_init_network_config $os_dir/net.cfg @@ -4331,6 +4366,9 @@ EOF rm -rf $os_dir/net.cfg fi else + # 避免删除 cloud-init 后 ifupdown 被 autoremove + chroot $os_dir apt-mark manual ifupdown + # 16.04 镜像用 ifupdown/networking 管理网络 # 要安装 resolveconf,不然 /etc/resolv.conf 为空 chroot_apt_install $os_dir resolvconf @@ -4581,9 +4619,12 @@ EOF esac # 基本配置 - disable_cloud_init /os basic_init /os + # 最后才删除 cloud-init + # 因为生成 netplan/sysconfig 网络配置要用目标系统的 cloud-init + remove_cloud_init /os + # 删除 swapfile swapoff -a rm -f /os/swapfile From eb98bc34a2cf71ffe32b434916cc5bd39aa3490c Mon Sep 17 00:00:00 2001 From: bin456789 Date: Thu, 6 Mar 2025 20:45:30 +0800 Subject: [PATCH 005/127] =?UTF-8?q?core:=20=E6=94=AF=E6=8C=81=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=20ssh=20=E5=85=AC=E9=92=A5=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit close #134 --- README.en.md | 16 +++++++ README.md | 18 +++++++- debian.cfg | 10 ++++- reinstall.sh | 125 +++++++++++++++++++++++++++++++++++++++++++-------- trans.sh | 108 +++++++++++++++++++++++++++++++++----------- 5 files changed, 231 insertions(+), 46 deletions(-) diff --git a/README.en.md b/README.en.md index eb85fcc..ed4ee10 100644 --- a/README.en.md +++ b/README.en.md @@ -150,6 +150,14 @@ bash reinstall.sh anolis 7|8|23 #### Optional Parameters - `--password PASSWORD` Set the password +- `--ssh-key KEY` Set up SSH public key, supports these formats. When using public key, password is empty. + - `--ssh-key "ssh-rsa ..."` + - `--ssh-key "ssh-ed25519 ..."` + - `--ssh-key "ecdsa-sha2-nistp256/384/521 ..."` + - `--ssh-key http://url` + - `--ssh-key github:your_username` + - `--ssh-key gitlab:your_username` + - `--ssh-key /path/to/public_key` - `--ssh-port PORT` Change the SSH port (for log observation during installation and for the new system) - `--web-port PORT` Change the Web port (for log observation during installation) - `--hold 2` Prevent reboot after installation completes, allowing SSH login to modify system content; the system is mounted at `/os` (this feature is not supported on Debian/Kali). @@ -228,6 +236,14 @@ bash reinstall.sh alpine --hold=1 - `--password PASSWORD` Set password - `--ssh-port PORT` Change SSH port +- `--ssh-key KEY` Set up SSH public key, supports these formats. When using public key, password is empty. + - `--ssh-key ssh-rsa ...` + - `--ssh-key ssh-ed25519 ...` + - `--ssh-key ecdsa-sha2-nistp256/384/521 ...` + - `--ssh-key http://url` + - `--ssh-key github:your_username` + - `--ssh-key gitlab:your_username` + - `--ssh-key /path/to/public_key` ### Feature 4: Reboot to netboot.xyz diff --git a/README.md b/README.md index 89e83d1..5767306 100644 --- a/README.md +++ b/README.md @@ -150,7 +150,15 @@ bash reinstall.sh anolis 7|8|23 #### 可选参数 - `--password PASSWORD` 设置密码 -- `--ssh-port PORT` 修改 SSH 端口(安装期间观察日志用,也用于新系统) +- `--ssh-key KEY` 设置 SSH 公钥登录,支持以下格式。当使用公钥时,密码为空 + - `--ssh-key "ssh-rsa ..."` + - `--ssh-key "ssh-ed25519 ..."` + - `--ssh-key "ecdsa-sha2-nistp256/384/521 ..."` + - `--ssh-key http://url` + - `--ssh-key github:your_username` + - `--ssh-key gitlab:your_username` + - `--ssh-key /path/to/public_key` +- `--ssh-port PORT` 修改 SSH 端口(安装期间观察日志用,也作用于新系统) - `--web-port PORT` 修改 Web 端口(安装期间观察日志用) - `--hold 2` 安装结束后不重启,此时可以 SSH 登录修改系统内容,系统挂载在 `/os` (此功能不支持 Debian/Kali) @@ -228,6 +236,14 @@ bash reinstall.sh alpine --hold=1 - `--password PASSWORD` 设置密码 - `--ssh-port PORT` 修改 SSH 端口 +- `--ssh-key KEY` 设置 SSH 公钥登录,支持以下格式。当使用公钥时,密码为空 + - `--ssh-key ssh-rsa ...` + - `--ssh-key ssh-ed25519 ...` + - `--ssh-key ecdsa-sha2-nistp256/384/521 ...` + - `--ssh-key http://url` + - `--ssh-key github:your_username` + - `--ssh-key gitlab:your_username` + - `--ssh-key /path/to/public_key` ### 功能 4: 重启到 netboot.xyz diff --git a/debian.cfg b/debian.cfg index f61a330..e30e4d9 100644 --- a/debian.cfg +++ b/debian.cfg @@ -26,6 +26,7 @@ d-i mirror/country string manual # B.4.5. 帐号设置 d-i passwd/make-user boolean false # 单纯为了跳过设置,实际上是在 partman/early_command 里设置密码,preseed/early_command 无法设置密码 +# 注意如果用 ssh key 后面还要删除密码 d-i passwd/root-password password '' d-i passwd/root-password-again password '' # kali 需要下面这行,否则会提示输入用户名 @@ -172,8 +173,13 @@ d-i preseed/late_command string true; \ in-target systemctl enable ssh; \ - echo "PermitRootLogin yes" >/target/etc/ssh/sshd_config.d/01-permitrootlogin.conf || \ - echo "PermitRootLogin yes" >>/target/etc/ssh/sshd_config; \ + if [ -s /configs/ssh_keys ]; then \ + (umask 077; mkdir -p /target/root/.ssh; cat /configs/ssh_keys >/target/root/.ssh/authorized_keys); \ + in-target passwd -d root; \ + else \ + echo "PermitRootLogin yes" >/target/etc/ssh/sshd_config.d/01-permitrootlogin.conf || \ + echo "PermitRootLogin yes" >>/target/etc/ssh/sshd_config; \ + fi; \ if [ -n "$ssh_port" ] && ! [ "$ssh_port" = 22 ]; then \ echo "Port $ssh_port" >/target/etc/ssh/sshd_config.d/01-change-ssh-port.conf || \ diff --git a/reinstall.sh b/reinstall.sh index 0e8ac69..9bd09aa 100644 --- a/reinstall.sh +++ b/reinstall.sh @@ -69,7 +69,9 @@ Usage: $reinstall_____ anolis 7|8|23 windows --image-name="windows xxx yyy" --iso="http://xxx.com/xxx.iso" netboot.xyz - Options: [--ssh-port PORT] + Options: [--password PASSWORD] + [--ssh-key KEY] + [--ssh-port PORT] [--rdp-port PORT] [--web-port PORT] [--allow-ping] @@ -1790,6 +1792,10 @@ verify_os_args() { redhat) [ -n "$img" ] || error_and_exit "redhat need --img" ;; windows) [ -n "$image_name" ] || error_and_exit "Install Windows need --image-name." ;; esac + + case "$distro" in + netboot.xyz | windows) [ -z "$ssh_keys" ] || error_and_exit "not support ssh key for $distro" ;; + esac } get_cmd_path() { @@ -3471,7 +3477,11 @@ This script is outdated, please download reinstall.sh again. # 保存配置 mkdir -p $initrd_dir/configs - save_password $initrd_dir/configs + if [ -n "$ssh_keys" ]; then + cat <<<"$ssh_keys" >$initrd_dir/configs/ssh_keys + else + save_password $initrd_dir/configs + fi if is_distro_like_debian $nextos_distro; then mod_initrd_debian_kali @@ -3572,6 +3582,15 @@ remove_useless_initrd_files() { du -sh . } +get_unix_path() { + if is_in_windows; then + # 输入的路径是 / 开头也没问题 + cygpath -u "$1" + else + printf '%s' "$1" + fi +} + # 脚本入口 if mount | grep -q 'tmpfs on / type tmpfs'; then error_and_exit "Can't run this script in Live OS." @@ -3620,6 +3639,7 @@ for o in ci installer debug minimal allow-ping force-cn \ lang: \ passwd: password: \ ssh-port: \ + ssh-key: public-key: \ rdp-port: \ web-port: http-port: \ allow-ping: \ @@ -3687,6 +3707,73 @@ while true; do --passwd | --password) [ -n "$2" ] || error_and_exit "Need value for $1" password=$2 + shift 2 + ;; + --ssh-key | --public-key) + ssh_key_error_and_exit() { + error "$1" + cat <"/configs/$1" } +# ubuntu 安装版、el/ol 安装版不使用该密码 get_password_linux_sha512() { get_config password-linux-sha512 } @@ -544,7 +545,6 @@ get_password_windows_administrator_base64() { get_config password-windows-administrator-base64 } -# debian 安装版、ubuntu 安装版、el/ol 安装版不使用该密码 get_password_plaintext() { get_config password-plaintext } @@ -726,6 +726,10 @@ is_elts() { [ -n "$elts" ] && [ "$elts" = 1 ] } +is_need_set_ssh_keys() { + [ -s /configs/ssh_keys ] +} + is_need_change_ssh_port() { [ -n "$ssh_port" ] && ! [ "$ssh_port" = 22 ] } @@ -771,6 +775,10 @@ del_cr() { sed 's/\r//g' } +del_comment_lines() { + sed '/^[[:space:]]*#/d' +} + del_empty_lines() { sed '/^[[:space:]]*$/d' } @@ -1376,6 +1384,11 @@ install_alpine() { chroot /os setup-timezone -i Asia/Shanghai chroot /os setup-ntp chrony || true + # 设置公钥 + if is_need_set_ssh_keys; then + set_ssh_keys_and_del_password /os + fi + # 下载 fix-eth-name download "$confhome/fix-eth-name.sh" /os/fix-eth-name.sh download "$confhome/fix-eth-name.initd" /os/etc/init.d/fix-eth-name @@ -1571,6 +1584,17 @@ install_nixos() { if [ -e /os/swapfile ] && $keep_swap; then nix_swap="swapDevices = [{ device = \"/swapfile\"; size = $swap_size; }];" fi + + if is_need_set_ssh_keys; then + nix_ssh_keys_or_PermitRootLogin=" +users.users.root.openssh.authorizedKeys.keys = [ +$(del_comment_lines $os_dir/root/.ssh/authorized_keys + ) + + # 删除密码 + chroot $os_dir passwd -d root +} + # 除了 alpine 都会用到 change_ssh_conf() { os_dir=$1 @@ -3562,20 +3607,25 @@ change_ssh_conf() { value=$3 sub_conf=$4 - # arch 没有 /etc/ssh/sshd_config.d/ 文件夹 - # opensuse tumbleweed 没有 /etc/ssh/sshd_config - # 有 /etc/ssh/sshd_config.d/ 文件夹 - # 有 /usr/etc/ssh/sshd_config - if { grep -q 'Include.*/etc/ssh/sshd_config.d' $os_dir/etc/ssh/sshd_config || - grep -q '^Include.*/etc/ssh/sshd_config.d/' $os_dir/usr/etc/ssh/sshd_config; } 2>/dev/null; then + if line="^$key .*" && grep -Exq "$line" $os_dir/etc/ssh/sshd_config; then + # 如果 sshd_config 存在此 key(非注释状态),则替换 + sed -Ei "s/$line/$key $value/" $os_dir/etc/ssh/sshd_config + elif { + # arch 没有 /etc/ssh/sshd_config.d/ 文件夹 + # opensuse tumbleweed 没有 /etc/ssh/sshd_config + # 有 /etc/ssh/sshd_config.d/ 文件夹 + # 有 /usr/etc/ssh/sshd_config + grep -q 'Include.*/etc/ssh/sshd_config.d' $os_dir/etc/ssh/sshd_config || + grep -q '^Include.*/etc/ssh/sshd_config.d/' $os_dir/usr/etc/ssh/sshd_config + } 2>/dev/null; then mkdir -p $os_dir/etc/ssh/sshd_config.d/ echo "$key $value" >"$os_dir/etc/ssh/sshd_config.d/$sub_conf" else - # 如果 sshd_config 存在此 key,则替换 + # 如果 sshd_config 存在此 key (无论是否已注释),则替换,包括删除注释 # 否则追加 line="^#?$key .*" if grep -Exq "$line" $os_dir/etc/ssh/sshd_config; then - sed -Eiq "s/$line/$key $value/" $os_dir/etc/ssh/sshd_config + sed -Ei "s/$line/$key $value/" $os_dir/etc/ssh/sshd_config else echo "$key $value" >>$os_dir/etc/ssh/sshd_config fi @@ -3584,17 +3634,15 @@ change_ssh_conf() { allow_password_login() { os_dir=$1 - change_ssh_conf "$os_dir" PasswordAuthentication yes 02-PasswordAuthenticaton.conf + change_ssh_conf "$os_dir" PasswordAuthentication yes 01-PasswordAuthenticaton.conf } -# arch gentoo 常规安装用 allow_root_password_login() { os_dir=$1 change_ssh_conf "$os_dir" PermitRootLogin yes 01-permitrootlogin.conf } -# arch gentoo 常规安装用 change_ssh_port() { os_dir=$1 ssh_port=$2 @@ -3974,8 +4022,11 @@ install_fnos() { # chroot $os_dir update-initramfs -u # 更改密码 - # chroot $os_dir passwd -d root - echo "root:$(get_password_linux_sha512)" | chroot $os_dir chpasswd -e + if is_need_set_ssh_keys; then + set_ssh_keys_and_del_password $os_dir + else + change_root_password $os_dir + fi # ssh root 登录,测试用 if false; then @@ -6328,13 +6379,20 @@ mount / -o remount,size=100% # 4. 允许同步失败,因为不是关键步骤 sync_time || true -# 设置密码,安装并打开 ssh -echo "root:$(get_password_linux_sha512)" | chpasswd -e +# 安装 ssh 并更改端口 apk add openssh if is_need_change_ssh_port; then change_ssh_port / $ssh_port fi -printf '\nyes' | setup-sshd + +# 设置密码,添加开机启动 + 开启 ssh 服务 +if is_need_set_ssh_keys; then + set_ssh_keys_and_del_password / + printf '\n' | setup-sshd +else + change_root_password / + printf '\nyes' | setup-sshd +fi # shellcheck disable=SC2154 if [ "$hold" = 1 ]; then From 7e3f12690e1834d881f898becb75ea4785d36104 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Thu, 6 Mar 2025 20:45:31 +0800 Subject: [PATCH 006/127] =?UTF-8?q?core:=20=E4=B8=8D=E9=87=8D=E8=A6=81?= =?UTF-8?q?=E7=9A=84=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - ubuntu: 支持 24.10 minimal - core: 添加 -h --help 参数 --- README.en.md | 4 ++-- README.md | 4 ++-- reinstall.sh | 32 ++++++++++++++++---------------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/README.en.md b/README.en.md index ed4ee10..c8a7cfc 100644 --- a/README.en.md +++ b/README.en.md @@ -394,8 +394,8 @@ bash reinstall.sh windows \ #### The following drivers will automatic download and install as needed, without the need for manual addition -- Virtio ([Virtio](https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/), [Alibaba Cloud](https://www.alibabacloud.com/help/ecs/user-guide/update-red-hat-virtio-drivers-of-windows-instances)) -- XEN ([XEN](https://xenproject.org/resources/downloads/), [Citrix](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Upgrading_PV_drivers.html#win2008-citrix-upgrade), [AWS](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/xen-drivers-overview.html)) +- Virtio ([Virtio](https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/), [Alibaba Cloud](https://www.alibabacloud.com/help/ecs/user-guide/install-the-virtio-driver-1)) +- XEN ([~~XEN~~(unsigned)](https://xenproject.org/resources/downloads/), [Citrix](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Upgrading_PV_drivers.html#win2008-citrix-upgrade), [AWS](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/xen-drivers-overview.html)) - AWS ([ENA Network Adapter](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ena-driver-releases-windows.html), [NVMe Storage Controller](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/nvme-driver-version-history.html)) - GCP ([gVNIC Network Adapter](https://cloud.google.com/compute/docs/networking/using-gvnic), [GGA Display Adapter](https://cloud.google.com/compute/docs/instances/enable-instance-virtual-display)) - Azure ([MANA Network Adapter](https://learn.microsoft.com/azure/virtual-network/accelerated-networking-mana-windows)) diff --git a/README.md b/README.md index 5767306..c7d4e25 100644 --- a/README.md +++ b/README.md @@ -394,8 +394,8 @@ bash reinstall.sh windows \ #### 以下驱动会自动按需下载安装,无需手动添加 -- Virtio ([Virtio](https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/)、[阿里云](https://www.alibabacloud.com/help/ecs/user-guide/update-red-hat-virtio-drivers-of-windows-instances)) -- XEN ([XEN](https://xenproject.org/resources/downloads/)、[Citrix](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Upgrading_PV_drivers.html#win2008-citrix-upgrade)、[AWS](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/xen-drivers-overview.html)) +- Virtio ([Virtio](https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/)、[阿里云](https://www.alibabacloud.com/help/ecs/user-guide/install-the-virtio-driver-1)) +- XEN ([~~XEN~~(未签名)](https://xenproject.org/resources/downloads/)、[Citrix](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Upgrading_PV_drivers.html#win2008-citrix-upgrade)、[AWS](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/xen-drivers-overview.html)) - AWS ([ENA 网卡](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ena-driver-releases-windows.html)、[NVME 存储控制器](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/nvme-driver-version-history.html)) - GCP ([gVNIC 网卡](https://cloud.google.com/compute/docs/networking/using-gvnic)、[GGA 显卡](https://cloud.google.com/compute/docs/instances/enable-instance-virtual-display)) - Azure ([MANA 网卡](https://learn.microsoft.com/azure/virtual-network/accelerated-networking-mana-windows)) diff --git a/reinstall.sh b/reinstall.sh index 9bd09aa..d00ffd0 100644 --- a/reinstall.sh +++ b/reinstall.sh @@ -153,10 +153,10 @@ is_in_china() { # 备用 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 + if ! _loc=$(curl -L http://www.visa.cn/cdn-cgi/trace | grep '^loc=' | cut -d= -f2 | grep .); then error_and_exit "Can not get location." fi + echo "Location: $_loc" >&2 fi [ "$_loc" = CN ] } @@ -341,7 +341,7 @@ test_url_real() { real_type=$(file_enhanced $tmp_file) echo "File type: $real_type" - # debian 9 ubuntu 16.04 可能会将 iso 识别成 raw + # debian 9 ubuntu 16.04-20.04 可能会将 iso 识别成 raw for type in $expect_types $([ "$expect_types" = iso ] && echo raw); do if [[ ."$real_type" = *."$type" ]]; then # 如果要设置变量 @@ -1214,17 +1214,11 @@ Continue? ci_mirror=https://cloud-images.ubuntu.com fi - # 22.04 和以下没有 minimal aarch64 镜像 + # 以下版本有 minimal 镜像 + # amd64 所有 + # arm64 24.04 和以上 is_have_minimal_image() { - [ "$basearch_alt" = amd64 ] || [ "$releasever" = 24.04 ] - } - - is_should_use_minimal_cloud_image() { - if [ "$minimal" = 1 ] && ! is_have_minimal_image; then - echo "Fallback to normal cloud image." - return 1 - fi - [ "$minimal" = 1 ] + [ "$basearch_alt" = amd64 ] || [ "${releasever%.*}" -ge 24 ] } get_suffix() { @@ -1237,7 +1231,10 @@ Continue? fi } - if is_should_use_minimal_cloud_image; then + if [ "$minimal" = 1 ]; then + if ! is_have_minimal_image; then + error_and_exit "Minimal cloud image is not available for $releasever $basearch_alt." + fi eval ${step}_img="$ci_mirror/minimal/releases/$codename/release/ubuntu-$releasever-minimal-cloudimg-$basearch_alt$(get_suffix).img" else eval ${step}_img="$ci_mirror/releases/$releasever/release/ubuntu-$releasever-server-cloudimg-$basearch_alt$(get_suffix).img" @@ -3629,7 +3626,7 @@ else fi long_opts= -for o in ci installer debug minimal allow-ping force-cn \ +for o in ci installer debug minimal allow-ping force-cn help \ add-driver: \ hold: sleep: \ iso: \ @@ -3651,7 +3648,7 @@ for o in ci installer debug minimal allow-ping force-cn \ done # 整理参数 -if ! opts=$(getopt -n $0 -o "" --long "$long_opts" -- "$@"); then +if ! opts=$(getopt -n $0 -o "h" --long "$long_opts" -- "$@"); then exit fi @@ -3659,6 +3656,9 @@ eval set -- "$opts" # shellcheck disable=SC2034 while true; do case "$1" in + -h | --help) + usage_and_exit + ;; --commit) commit=$2 shift 2 From cfd39be075fadcaff8e6f39a05a4a95a9fbfafff Mon Sep 17 00:00:00 2001 From: bin456789 Date: Thu, 6 Mar 2025 21:04:50 +0800 Subject: [PATCH 007/127] =?UTF-8?q?core:=20=E4=BF=AE=E5=A4=8D=E6=B2=A1?= =?UTF-8?q?=E5=AE=89=E8=A3=85=20curl=20=E6=97=B6=20--ssh-key=20=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=20key=20=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- reinstall.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/reinstall.sh b/reinstall.sh index d00ffd0..db7ee35 100644 --- a/reinstall.sh +++ b/reinstall.sh @@ -116,6 +116,8 @@ error_and_exit() { } curl() { + is_have_cmd curl || install_pkg curl + # 添加 -f, --fail,不然 404 退出码也为0 # 32位 cygwin 已停止更新,证书可能有问题,先添加 --insecure # centos 7 curl 不支持 --retry-connrefused --retry-all-errors From 6a93bcc1851143cfe7b84b28779879b92ef03928 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Fri, 7 Mar 2025 22:22:11 +0800 Subject: [PATCH 008/127] =?UTF-8?q?windows:=20=E4=BF=AE=E5=A4=8D=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E6=AD=A3=E7=A1=AE=E6=B7=BB=E5=8A=A0=20xen=20=E9=A9=B1?= =?UTF-8?q?=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.en.md | 18 ++++++++++-------- README.md | 18 ++++++++++-------- reinstall.sh | 5 +++-- trans.sh | 9 ++++----- 4 files changed, 27 insertions(+), 23 deletions(-) diff --git a/README.en.md b/README.en.md index c8a7cfc..579e215 100644 --- a/README.en.md +++ b/README.en.md @@ -150,14 +150,15 @@ bash reinstall.sh anolis 7|8|23 #### Optional Parameters - `--password PASSWORD` Set the password -- `--ssh-key KEY` Set up SSH public key, supports these formats. When using public key, password is empty. +- `--ssh-key KEY` Set up SSH login public key, supports these formats. When using public key, password is empty. - `--ssh-key "ssh-rsa ..."` - `--ssh-key "ssh-ed25519 ..."` - `--ssh-key "ecdsa-sha2-nistp256/384/521 ..."` - - `--ssh-key http://url` + - `--ssh-key http://path/to/public_key` - `--ssh-key github:your_username` - `--ssh-key gitlab:your_username` - `--ssh-key /path/to/public_key` + - `--ssh-key C:\path\to\public_key` - `--ssh-port PORT` Change the SSH port (for log observation during installation and for the new system) - `--web-port PORT` Change the Web port (for log observation during installation) - `--hold 2` Prevent reboot after installation completes, allowing SSH login to modify system content; the system is mounted at `/os` (this feature is not supported on Debian/Kali). @@ -236,14 +237,15 @@ bash reinstall.sh alpine --hold=1 - `--password PASSWORD` Set password - `--ssh-port PORT` Change SSH port -- `--ssh-key KEY` Set up SSH public key, supports these formats. When using public key, password is empty. - - `--ssh-key ssh-rsa ...` - - `--ssh-key ssh-ed25519 ...` - - `--ssh-key ecdsa-sha2-nistp256/384/521 ...` - - `--ssh-key http://url` +- `--ssh-key KEY` Set up SSH login public key, supports these formats. When using public key, password is empty. + - `--ssh-key "ssh-rsa ..."` + - `--ssh-key "ssh-ed25519 ..."` + - `--ssh-key "ecdsa-sha2-nistp256/384/521 ..."` + - `--ssh-key http://path/to/public_key` - `--ssh-key github:your_username` - `--ssh-key gitlab:your_username` - `--ssh-key /path/to/public_key` + - `--ssh-key C:\path\to\public_key` ### Feature 4: Reboot to netboot.xyz @@ -395,7 +397,7 @@ bash reinstall.sh windows \ #### The following drivers will automatic download and install as needed, without the need for manual addition - Virtio ([Virtio](https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/), [Alibaba Cloud](https://www.alibabacloud.com/help/ecs/user-guide/install-the-virtio-driver-1)) -- XEN ([~~XEN~~(unsigned)](https://xenproject.org/resources/downloads/), [Citrix](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Upgrading_PV_drivers.html#win2008-citrix-upgrade), [AWS](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/xen-drivers-overview.html)) +- XEN ([~~XEN~~ (unsigned)](https://xenproject.org/resources/downloads/), [Citrix](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Upgrading_PV_drivers.html#win2008-citrix-upgrade), [AWS](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/xen-drivers-overview.html)) - AWS ([ENA Network Adapter](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ena-driver-releases-windows.html), [NVMe Storage Controller](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/nvme-driver-version-history.html)) - GCP ([gVNIC Network Adapter](https://cloud.google.com/compute/docs/networking/using-gvnic), [GGA Display Adapter](https://cloud.google.com/compute/docs/instances/enable-instance-virtual-display)) - Azure ([MANA Network Adapter](https://learn.microsoft.com/azure/virtual-network/accelerated-networking-mana-windows)) diff --git a/README.md b/README.md index c7d4e25..90733c3 100644 --- a/README.md +++ b/README.md @@ -150,14 +150,15 @@ bash reinstall.sh anolis 7|8|23 #### 可选参数 - `--password PASSWORD` 设置密码 -- `--ssh-key KEY` 设置 SSH 公钥登录,支持以下格式。当使用公钥时,密码为空 +- `--ssh-key KEY` 设置 SSH 登录公钥,支持以下格式。当使用公钥时,密码为空 - `--ssh-key "ssh-rsa ..."` - `--ssh-key "ssh-ed25519 ..."` - `--ssh-key "ecdsa-sha2-nistp256/384/521 ..."` - - `--ssh-key http://url` + - `--ssh-key http://path/to/public_key` - `--ssh-key github:your_username` - `--ssh-key gitlab:your_username` - `--ssh-key /path/to/public_key` + - `--ssh-key C:\path\to\public_key` - `--ssh-port PORT` 修改 SSH 端口(安装期间观察日志用,也作用于新系统) - `--web-port PORT` 修改 Web 端口(安装期间观察日志用) - `--hold 2` 安装结束后不重启,此时可以 SSH 登录修改系统内容,系统挂载在 `/os` (此功能不支持 Debian/Kali) @@ -236,14 +237,15 @@ bash reinstall.sh alpine --hold=1 - `--password PASSWORD` 设置密码 - `--ssh-port PORT` 修改 SSH 端口 -- `--ssh-key KEY` 设置 SSH 公钥登录,支持以下格式。当使用公钥时,密码为空 - - `--ssh-key ssh-rsa ...` - - `--ssh-key ssh-ed25519 ...` - - `--ssh-key ecdsa-sha2-nistp256/384/521 ...` - - `--ssh-key http://url` +- `--ssh-key KEY` 设置 SSH 登录公钥,支持以下格式。当使用公钥时,密码为空 + - `--ssh-key "ssh-rsa ..."` + - `--ssh-key "ssh-ed25519 ..."` + - `--ssh-key "ecdsa-sha2-nistp256/384/521 ..."` + - `--ssh-key http://path/to/public_key` - `--ssh-key github:your_username` - `--ssh-key gitlab:your_username` - `--ssh-key /path/to/public_key` + - `--ssh-key C:\path\to\public_key` ### 功能 4: 重启到 netboot.xyz @@ -395,7 +397,7 @@ bash reinstall.sh windows \ #### 以下驱动会自动按需下载安装,无需手动添加 - Virtio ([Virtio](https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/)、[阿里云](https://www.alibabacloud.com/help/ecs/user-guide/install-the-virtio-driver-1)) -- XEN ([~~XEN~~(未签名)](https://xenproject.org/resources/downloads/)、[Citrix](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Upgrading_PV_drivers.html#win2008-citrix-upgrade)、[AWS](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/xen-drivers-overview.html)) +- XEN ([~~XEN~~ (未签名)](https://xenproject.org/resources/downloads/)、[Citrix](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Upgrading_PV_drivers.html#win2008-citrix-upgrade)、[AWS](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/xen-drivers-overview.html)) - AWS ([ENA 网卡](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ena-driver-releases-windows.html)、[NVME 存储控制器](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/nvme-driver-version-history.html)) - GCP ([gVNIC 网卡](https://cloud.google.com/compute/docs/networking/using-gvnic)、[GGA 显卡](https://cloud.google.com/compute/docs/instances/enable-instance-virtual-display)) - Azure ([MANA 网卡](https://learn.microsoft.com/azure/virtual-network/accelerated-networking-mana-windows)) diff --git a/reinstall.sh b/reinstall.sh index db7ee35..702a3c3 100644 --- a/reinstall.sh +++ b/reinstall.sh @@ -3721,9 +3721,10 @@ Available options: --ssh-key "ecdsa-sha2-nistp256/384/521 ..." --ssh-key github:your_username --ssh-key gitlab:your_username - --ssh-key http://url - --ssh-key https://url + --ssh-key http://path/to/public_key + --ssh-key https://path/to/public_key --ssh-key /path/to/public_key + --ssh-key C:\path\to\public_key EOF exit 1 } diff --git a/trans.sh b/trans.sh index f532061..a9c772e 100644 --- a/trans.sh +++ b/trans.sh @@ -5496,11 +5496,10 @@ install_windows() { download "$(get_aws_repo)/AWSPV/$aws_pv_ver/AWSPVDriver.zip" $drv/AWSPVDriver.zip unzip -o -d $drv $drv/AWSPVDriver.zip - msiextract $drv/AWSPVDriverSetup.msi -C $drv - mkdir -p $drv/aws/ - cp -rf $drv/.Drivers/* $drv/aws/ + mkdir -p $drv/xen/ + msiextract $drv/AWSPVDriverSetup.msi -C $drv/xen/ - cp_drivers $drv/xen -ipath "*/$arch_xdd/*" + cp_drivers $drv/xen/.Drivers } # citrix xen @@ -5531,7 +5530,7 @@ install_windows() { tar -xf $drv/$part.tar -C $drv/xen/ done - cp_drivers $drv/xen + cp_drivers $drv/xen -ipath "*/$arch_xdd/*" } # virtio From 243bdb0831ec1275609986269bfb75e8508caa7f Mon Sep 17 00:00:00 2001 From: bin456789 Date: Mon, 10 Mar 2025 22:21:46 +0800 Subject: [PATCH 009/127] =?UTF-8?q?windows:=20=E6=B7=BB=E5=8A=A0=20intel?= =?UTF-8?q?=20=E7=BD=91=E5=8D=A1=E9=A9=B1=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.en.md | 39 +++++++++-- README.md | 39 +++++++++-- trans.sh | 140 +++++++++++++++++++++++++++++++++++++++- windows-driver-utils.sh | 32 +++++++++ 4 files changed, 233 insertions(+), 17 deletions(-) diff --git a/README.en.md b/README.en.md index 579e215..07b7d39 100644 --- a/README.en.md +++ b/README.en.md @@ -1,4 +1,4 @@ - + # reinstall @@ -396,12 +396,37 @@ bash reinstall.sh windows \ #### The following drivers will automatic download and install as needed, without the need for manual addition -- Virtio ([Virtio](https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/), [Alibaba Cloud](https://www.alibabacloud.com/help/ecs/user-guide/install-the-virtio-driver-1)) -- XEN ([~~XEN~~ (unsigned)](https://xenproject.org/resources/downloads/), [Citrix](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Upgrading_PV_drivers.html#win2008-citrix-upgrade), [AWS](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/xen-drivers-overview.html)) -- AWS ([ENA Network Adapter](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ena-driver-releases-windows.html), [NVMe Storage Controller](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/nvme-driver-version-history.html)) -- GCP ([gVNIC Network Adapter](https://cloud.google.com/compute/docs/networking/using-gvnic), [GGA Display Adapter](https://cloud.google.com/compute/docs/instances/enable-instance-virtual-display)) -- Azure ([MANA Network Adapter](https://learn.microsoft.com/azure/virtual-network/accelerated-networking-mana-windows)) -- Intel ([VMD Storage Controller](https://www.intel.com/content/www/us/en/download/720755/intel-rapid-storage-technology-driver-installation-software-with-intel-optane-memory-11th-up-to-13th-gen-platforms.html)) +- Virtio ([Virtio][virtio-virtio],[Alibaba Cloud][virtio-aliyun]) +- XEN ([~~XEN~~][xen-xen] (unsigned), [Citrix][xen-citrix], [AWS][xen-aws]) +- AWS ([ENA Network Adapter][aws-ena], [NVME Storage Controller][aws-nvme]) +- GCP ([gVNIC Network Adapter][gcp-gvnic], [GGA Display Adapter][gcp-gga]) +- Azure ([MANA Network Adapter][azure-mana]) +- Intel ([VMD Storage Controller][intel-vmd], Network Adapter: [7][intel-nic-7-sha1], [8][intel-nic-8], [8.1][intel-nic-8.1], [10][intel-nic-10], [11][intel-nic-11], [2008 R2][intel-nic-7-sha1], [2012][intel-nic-2012], [2012 R2][intel-nic-2012-r2], [2016][intel-nic-2016], [2019][intel-nic-2019], [2022][intel-nic-2022], [2025][intel-nic-2025]) + +[virtio-virtio]: https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/ +[virtio-aliyun]: https://www.alibabacloud.com/help/ecs/user-guide/install-the-virtio-driver-1 +[xen-xen]: https://xenproject.org/resources/downloads/ +[xen-aws]: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/xen-drivers-overview.html +[xen-citrix]: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Upgrading_PV_drivers.html#win2008-citrix-upgrade +[aws-ena]: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ena-driver-releases-windows.html +[aws-nvme]: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/nvme-driver-version-history.html +[gcp-gvnic]: https://cloud.google.com/compute/docs/networking/using-gvnic +[gcp-gga]: https://cloud.google.com/compute/docs/instances/enable-instance-virtual-display +[azure-mana]: https://learn.microsoft.com/azure/virtual-network/accelerated-networking-mana-windows +[intel-vmd]: https://www.intel.com/content/www/us/en/download/720755/intel-rapid-storage-technology-driver-installation-software-with-intel-optane-memory-11th-up-to-13th-gen-platforms.html +[intel-nic-7-sha1]: https://www.intel.com/content/www/us/en/download/15590/29323/intel-network-adapter-driver-for-windows-7-final-release.html +[intel-nic-7-sha256]: https://www.intel.com/content/www/us/en/download/15590/intel-network-adapter-driver-for-windows-7-final-release.html +[intel-nic-8]: https://www.intel.com/content/www/us/en/download/16765/intel-network-adapter-driver-for-windows-8-final-release.html +[intel-nic-8.1]: https://www.intel.com/content/www/us/en/download/17479/intel-network-adapter-driver-for-windows-8-1.html +[intel-nic-10]: https://www.intel.com/content/www/us/en/download/18293/intel-network-adapter-driver-for-windows-10.html +[intel-nic-11]: https://www.intel.com/content/www/us/en/download/727998/intel-network-adapter-driver-for-microsoft-windows-11.html +[intel-nic-2008-r2-sha256]: https://www.intel.com/content/www/us/en/download/15591/intel-network-adapter-driver-for-windows-server-2008-r2-final-release.html +[intel-nic-2012]: https://www.intel.com/content/www/us/en/download/16789/intel-network-adapter-driver-for-windows-server-2012.html +[intel-nic-2012-r2]: https://www.intel.com/content/www/us/en/download/17480/intel-network-adapter-driver-for-windows-server-2012-r2.html +[intel-nic-2016]: https://www.intel.com/content/www/us/en/download/18737/intel-network-adapter-driver-for-windows-server-2016.html +[intel-nic-2019]: https://www.intel.com/content/www/us/en/download/19372/intel-network-adapter-driver-for-windows-server-2019.html +[intel-nic-2022]: https://www.intel.com/content/www/us/en/download/706171/intel-network-adapter-driver-for-windows-server-2022.html +[intel-nic-2025]: https://www.intel.com/content/www/us/en/download/838943/intel-network-adapter-driver-for-windows-server-2025.html #### How to Specify the Image Name `--image-name` diff --git a/README.md b/README.md index 90733c3..0b4a1d9 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ - + # reinstall @@ -396,12 +396,37 @@ bash reinstall.sh windows \ #### 以下驱动会自动按需下载安装,无需手动添加 -- Virtio ([Virtio](https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/)、[阿里云](https://www.alibabacloud.com/help/ecs/user-guide/install-the-virtio-driver-1)) -- XEN ([~~XEN~~ (未签名)](https://xenproject.org/resources/downloads/)、[Citrix](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Upgrading_PV_drivers.html#win2008-citrix-upgrade)、[AWS](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/xen-drivers-overview.html)) -- AWS ([ENA 网卡](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ena-driver-releases-windows.html)、[NVME 存储控制器](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/nvme-driver-version-history.html)) -- GCP ([gVNIC 网卡](https://cloud.google.com/compute/docs/networking/using-gvnic)、[GGA 显卡](https://cloud.google.com/compute/docs/instances/enable-instance-virtual-display)) -- Azure ([MANA 网卡](https://learn.microsoft.com/azure/virtual-network/accelerated-networking-mana-windows)) -- Intel ([VMD 存储控制器](https://www.intel.com/content/www/us/en/download/720755/intel-rapid-storage-technology-driver-installation-software-with-intel-optane-memory-11th-up-to-13th-gen-platforms.html)) +- Virtio ([Virtio][virtio-virtio],[阿里云][virtio-aliyun]) +- XEN ([~~XEN~~][xen-xen] (未签名), [Citrix][xen-citrix], [AWS][xen-aws]) +- AWS ([ENA 网卡][aws-ena], [NVME 存储控制器][aws-nvme]) +- GCP ([gVNIC 网卡][gcp-gvnic], [GGA 显卡][gcp-gga]) +- Azure ([MANA 网卡][azure-mana]) +- Intel ([VMD 存储控制器][intel-vmd], 网卡: [7][intel-nic-7-sha1], [8][intel-nic-8], [8.1][intel-nic-8.1], [10][intel-nic-10], [11][intel-nic-11], [2008 R2][intel-nic-7-sha1], [2012][intel-nic-2012], [2012 R2][intel-nic-2012-r2], [2016][intel-nic-2016], [2019][intel-nic-2019], [2022][intel-nic-2022], [2025][intel-nic-2025]) + +[virtio-virtio]: https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/ +[virtio-aliyun]: https://www.alibabacloud.com/help/ecs/user-guide/install-the-virtio-driver-1 +[xen-xen]: https://xenproject.org/resources/downloads/ +[xen-aws]: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/xen-drivers-overview.html +[xen-citrix]: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Upgrading_PV_drivers.html#win2008-citrix-upgrade +[aws-ena]: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ena-driver-releases-windows.html +[aws-nvme]: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/nvme-driver-version-history.html +[gcp-gvnic]: https://cloud.google.com/compute/docs/networking/using-gvnic +[gcp-gga]: https://cloud.google.com/compute/docs/instances/enable-instance-virtual-display +[azure-mana]: https://learn.microsoft.com/azure/virtual-network/accelerated-networking-mana-windows +[intel-vmd]: https://www.intel.com/content/www/us/en/download/720755/intel-rapid-storage-technology-driver-installation-software-with-intel-optane-memory-11th-up-to-13th-gen-platforms.html +[intel-nic-7-sha1]: https://www.intel.com/content/www/us/en/download/15590/29323/intel-network-adapter-driver-for-windows-7-final-release.html +[intel-nic-7-sha256]: https://www.intel.com/content/www/us/en/download/15590/intel-network-adapter-driver-for-windows-7-final-release.html +[intel-nic-8]: https://www.intel.com/content/www/us/en/download/16765/intel-network-adapter-driver-for-windows-8-final-release.html +[intel-nic-8.1]: https://www.intel.com/content/www/us/en/download/17479/intel-network-adapter-driver-for-windows-8-1.html +[intel-nic-10]: https://www.intel.com/content/www/us/en/download/18293/intel-network-adapter-driver-for-windows-10.html +[intel-nic-11]: https://www.intel.com/content/www/us/en/download/727998/intel-network-adapter-driver-for-microsoft-windows-11.html +[intel-nic-2008-r2-sha256]: https://www.intel.com/content/www/us/en/download/15591/intel-network-adapter-driver-for-windows-server-2008-r2-final-release.html +[intel-nic-2012]: https://www.intel.com/content/www/us/en/download/16789/intel-network-adapter-driver-for-windows-server-2012.html +[intel-nic-2012-r2]: https://www.intel.com/content/www/us/en/download/17480/intel-network-adapter-driver-for-windows-server-2012-r2.html +[intel-nic-2016]: https://www.intel.com/content/www/us/en/download/18737/intel-network-adapter-driver-for-windows-server-2016.html +[intel-nic-2019]: https://www.intel.com/content/www/us/en/download/19372/intel-network-adapter-driver-for-windows-server-2019.html +[intel-nic-2022]: https://www.intel.com/content/www/us/en/download/706171/intel-network-adapter-driver-for-windows-server-2022.html +[intel-nic-2025]: https://www.intel.com/content/www/us/en/download/838943/intel-network-adapter-driver-for-windows-server-2025.html #### 如何填写映像名称 `--image-name` diff --git a/trans.sh b/trans.sh index a9c772e..25eeb73 100644 --- a/trans.sh +++ b/trans.sh @@ -5120,6 +5120,22 @@ is_absolute_path() { [[ "$1" = "/*" ]] } +# 注意使用方法是 list=$(list_add "$list" "$item_to_add") +list_add() { + local list=$1 + local item_to_add=$2 + if [ -n "$list" ]; then + echo "$list" + fi + echo "$item_to_add" +} + +is_list_has() { + local list=$1 + local item=$2 + echo "$list" | grep -qFx "$item" +} + install_windows() { get_wim_prop() { wim=$1 @@ -5420,10 +5436,122 @@ install_windows() { ;; esac + # intel 网卡驱动 + # 官网没有提供 vista/2008 驱动 + # win7 驱动 inf/ndis 不支持 vista/2008 + if is_nt_ver_ge 6.1 && { [ "$arch_wim" = x86 ] || [ "$arch_wim" = x86_64 ]; } && + grep -iq 8086 /sys/class/net/e*/device/vendor; then + add_driver_intel_nic + fi + # 自定义驱动 add_driver_custom } + add_driver_intel_nic() { + info "Add drivers: Intel NIC" + + arch_intel=$( + case "$arch_wim" in + x86) echo 32 ;; + x86_64) echo x64 ;; + esac + ) + + file=$( + case "$product_ver" in + '7' | '2008 r2') echo 29323/eng/prowin${arch_intel}legacy.exe ;; # 24.3 sha1 签名 + # '7' | '2008 r2') echo 18713/eng/prowin${arch_intel}legacy.exe ;; # 25.0 有部分文件是 sha256 签名 + '8') echo 21642/eng/prowin${arch_intel}.exe ;; + '8.1') echo 764813/Wired_driver_27.8_${arch_intel}.zip ;; + '2012' | '2012 r2') echo 785805/Wired_driver_28.2_${arch_intel}.zip ;; + *) echo 845886/Wired_driver_30.0_${arch_intel}.zip ;; + esac + ) + + # intel 禁止了 aria2 下载 + # download https://downloadmirror.intel.com/$file $drv/intel.zip + wget https://downloadmirror.intel.com/$file -O $drv/intel.zip + + # inf 可能是 UTF-16 LE?因此用 rg 搜索 + # 用 busybox unzip 解压 win10 驱动时,路径和文件名会粘在一起 + apk add unzip ripgrep + + # win7 驱动是 .exe 解压不会报错 + # win10 驱动是 .zip 解压反而会报错,目测 zip 文件有问题 + # 在 windows 下解压 win8 的驱动会提示 checksum 错误 + unzip -o -d $drv/intel/ $drv/intel.zip || true + + # Vista RTM 版本号是 6000 NDIS 6.0 + # 2008 RTM 版本号是 6001 NDIS 6.1 + + # 找出驱动文件夹对应的最低系统版本 + # 1. 驱动可能限制 windows client/server,但我们不区分 + # 如果装不了也没关系。如果能装但不加载,用户也可以在硬件管理器强制加载驱动 + # 2. 官网写着 win10 驱动要求 RS5 1809,但是驱动包里有 NDIS65 文件夹,也就是支持 10240 + # 3. 有可能 NDIS65 文件夹实际要求 NDIS 6.51?但是先不管 + # https://learn.microsoft.com/en-us/windows-hardware/drivers/network/overview-of-ndis-versions + min_support_map=$(cat < Date: Mon, 10 Mar 2025 22:23:37 +0800 Subject: [PATCH 010/127] =?UTF-8?q?core:=20=E4=B8=8D=E9=87=8D=E8=A6=81?= =?UTF-8?q?=E7=9A=84=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 更优雅地 overwrite windows 命令 - 更改 openSUSE 源 - 删除 wicked 网卡配置的 cloud-init 注释 --- README.en.md | 1 - README.md | 1 - reinstall.sh | 21 +++++++++++++++------ trans.sh | 13 +++++++++++++ 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/README.en.md b/README.en.md index 07b7d39..5f146fc 100644 --- a/README.en.md +++ b/README.en.md @@ -7,7 +7,6 @@ [![Lines of Code](https://tokei.rs/b1/github/bin456789/reinstall?category=code&label=Lines%20of%20Code&style=flat-square)](https://github.com/XAMPPRocky/tokei) [![Telegram Group](https://img.shields.io/badge/Telegram-2CA5E0?style=flat-square&logo=telegram&logoColor=white)](https://t.me/reinstall_os) [![Github Sponsors](https://img.shields.io/badge/sponsor-30363D?style=flat-square&logo=GitHub-Sponsors&logoColor=#EA4AAA)](https://github.com/sponsors/bin456789) - One-Click Script to Reinstall System [中文](README.md) diff --git a/README.md b/README.md index 0b4a1d9..6d6f69e 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,6 @@ [![Lines of Code](https://tokei.rs/b1/github/bin456789/reinstall?category=code&label=Lines%20of%20Code&style=flat-square)](https://github.com/XAMPPRocky/tokei) [![Telegram Group](https://img.shields.io/badge/Telegram-2CA5E0?style=flat-square&logo=telegram&logoColor=white)](https://t.me/reinstall_os) [![Github Sponsors](https://img.shields.io/badge/sponsor-30363D?style=flat-square&logo=GitHub-Sponsors&logoColor=#EA4AAA)](https://github.com/sponsors/bin456789) - 一键重装脚本 [English](README.en.md) diff --git a/reinstall.sh b/reinstall.sh index 702a3c3..683f63a 100644 --- a/reinstall.sh +++ b/reinstall.sh @@ -488,15 +488,14 @@ run_with_del_cr() { } run_with_del_cr_template() { - # 调用链:wmic() -> run_with_del_cr(wmic) -> _wmic() -> command wmic - if command -v _$exe >/dev/null; then + if get_function _$exe >/dev/null; then run_with_del_cr _$exe "$@" else run_with_del_cr command $exe "$@" fi } -_wmic() { +wmic() { if is_have_cmd wmic; then # 如果参数没有 GET,添加 GET,防止以下报错 # wmic memorychip /format:list @@ -1343,8 +1342,12 @@ Continue? } setos_opensuse() { - # aria2 有 mata4 问题 # https://download.opensuse.org/ + # curl 会跳转到最近的镜像源,但可能会被镜像源 block + # aria2 会跳转使用 metalink + + # https://downloadcontent.opensuse.org # 德国 + # https://downloadcontentcdn.opensuse.org # fastly cdn # 很多国内源缺少 aarch64 tumbleweed appliances # https://download.opensuse.org/ports/aarch64/tumbleweed/appliances/ @@ -1354,7 +1357,7 @@ Continue? if is_in_china; then mirror=https://mirror.nju.edu.cn/opensuse else - mirror=https://ftp.gwdg.de/pub/opensuse + mirror=https://downloadcontentcdn.opensuse.org fi if [ "$releasever" = tumbleweed ]; then @@ -2667,7 +2670,7 @@ install_grub_linux_efi() { if is_in_china; then mirror=https://mirror.nju.edu.cn/opensuse else - mirror=https://ftp.gwdg.de/pub/opensuse + mirror=https://downloadcontentcdn.opensuse.org fi [ "$basearch" = x86_64 ] && ports='' || ports=/ports/$basearch @@ -3611,6 +3614,12 @@ if is_in_windows; then # 为 windows 程序输出删除 cr for exe in $WINDOWS_EXES; do + # 如果我们覆写了 wmic(),则先将 wmic() 重命名为 _wmic() + if get_function $exe >/dev/null 2>&1; then + eval "_$(get_function $exe)" + fi + # 使用以下方法重新生成 wmic() + # 调用链:wmic() -> run_with_del_cr(wmic) -> _wmic() -> command wmic eval "$exe(){ $(get_function_content run_with_del_cr_template | sed "s/\$exe/$exe/g") }" done fi diff --git a/trans.sh b/trans.sh index 25eeb73..fb450dc 100644 --- a/trans.sh +++ b/trans.sh @@ -3347,6 +3347,11 @@ EOF chroot $os_dir cloud-init devel net-convert \ -p /net.cfg -k yaml -d out -D opensuse -O sysconfig + # 删除 + # Created by cloud-init on instance boot automatically, do not edit. + # + sed -i '/^#/d' "$os_dir/out/etc/sysconfig/network/ifcfg-eth"* + for ethx in $(get_eths); do # 1. 修复甲骨文云重启后 ipv6 丢失 # https://github.com/openSUSE/wicked/issues/1058 @@ -5642,6 +5647,14 @@ EOF # 2012 9.3.0 # 2008 (r2) 7.2.0.1555 + # 9.3.1 + # https://downloads.xenserver.com/vm-tools-windows/9.3.1/managementagentx64.msi + # http://downloadns.citrix.com.edgesuite.net/17461/managementagentx64.msi + + # 7.2.0.1555 + # http://downloadns.citrix.com.edgesuite.net/14656/managementagentx64.msi + # http://downloadns.citrix.com.edgesuite.net/14655/managementagentx86.msi + # xen # 没签名,暂时用aws的驱动代替 # https://lore.kernel.org/xen-devel/E1qKMmq-00035B-SS@xenbits.xenproject.org/ From f3d86945672f4cebf37f64902e880b5dec739abf Mon Sep 17 00:00:00 2001 From: bin456789 Date: Wed, 19 Mar 2025 23:42:45 +0800 Subject: [PATCH 011/127] =?UTF-8?q?core:=20=E4=B8=B4=E6=97=B6=E5=88=87?= =?UTF-8?q?=E6=8D=A2=E5=88=B0=20fedora=20efi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit link #288 #292 --- reinstall.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reinstall.sh b/reinstall.sh index 683f63a..8be31e6 100644 --- a/reinstall.sh +++ b/reinstall.sh @@ -2645,7 +2645,7 @@ install_grub_linux_efi() { info 'download grub efi' # fedora 39 的 efi 无法识别 opensuse tumbleweed 的 xfs - efi_distro=opensuse + efi_distro=fedora grub_efi=$(get_grub_efi_filename) # 不要用 download.opensuse.org 和 download.fedoraproject.org @@ -2657,7 +2657,7 @@ install_grub_linux_efi() { # https://mirror.fcix.net/opensuse/tumbleweed/repo/oss/EFI/BOOT/bootx64.efi # https://mirror.fcix.net/opensuse/tumbleweed/appliances/openSUSE-Tumbleweed-Minimal-VM.x86_64-Cloud.qcow2 if [ "$efi_distro" = fedora ]; then - fedora_ver=40 + fedora_ver=41 if is_in_china; then mirror=https://mirror.nju.edu.cn/fedora From 84c893150f2bd8cef652b4ad3af4ca501b587f37 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Thu, 20 Mar 2025 21:55:37 +0800 Subject: [PATCH 012/127] =?UTF-8?q?ubuntu:=20=E4=BF=AE=E5=A4=8D=20do-relea?= =?UTF-8?q?se-upgrade=20=E6=97=B6=20grub=20=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- trans.sh | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/trans.sh b/trans.sh index fb450dc..02245b5 100644 --- a/trans.sh +++ b/trans.sh @@ -3884,15 +3884,17 @@ chroot_apt_remove() { # 不能用 apt remove --purge -y xxx yyy # 因为如果索引里没有其中一个,会报错,另一个也不会删除 - # 因此需要分开删除 - for package in "$@"; do + local pkgs= + for pkg in "$@"; do # apt list 会提示 WARNING: apt does not have a stable CLI interface. Use with caution in scripts. # 但又不能用 apt-get list - if chroot $os_dir apt list --installed "$package" | grep -q installed; then - # 删除 resolvconf 时会弹出建议重启,因此添加 noninteractive - DEBIAN_FRONTEND=noninteractive chroot $os_dir apt-get remove --purge -y "$package" + if chroot $os_dir apt list --installed "$pkg" | grep -q installed; then + pkgs="$pkgs $pkg" fi done + + # 删除 resolvconf 时会弹出建议重启,因此添加 noninteractive + DEBIAN_FRONTEND=noninteractive chroot $os_dir apt-get remove --purge --allow-remove-essential -y $pkgs } chroot_apt_autoremove() { @@ -4360,6 +4362,24 @@ configfile \$prefix/grub.cfg EOF fi + # 避免 do-release-upgrade 时自动执行 dpkg-reconfigure grub-xx 但是 efi/biosgrub 分区不存在而导致报错 + # shellcheck disable=SC2046 + chroot_apt_remove $os_dir $(is_efi && echo 'grub-pc' || echo 'grub-efi*' 'shim*') + chroot_apt_autoremove $os_dir + + # 安装 mbr + if ! is_efi; then + if false; then + # debconf-show grub-pc + # 每次开机硬盘名字可能不一样,但是 debian netboot 安装后也是设置了 grub-pc/install_devices + echo grub-pc grub-pc/install_devices multiselect /dev/$xda | chroot $os_dir debconf-set-selections # 22.04 + echo grub-pc grub-pc/cloud_style_installation boolean true | chroot $os_dir debconf-set-selections # 24.04 + chroot $os_dir dpkg-reconfigure -f noninteractive grub-pc + else + chroot $os_dir grub-install /dev/$xda + fi + fi + # 自带内核: # 常规版本 generic # minimal 20.04/22.04 kvm # 后台 vnc 无显示 @@ -4442,11 +4462,6 @@ EOF fi fi - # 安装 bios 引导 - if ! is_efi; then - chroot $os_dir grub-install /dev/$xda - fi - # 更改 efi 目录的 grub.cfg 写死的 fsuuid # 因为 24.04 fsuuid 对应 boot 分区 efi_grub_cfg=$os_dir/boot/efi/EFI/ubuntu/grub.cfg From 837827f30e88bf19c7840b5da7c085ae5490da27 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Thu, 20 Mar 2025 21:55:38 +0800 Subject: [PATCH 013/127] =?UTF-8?q?el:=20grub2-mkconfig=20=E6=97=B6?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=20--update-bls-cmdline?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- trans.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/trans.sh b/trans.sh index 02245b5..71d88f6 100644 --- a/trans.sh +++ b/trans.sh @@ -4239,8 +4239,12 @@ EOF fi # 主 grub.cfg - # --update-bls-cmdline - chroot /os/ grub2-mkconfig -o "$grub_o_cfg" + if ls /os/boot/loader/entries/*.conf >/dev/null 2>&1 && + chroot /os/ grub2-mkconfig --help | grep -q update-bls-cmdline; then + chroot /os/ grub2-mkconfig -o "$grub_o_cfg" --update-bls-cmdline + else + chroot /os/ grub2-mkconfig -o "$grub_o_cfg" + fi # 网络配置 # el7/8 sysconfig From 0da940b2a79aeb41bd4b9f4cb8110228a4bae25b Mon Sep 17 00:00:00 2001 From: bin456789 Date: Thu, 20 Mar 2025 21:55:38 +0800 Subject: [PATCH 014/127] =?UTF-8?q?core:=20=E6=B7=BB=E5=8A=A0=E9=87=8D?= =?UTF-8?q?=E8=AF=95=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.en.md | 2 +- README.md | 2 +- trans.sh | 12 ++++++++---- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/README.en.md b/README.en.md index 5f146fc..24ec79c 100644 --- a/README.en.md +++ b/README.en.md @@ -342,7 +342,7 @@ zh-tw ```bash bash reinstall.sh windows \ - --image-name "Windows 11 Enterprise LTSC 2024" \ + --image-name "Windows 11 Enterprise LTSC 2024 Evaluation" \ --iso "https://go.microsoft.com/fwlink/?linkid=2289029" ``` diff --git a/README.md b/README.md index 6d6f69e..fb66e81 100644 --- a/README.md +++ b/README.md @@ -342,7 +342,7 @@ zh-tw ```bash bash reinstall.sh windows \ - --image-name "Windows 11 Enterprise LTSC 2024" \ + --image-name "Windows 11 Enterprise LTSC 2024 Evaluation" \ --iso "https://go.microsoft.com/fwlink/?linkid=2289029" ``` diff --git a/trans.sh b/trans.sh index 71d88f6..412e178 100644 --- a/trans.sh +++ b/trans.sh @@ -46,6 +46,8 @@ warn() { error_and_exit() { error "$@" + echo "Run '/trans.sh' to retry." >&2 + echo "Run '/trans.sh alpine' to install Alpine Linux instead." >&2 exit 1 } @@ -53,10 +55,12 @@ trap_err() { line_no=$1 ret_no=$2 - error "Line $line_no return $ret_no" - if [ -f "/trans.sh" ]; then - sed -n "$line_no"p /trans.sh - fi + error_and_exit "$( + echo "Line $line_no return $ret_no" + if [ -f "/trans.sh" ]; then + sed -n "$line_no"p /trans.sh + fi + )" } is_run_from_locald() { From dd1b3abbfde0a66da779daa040430c0be7e61d79 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Sun, 23 Mar 2025 10:15:48 +0800 Subject: [PATCH 015/127] =?UTF-8?q?core:=20=E4=BF=AE=E5=A4=8D=20efi=20?= =?UTF-8?q?=E6=9D=A1=E7=9B=AE=20inactive=20=E6=97=B6=20(=E6=B2=A1=E6=9C=89?= =?UTF-8?q?*=E7=AC=A6=E5=8F=B7)=20=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://manpages.debian.org/unstable/efibootmgr/efibootmgr.8.en.html#Displaying_the_current_settings_(must_be_root): --- reinstall.sh | 1 + trans.sh | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/reinstall.sh b/reinstall.sh index 8be31e6..fb48c66 100644 --- a/reinstall.sh +++ b/reinstall.sh @@ -2588,6 +2588,7 @@ grep_efi_entry() { grep -E '^Boot[0-9a-fA-F]{4}' } +# trans.sh 有同名方法 grep_efi_index() { awk '{print $1}' | sed -e 's/Boot//' -e 's/\*//' } diff --git a/trans.sh b/trans.sh index 412e178..9950c65 100644 --- a/trans.sh +++ b/trans.sh @@ -822,8 +822,9 @@ del_invalid_efi_entry() { done < <(efibootmgr | grep 'HD(.*,GPT,') } +# reinstall.sh 有同名方法 grep_efi_index() { - awk -F '*' '{print $1}' | sed 's/Boot//' + awk '{print $1}' | sed -e 's/Boot//' -e 's/\*//' } # 某些机器可能不会回落到 bootx64.efi From d603169f761a6f2784e898e3cdc207442e3d220f Mon Sep 17 00:00:00 2001 From: bin456789 Date: Mon, 24 Mar 2025 21:02:01 +0800 Subject: [PATCH 016/127] =?UTF-8?q?core:=20=E6=B7=BB=E5=8A=A0=20udevadm=20?= =?UTF-8?q?settle?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fix-eth-name.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fix-eth-name.sh b/fix-eth-name.sh index 09e3b36..db32213 100644 --- a/fix-eth-name.sh +++ b/fix-eth-name.sh @@ -7,6 +7,13 @@ set -eE # openeuler 需等待 udev 将网卡名从 eth0 改为 enp3s0 sleep 10 +# 不知道有没有用 +if command -v udevadm >/dev/null; then + # udevadm trigger + udevadm settle +elif command -v mdev >/dev/null; then + mdev -sf +fi # 本脚本在首次进入新系统后运行 # 将 trans 阶段生成的网络配置中的网卡名(eth0) 改为正确的网卡名,也适用于以下情况 From daa835dddc42381dd6a03fab80d446d99598d791 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Mon, 24 Mar 2025 21:02:01 +0800 Subject: [PATCH 017/127] =?UTF-8?q?windows:=20=E6=B7=BB=E5=8A=A0=E8=85=BE?= =?UTF-8?q?=E8=AE=AF=E4=BA=91=E3=80=81GCP=20virtio=20=E9=A9=B1=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.en.md | 4 +- README.md | 4 +- trans.sh | 150 ++++++++++++++++++++++++++++++++++++++++++++------- 3 files changed, 136 insertions(+), 22 deletions(-) diff --git a/README.en.md b/README.en.md index 24ec79c..948dd57 100644 --- a/README.en.md +++ b/README.en.md @@ -395,7 +395,7 @@ bash reinstall.sh windows \ #### The following drivers will automatic download and install as needed, without the need for manual addition -- Virtio ([Virtio][virtio-virtio],[Alibaba Cloud][virtio-aliyun]) +- Virtio ([Virtio][virtio-virtio], [Alibaba Cloud][virtio-aliyun], [Tencent Cloud][virtio-qcloud], [GCP][virtio-gcp]) - XEN ([~~XEN~~][xen-xen] (unsigned), [Citrix][xen-citrix], [AWS][xen-aws]) - AWS ([ENA Network Adapter][aws-ena], [NVME Storage Controller][aws-nvme]) - GCP ([gVNIC Network Adapter][gcp-gvnic], [GGA Display Adapter][gcp-gga]) @@ -404,6 +404,8 @@ bash reinstall.sh windows \ [virtio-virtio]: https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/ [virtio-aliyun]: https://www.alibabacloud.com/help/ecs/user-guide/install-the-virtio-driver-1 +[virtio-qcloud]: https://cloud.tencent.com/document/product/213/17815#b84b2032-752c-43c4-a509-73530b8f82ff +[virtio-gcp]: https://console.cloud.google.com/storage/browser/gce-windows-drivers-public [xen-xen]: https://xenproject.org/resources/downloads/ [xen-aws]: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/xen-drivers-overview.html [xen-citrix]: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Upgrading_PV_drivers.html#win2008-citrix-upgrade diff --git a/README.md b/README.md index fb66e81..d1f0c93 100644 --- a/README.md +++ b/README.md @@ -395,7 +395,7 @@ bash reinstall.sh windows \ #### 以下驱动会自动按需下载安装,无需手动添加 -- Virtio ([Virtio][virtio-virtio],[阿里云][virtio-aliyun]) +- Virtio ([Virtio][virtio-virtio], [阿里云][virtio-aliyun], [腾讯云][virtio-qcloud], [GCP][virtio-gcp]) - XEN ([~~XEN~~][xen-xen] (未签名), [Citrix][xen-citrix], [AWS][xen-aws]) - AWS ([ENA 网卡][aws-ena], [NVME 存储控制器][aws-nvme]) - GCP ([gVNIC 网卡][gcp-gvnic], [GGA 显卡][gcp-gga]) @@ -404,6 +404,8 @@ bash reinstall.sh windows \ [virtio-virtio]: https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/ [virtio-aliyun]: https://www.alibabacloud.com/help/ecs/user-guide/install-the-virtio-driver-1 +[virtio-qcloud]: https://cloud.tencent.com/document/product/213/17815#b84b2032-752c-43c4-a509-73530b8f82ff +[virtio-gcp]: https://console.cloud.google.com/storage/browser/gce-windows-drivers-public [xen-xen]: https://xenproject.org/resources/downloads/ [xen-aws]: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/xen-drivers-overview.html [xen-citrix]: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Upgrading_PV_drivers.html#win2008-citrix-upgrade diff --git a/trans.sh b/trans.sh index 9950c65..e3abdeb 100644 --- a/trans.sh +++ b/trans.sh @@ -5136,6 +5136,8 @@ get_cloud_vendor() { echo huawei elif is_dmi_contains 'Alibaba Cloud'; then echo aliyun + elif is_dmi_contains 'Tencent Cloud'; then + echo qcloud fi } @@ -5418,9 +5420,25 @@ install_windows() { if is_virt_contains virtio; then if [ "$vendor" = aliyun ] && is_nt_ver_ge 6.1 && [ "$arch_wim" = x86_64 ]; then add_driver_aliyun_virtio - # 未测试是否需要专用驱动 + elif [ "$vendor" = qcloud ] && is_nt_ver_ge 6.1 && [ "$arch_wim" = x86_64 ]; then + add_driver_qcloud_virtio + # 未测试是否需要专用驱动 elif false && [ "$vendor" = huawei ] && is_nt_ver_ge 6.0 && { [ "$arch_wim" = x86 ] || [ "$arch_wim" = x86_64 ]; }; then add_driver_huawei_virtio + + # gcp 官方驱动不全,需要用公版补全 + elif [ "$vendor" = gcp ] && [ "$nt_ver" = 6.1 ] && [ "$arch_wim" = x86_64 ]; then + add_driver_gcp_virtio_win6_1_sha1_x64 + add_driver_generic_virtio \( -iname viorng.inf -or -iname balloon.inf \) + + elif [ "$vendor" = gcp ] && is_nt_ver_ge 6.2 && [ "$arch_wim" = x86 ]; then + add_driver_gcp_virtio + add_driver_generic_virtio \( -iname viorng.inf -or -iname pvpanic.inf \) + + elif [ "$vendor" = gcp ] && is_nt_ver_ge 6.2 && [ "$arch_wim" = x86_64 ]; then + add_driver_gcp_virtio + add_driver_generic_virtio -iname viorng.inf + else # 兜底 add_driver_generic_virtio @@ -5753,7 +5771,7 @@ EOF mount -o ro $drv/virtio.iso $drv/virtio # -not -ipath "*/balloon/*" - cp_drivers $drv/virtio -ipath "*/$virtio_sys/$arch/*" + cp_drivers $drv/virtio -ipath "*/$virtio_sys/$arch/*" "$@" else # coreutils 的 cp mv rm 才有 -v 参数 apk add 7zip file coreutils @@ -5799,10 +5817,54 @@ EOF mv -v "$file" "$new_file" done ) - cp_drivers $drv/virtio + cp_drivers $drv/virtio "$@" fi } + add_driver_qcloud_virtio() { + info "Add drivers: QCloud virtio" + + # 测试版? + # https://mirrors.tencent.com/install/cts/windows/Drivers.zip + + apk add 7zip + download https://mirrors.tencent.com/install/windows/virtio_64_1.0.9.exe $drv/virtio.exe + exclude='$*' # 排除 $PLUGINSDIR + override=u # A(u)to rename all + 7z x $drv/virtio.exe -o$drv/qcloud/ -ao$override -x!$exclude + + # balloon 6.2 + # balloon_1 6.1 + + # netkvm 10.0 + # netkvm_1 6.1 + # netkvm_2 6.3 + + # viostor 10.0 + # viostor_1 6.1 + # viostor_2 6.2 + + drivers=$( + case "$nt_ver" in + 6.1) echo balloon_1 netkvm_1 viostor_1 ;; # sha1 + 6.2) echo balloon netkvm_1 viostor_2 ;; + 6.3) echo balloon netkvm_2 viostor_2 ;; + *) echo balloon netkvm viostor ;; + esac + ) + + for old_name in $drivers; do + part=${old_name%%_*} + if ! [ "$old_name" = "$part" ]; then + find $drv/qcloud/$part -type f -iname "$old_name.*" | while read -r file; do + ext="${file##*.}" + mv -v "$file" "$drv/qcloud/$part/$part.$ext" + done + fi + cp_drivers $drv/qcloud/$part/$part.inf + done + } + add_driver_huawei_virtio() { info "Add drivers: Huawei virtio" @@ -5887,35 +5949,83 @@ EOF fi } - # gcp - # x86 x86_64 arm64 都有 - add_driver_gcp() { - info "Add drivers: GCP" + # gcp virtio win7 x64 + # 缺 balloon viorng + add_driver_gcp_virtio_win6_1_sha1_x64() { + info "Add drivers: GCP virtio win6.1 sha1 x64" + mkdir -p $drv/gce/win6.1sha1 + for file in \ + WdfCoInstaller01009.dll WdfCoInstaller01011.dll \ + netkvm.inf netkvm.cat netkvm.sys netkvmco.dll \ + nvme.inf nvme64.cat nvme.sys \ + pvpanic.inf pvpanic.sys pvpanic.cat \ + vioscsi.inf vioscsi.sys vioscsi.cat; do + download https://storage.googleapis.com/gce-windows-drivers-public/win6.1sha1/$file $drv/gce/win6.1sha1/$file + done + cp_drivers $drv/gce/win6.1sha1 + } + + # gcp virtio win8+ + # x86 缺 viorng pvpanic + # x64 缺 viorng + # https://github.com/GoogleCloudPlatform/compute-image-tools/tree/master/daisy_workflows/image_build/windows + # 官方是从 https://console.cloud.google.com/storage/browser/gce-windows-drivers-public 下载驱动,安装系统后再 googet 更新驱动 + # 我们一步到位从 googet 下载驱动 + add_driver_gcp_virtio() { + info "Add drivers: GCP virtio" + + mkdir -p $drv/gce gce_repo=https://packages.cloud.google.com/yuck - download $gce_repo/repos/google-compute-engine-stable/index /tmp/gce.json - for name in gvnic gga; do - # gvnic 没有 arm64 - if [ "$name" = gvnic ] && [ "$arch_wim" = arm64 ]; then + download $gce_repo/repos/google-compute-engine-stable/index $drv/gce/gce.json + for part in balloon netkvm pvpanic vioscsi; do + # gcp 提供的 pvpanic 没有 x86 驱动 + if [ "$part" = pvpanic ] && [ "$arch_wim" = x86 ]; then continue fi - mkdir -p $drv/gce/$name - link=$(grep -o "/pool/.*-google-compute-engine-driver-$name.*\.goo" /tmp/gce.json) - wget $gce_repo$link -O- | tar xz -C $drv/gce/$name + mkdir -p $drv/gce/$part + link=$(grep -o "/pool/.*-google-compute-engine-driver-$part.*\.goo" $drv/gce/gce.json) + wget $gce_repo$link -O- | tar xz -C $drv/gce/$part - # 没有 win6.0 文件夹 - # 但 inf 没限制 - # TODO: 测试是否可用 + [ "$arch_wim" = x86 ] && suffix=-32 || suffix= + cp_drivers $drv/gce/$part -ipath "*/win$nt_ver$suffix/*" + done + } + + # gcp + # x86 x86_64 arm64 都有 + # win7 驱动是 sha256 签名 + add_driver_gcp() { + info "Add drivers: GCP" + + # https://packages.cloud.google.com/yuck/repos/google-compute-engine-stable/index + # https://packages.cloud.google.com/yuck/repos/google-compute-engine-driver-gvnic-gq-stable/index + # 官方镜像的 gvnic 是从 gvnic-gq-stable 获取的,版本低一点,但更稳定? + + mkdir -p $drv/gce + gce_repo=https://packages.cloud.google.com/yuck + download $gce_repo/repos/google-compute-engine-stable/index $drv/gce/gce.json + for part in gvnic gga; do + # gvnic 没有 arm64 + if [ "$part" = gvnic ] && [ "$arch_wim" = arm64 ]; then + continue + fi + + mkdir -p $drv/gce/$part + link=$(grep -o "/pool/.*-google-compute-engine-driver-$part.*\.goo" $drv/gce/gce.json) + wget $gce_repo$link -O- | tar xz -C $drv/gce/$part + + # inf 不限版本,6.0 能装 6.1 的驱动但用不了 if false; then for suffix in '' '-32'; do - if [ -d "$drv/gce/$name/win6.1$suffix" ]; then - cp -r "$drv/gce/$name/win6.1$suffix" "$drv/gce/$name/win6.0$suffix" + if [ -d "$drv/gce/$part/win6.1$suffix" ]; then + cp -r "$drv/gce/$part/win6.1$suffix" "$drv/gce/$part/win6.0$suffix" fi done fi - case "$name" in + case "$part" in gvnic) [ "$arch_wim" = x86 ] && suffix=-32 || suffix= cp_drivers $drv/gce/gvnic -ipath "*/win$nt_ver$suffix/*" From c42fee9204952aa9e68da19042168f9897157732 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Wed, 26 Mar 2025 00:27:03 +0800 Subject: [PATCH 018/127] =?UTF-8?q?windows:=20=E4=BF=AE=E5=A4=8D=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E6=AD=A3=E7=A1=AE=E8=A7=A3=E6=9E=90=20UTF-16LE=20?= =?UTF-8?q?=E7=BC=96=E7=A0=81=E7=9A=84=20inf?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- windows-driver-utils.sh | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/windows-driver-utils.sh b/windows-driver-utils.sh index d2f360c..a9fc69c 100644 --- a/windows-driver-utils.sh +++ b/windows-driver-utils.sh @@ -1,16 +1,42 @@ #!/bin/ash # shellcheck shell=dash -# shellcheck disable=SC3001,SC3010 +# shellcheck disable=SC3001,SC3003,SC3010 # reinstall.sh / trans.sh 共用此文件 -# inf 是 utf-16-le 编码会有问题?要用 rg 或者 grep -a a.b.c.d ? +# grep 无法处理 UTF-16LE 编码的 inf,有以下几种解决方法 +# 1. 使用 ripgrep (rg) 或者 ugrep,但 cygwin 没有 +# 2. grep -a a.b.c.d +# 3. iconv -f UTF-16 -t UTF-8 del_inf_comment() { sed 's/;.*//' } simply_inf() { - del_cr | del_inf_comment | trim | del_empty_lines + convert_file_to_utf8 "$1" | del_cr | del_inf_comment | trim | del_empty_lines +} + +convert_file_to_utf8() { + # ash 用 * 比较字符串有问题 + # [[ $'\xEF\xBB' = $'\xEF\xBB*' ]] && echo 1 + + # UTF-16LE without BOM 要处理吗? windows 支持这种编码的 inf? + + # UTF-16LE with BOM + if [ "$(head -c2 "$1")" = $'\xFF\xFE' ]; then + # -f UTF-16LE -t UTF-8 会添加 UTF-8 BOM + iconv -f UTF-16 -t UTF-8 "$1" + + # UTF-8 with BOM + elif [ "$(head -c3 "$1")" = $'\xEF\xBB\xBF' ]; then + # busybox sed 不支持 + # sed '1s/^\xEF\xBB\xBF//' "$1" + tail -c +4 "$1" + + # 其它 + else + cat "$1" + fi } simply_inf_word() { @@ -35,7 +61,7 @@ list_files_from_inf() { local mix_x86_x86_64=$3 # 所有字段不区分大小写 - inf_txts=$(simply_inf <"$inf" | to_lower) + inf_txts=$(simply_inf "$inf" | to_lower) is_match_section() { local section=$1 From d7540ff59cbb14fee2d571ec6f686b2b0a65f345 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Wed, 26 Mar 2025 00:27:04 +0800 Subject: [PATCH 019/127] =?UTF-8?q?windows:=20=E6=9B=B4=E6=96=B0=20vmd=20?= =?UTF-8?q?=E9=A9=B1=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.en.md | 2 +- README.md | 2 +- reinstall.sh | 2 +- trans.sh | 18 ++++++++++++------ 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/README.en.md b/README.en.md index 948dd57..7a20f16 100644 --- a/README.en.md +++ b/README.en.md @@ -414,7 +414,7 @@ bash reinstall.sh windows \ [gcp-gvnic]: https://cloud.google.com/compute/docs/networking/using-gvnic [gcp-gga]: https://cloud.google.com/compute/docs/instances/enable-instance-virtual-display [azure-mana]: https://learn.microsoft.com/azure/virtual-network/accelerated-networking-mana-windows -[intel-vmd]: https://www.intel.com/content/www/us/en/download/720755/intel-rapid-storage-technology-driver-installation-software-with-intel-optane-memory-11th-up-to-13th-gen-platforms.html +[intel-vmd]: https://www.intel.com/content/www/us/en/download/849936/intel-rapid-storage-technology-driver-installation-software-with-intel-optane-memory-12th-to-15th-gen-platforms.html [intel-nic-7-sha1]: https://www.intel.com/content/www/us/en/download/15590/29323/intel-network-adapter-driver-for-windows-7-final-release.html [intel-nic-7-sha256]: https://www.intel.com/content/www/us/en/download/15590/intel-network-adapter-driver-for-windows-7-final-release.html [intel-nic-8]: https://www.intel.com/content/www/us/en/download/16765/intel-network-adapter-driver-for-windows-8-final-release.html diff --git a/README.md b/README.md index d1f0c93..2faadae 100644 --- a/README.md +++ b/README.md @@ -414,7 +414,7 @@ bash reinstall.sh windows \ [gcp-gvnic]: https://cloud.google.com/compute/docs/networking/using-gvnic [gcp-gga]: https://cloud.google.com/compute/docs/instances/enable-instance-virtual-display [azure-mana]: https://learn.microsoft.com/azure/virtual-network/accelerated-networking-mana-windows -[intel-vmd]: https://www.intel.com/content/www/us/en/download/720755/intel-rapid-storage-technology-driver-installation-software-with-intel-optane-memory-11th-up-to-13th-gen-platforms.html +[intel-vmd]: https://www.intel.com/content/www/us/en/download/849936/intel-rapid-storage-technology-driver-installation-software-with-intel-optane-memory-12th-to-15th-gen-platforms.html [intel-nic-7-sha1]: https://www.intel.com/content/www/us/en/download/15590/29323/intel-network-adapter-driver-for-windows-7-final-release.html [intel-nic-7-sha256]: https://www.intel.com/content/www/us/en/download/15590/intel-network-adapter-driver-for-windows-7-final-release.html [intel-nic-8]: https://www.intel.com/content/www/us/en/download/16765/intel-network-adapter-driver-for-windows-8-final-release.html diff --git a/reinstall.sh b/reinstall.sh index fb48c66..2a6a639 100644 --- a/reinstall.sh +++ b/reinstall.sh @@ -2164,7 +2164,7 @@ to_lower() { } del_cr() { - sed 's/\r//g' + sed 's/\r$//' } del_empty_lines() { diff --git a/trans.sh b/trans.sh index e3abdeb..7e401f5 100644 --- a/trans.sh +++ b/trans.sh @@ -776,7 +776,7 @@ to_lower() { } del_cr() { - sed 's/\r//g' + sed 's/\r$//' } del_comment_lines() { @@ -5456,10 +5456,11 @@ install_windows() { fi # vmd - # 改进: 像检测 virtio 那样直接从 /sys 检测设备 - # inf 有要求 19041 或以上 - if [ "$build_ver" -ge 19041 ] && [ "$arch_wim" = x86_64 ] && - is_lspci_contains 'Volume Management Device'; then + # RST v17 不支持 vmd + # RST v18 inf 要求 15063 或以上 + # RST v19 inf 要求 15063 或以上 + # RST v20 inf 要求 19041 或以上 + if [ -d /sys/module/vmd ] && [ "$build_ver" -ge 15063 ] && [ "$arch_wim" = x86_64 ]; then add_driver_vmd fi @@ -6049,7 +6050,12 @@ EOF add_driver_vmd() { apk add 7zip - download https://downloadmirror.intel.com/820815/SetupRST.exe $drv/SetupRST.exe + if [ "$build_ver" -ge 19041 ]; then + url=https://downloadmirror.intel.com/849939/SetupRST.exe # RST v20 + elif [ "$build_ver" -ge 15063 ]; then + url=https://downloadmirror.intel.com/849934/SetupRST.exe # RST v19 + fi + download $url $drv/SetupRST.exe 7z x $drv/SetupRST.exe -o$drv/SetupRST -i!.text 7z x $drv/SetupRST/.text -o$drv/vmd cp_drivers $drv/vmd From 2a8e760b9714cb7bc378b99837067a42b6deeba6 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Wed, 26 Mar 2025 20:50:45 +0800 Subject: [PATCH 020/127] =?UTF-8?q?core:=20initrd=20=E9=98=B6=E6=AE=B5?= =?UTF-8?q?=E7=AD=89=E5=BE=85=E7=BD=91=E5=8D=A1=E5=90=AF=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.en.md | 2 +- README.md | 2 +- initrd-network.sh | 12 +++++++++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/README.en.md b/README.en.md index 7a20f16..34e3114 100644 --- a/README.en.md +++ b/README.en.md @@ -4,7 +4,7 @@ [![Codacy](https://img.shields.io/codacy/grade/dc679a17751448628fe6d8ac35e26eed?logo=Codacy&label=Codacy&style=flat-square)](https://app.codacy.com/gh/bin456789/reinstall/dashboard) [![CodeFactor](https://img.shields.io/codefactor/grade/github/bin456789/reinstall?logo=CodeFactor&logoColor=white&label=CodeFactor&style=flat-square)](https://www.codefactor.io/repository/github/bin456789/reinstall) -[![Lines of Code](https://tokei.rs/b1/github/bin456789/reinstall?category=code&label=Lines%20of%20Code&style=flat-square)](https://github.com/XAMPPRocky/tokei) +[![Lines of Code](https://tokei.rs/b1/github/bin456789/reinstall?category=code&label=Lines%20of%20Code&style=flat-square)](https://github.com/XAMPPRocky/tokei_rs) [![Telegram Group](https://img.shields.io/badge/Telegram-2CA5E0?style=flat-square&logo=telegram&logoColor=white)](https://t.me/reinstall_os) [![Github Sponsors](https://img.shields.io/badge/sponsor-30363D?style=flat-square&logo=GitHub-Sponsors&logoColor=#EA4AAA)](https://github.com/sponsors/bin456789) diff --git a/README.md b/README.md index 2faadae..f8a4428 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ [![Codacy](https://img.shields.io/codacy/grade/dc679a17751448628fe6d8ac35e26eed?logo=Codacy&label=Codacy&style=flat-square)](https://app.codacy.com/gh/bin456789/reinstall/dashboard) [![CodeFactor](https://img.shields.io/codefactor/grade/github/bin456789/reinstall?logo=CodeFactor&logoColor=white&label=CodeFactor&style=flat-square)](https://www.codefactor.io/repository/github/bin456789/reinstall) -[![Lines of Code](https://tokei.rs/b1/github/bin456789/reinstall?category=code&label=Lines%20of%20Code&style=flat-square)](https://github.com/XAMPPRocky/tokei) +[![Lines of Code](https://tokei.rs/b1/github/bin456789/reinstall?category=code&label=Lines%20of%20Code&style=flat-square)](https://github.com/XAMPPRocky/tokei_rs) [![Telegram Group](https://img.shields.io/badge/Telegram-2CA5E0?style=flat-square&logo=telegram&logoColor=white)](https://t.me/reinstall_os) [![Github Sponsors](https://img.shields.io/badge/sponsor-30363D?style=flat-square&logo=GitHub-Sponsors&logoColor=#EA4AAA)](https://github.com/sponsors/bin456789) diff --git a/initrd-network.sh b/initrd-network.sh index f4b5a0e..54a7ae2 100644 --- a/initrd-network.sh +++ b/initrd-network.sh @@ -42,9 +42,9 @@ get_ethx() { # 2: eth0: mtu 1500 qdisc mq state UP qlen 1000\ link/ether 60:45:bd:21:8a:51 brd ff:ff:ff:ff:ff:ff # 3: eth1: mtu 1500 qdisc mq master eth0 state UP qlen 1000\ link/ether 60:45:bd:21:8a:51 brd ff:ff:ff if false; then - ip -o link | grep -i "$mac_addr" | grep -v master | awk '{print $2}' | cut -d: -f1 + ip -o link | grep -i "$mac_addr" | grep -v master | awk '{print $2}' | cut -d: -f1 | grep . else - ip -o link | grep -i "$mac_addr" | grep -v master | cut -d' ' -f2 | cut -d: -f1 + ip -o link | grep -i "$mac_addr" | grep -v master | cut -d' ' -f2 | cut -d: -f1 | grep . fi } @@ -274,7 +274,13 @@ flush_ipv6_config() { ip -6 route flush dev "$ethx" } -ethx=$(get_ethx) +for i in $(seq 20); do + if ethx=$(get_ethx); then + break + fi + sleep 1 +done + if [ -z "$ethx" ]; then echo "Not found network card: $mac_addr" exit From f0742b08e68af768e15737e2c029b1cff20bb280 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Wed, 26 Mar 2025 23:25:07 +0800 Subject: [PATCH 021/127] =?UTF-8?q?core:=20=E4=BF=AE=E5=A4=8D=20wmic=20?= =?UTF-8?q?=E6=8D=A2=E8=A1=8C=E7=AC=A6=E4=B8=8D=E6=98=AF=20\r\n=20?= =?UTF-8?q?=E8=80=8C=E6=98=AF=20\r\r\n=20=E5=AF=BC=E8=87=B4=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E6=AD=A3=E7=A1=AE=E8=A7=A3=E6=9E=90=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- reinstall.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/reinstall.sh b/reinstall.sh index 2a6a639..89fb4e5 100644 --- a/reinstall.sh +++ b/reinstall.sh @@ -2164,7 +2164,9 @@ to_lower() { } del_cr() { - sed 's/\r$//' + # wmic/reg 换行符是 \r\r\n + # wmic nicconfig where InterfaceIndex=$id get MACAddress,IPAddress,IPSubnet,DefaultIPGateway | hexdump -c + sed -E 's/\r+$//' } del_empty_lines() { From 12a3ccb2ea8170e2d6ce3080a39700e5171267d1 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Thu, 27 Mar 2025 07:46:18 +0800 Subject: [PATCH 022/127] =?UTF-8?q?ci:=20=E4=BF=AE=E5=A4=8D=E5=9C=A8=20git?= =?UTF-8?q?hub=20action=20=E4=B8=8A=E8=BF=90=E8=A1=8C=E5=87=BA=E9=94=99?= =?UTF-8?q?=E6=97=B6=E6=B2=A1=E6=9C=89=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/run_reinstall.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/run_reinstall.yml b/.github/workflows/run_reinstall.yml index 143ed6e..ee62e24 100644 --- a/.github/workflows/run_reinstall.yml +++ b/.github/workflows/run_reinstall.yml @@ -8,7 +8,6 @@ jobs: run: name: 运行主程序 strategy: - fail-fast: false matrix: os: [ubuntu-latest, windows-latest] include: From 4e48ee7964b0cb7e4a7e576d593784de86c279e8 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Thu, 27 Mar 2025 12:02:44 +0800 Subject: [PATCH 023/127] =?UTF-8?q?core:=20=E4=BF=AE=E5=A4=8D=E7=BA=AF=20i?= =?UTF-8?q?pv6=20=E4=B8=8B=E6=97=A0=E6=B3=95=E6=A3=80=E6=B5=8B=E5=9C=B0?= =?UTF-8?q?=E5=8C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- reinstall.bat | 2 +- reinstall.sh | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/reinstall.bat b/reinstall.bat index af00357..f27c12c 100644 --- a/reinstall.bat +++ b/reinstall.bat @@ -37,7 +37,7 @@ if not exist %tmp% ( rem 检查是否国内 if not exist geoip ( rem www.cloudflare.com/dash.cloudflare.com 国内访问的是美国服务器,而且部分地区被墙 - call :download http://www.visa.cn/cdn-cgi/trace %~dp0geoip || goto :download_failed + call :download http://www.qualcomm.cn/cdn-cgi/trace %~dp0geoip || goto :download_failed ) findstr /c:"loc=CN" geoip >nul if not errorlevel 1 ( diff --git a/reinstall.sh b/reinstall.sh index 89fb4e5..5841e7a 100644 --- a/reinstall.sh +++ b/reinstall.sh @@ -149,13 +149,13 @@ is_in_china() { if [ -z "$_loc" ]; then # www.cloudflare.com/dash.cloudflare.com 国内访问的是美国服务器,而且部分地区被墙 - # 备用 www.bose.cn - # 备用 www.qualcomm.cn + # 没有ipv6 www.visa.cn + # 没有ipv6 www.bose.cn + # 没有ipv6 www.garmin.com.cn # 备用 www.prologis.cn - # 备用 www.garmin.com.cn # 备用 www.autodesk.com.cn # 备用 www.keysight.com.cn - if ! _loc=$(curl -L http://www.visa.cn/cdn-cgi/trace | grep '^loc=' | cut -d= -f2 | grep .); then + if ! _loc=$(curl -L http://www.qualcomm.cn/cdn-cgi/trace | grep '^loc=' | cut -d= -f2 | grep .); then error_and_exit "Can not get location." fi echo "Location: $_loc" >&2 From 3a460f90043a9d4922b078c780290e74d5bba451 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Fri, 28 Mar 2025 00:13:22 +0800 Subject: [PATCH 024/127] =?UTF-8?q?core:=20=E5=B0=9D=E8=AF=95=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E6=98=AF=E9=9D=99=E6=80=81=20IPv6=20=EF=BC=8C?= =?UTF-8?q?=E4=BD=86=E6=98=AF=E4=BB=8E=20RA=20=E8=8E=B7=E5=8F=96=E5=88=B0?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E7=BD=91=E5=85=B3=E7=9A=84=E6=83=85=E5=86=B5?= =?UTF-8?q?=20#298?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- initrd-network.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/initrd-network.sh b/initrd-network.sh index 54a7ae2..0ba37bb 100644 --- a/initrd-network.sh +++ b/initrd-network.sh @@ -426,8 +426,10 @@ if ! $ipv4_has_internet && add_missing_ipv4_config test_internet fi +# 有可能是静态 IPv6 但能从 RA 获取到网关,因此加上 || $ra_has_gateway if ! $ipv6_has_internet && - $dhcpv6_or_slaac && [ -n "$ipv6_addr" ] && [ -n "$ipv6_gateway" ] && + { $dhcpv6_or_slaac || $ra_has_gateway; } && + [ -n "$ipv6_addr" ] && [ -n "$ipv6_gateway" ] && ! { [ "$ipv6_addr" = "$(get_first_ipv6_addr)" ] || [ "$ipv6_gateway" = "$(get_first_ipv6_gateway)" ]; }; then echo "IPv6 netmask/gateway obtained from SLAAC/DHCPv6 is different from old system." dhcpv6_or_slaac=false From 06559947e39ac3ccd46fb34d2b9bcc10abb01272 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Fri, 28 Mar 2025 13:26:28 +0800 Subject: [PATCH 025/127] =?UTF-8?q?core:=20=E4=BF=AE=E5=A4=8D=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E5=8A=A8=E9=9D=99=E6=80=81=E7=9A=84=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #298 --- initrd-network.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/initrd-network.sh b/initrd-network.sh index 0ba37bb..cce3e91 100644 --- a/initrd-network.sh +++ b/initrd-network.sh @@ -419,7 +419,7 @@ test_internet # IP 不同的情况在前面已经改成静态了 if ! $ipv4_has_internet && $dhcpv4 && [ -n "$ipv4_addr" ] && [ -n "$ipv4_gateway" ] && - ! { [ "$ipv4_addr" = "$(get_first_ipv4_addr)" ] || [ "$ipv4_gateway" = "$(get_first_ipv4_gateway)" ]; }; then + ! { [ "$ipv4_addr" = "$(get_first_ipv4_addr)" ] && [ "$ipv4_gateway" = "$(get_first_ipv4_gateway)" ]; }; then echo "IPv4 netmask/gateway obtained from DHCP is different from old system." dhcpv4=false flush_ipv4_config @@ -430,7 +430,7 @@ fi if ! $ipv6_has_internet && { $dhcpv6_or_slaac || $ra_has_gateway; } && [ -n "$ipv6_addr" ] && [ -n "$ipv6_gateway" ] && - ! { [ "$ipv6_addr" = "$(get_first_ipv6_addr)" ] || [ "$ipv6_gateway" = "$(get_first_ipv6_gateway)" ]; }; then + ! { [ "$ipv6_addr" = "$(get_first_ipv6_addr)" ] && [ "$ipv6_gateway" = "$(get_first_ipv6_gateway)" ]; }; then echo "IPv6 netmask/gateway obtained from SLAAC/DHCPv6 is different from old system." dhcpv6_or_slaac=false should_disable_accept_ra=true From b664df17e8b4aaf6f19bfcaa6db83ddaef69a34f Mon Sep 17 00:00:00 2001 From: bin456789 Date: Wed, 2 Apr 2025 19:22:49 +0800 Subject: [PATCH 026/127] =?UTF-8?q?ubuntu:=20=E4=BF=AE=E5=A4=8D=E5=88=A0?= =?UTF-8?q?=E9=99=A4=20grub-pc=20=E6=97=B6=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fixes #304 --- trans.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/trans.sh b/trans.sh index 7e401f5..22078b9 100644 --- a/trans.sh +++ b/trans.sh @@ -3870,16 +3870,21 @@ chroot_dnf() { fi } -chroot_apt_install() { +chroot_apt_update() { os_dir=$1 - shift current_hash=$(cat $os_dir/etc/apt/sources.list $os_dir/etc/apt/sources.list.d/*.sources 2>/dev/null | md5sum) if ! [ "$saved_hash" = "$current_hash" ]; then chroot $os_dir apt-get update saved_hash="$current_hash" fi +} +chroot_apt_install() { + os_dir=$1 + shift + + chroot_apt_update $os_dir DEBIAN_FRONTEND=noninteractive chroot $os_dir apt-get install -y "$@" } @@ -3887,6 +3892,10 @@ chroot_apt_remove() { os_dir=$1 shift + # minimal 镜像 删除 grub-pc 时会安装 grub-efi-amd64 + # 因此需要先更新索引 + chroot_apt_update $os_dir + # 不能用 apt remove --purge -y xxx yyy # 因为如果索引里没有其中一个,会报错,另一个也不会删除 local pkgs= From 5b5b2698e2f77be6e683a4e30f7ca4ef0386ed9e Mon Sep 17 00:00:00 2001 From: bin456789 Date: Wed, 2 Apr 2025 19:26:07 +0800 Subject: [PATCH 027/127] =?UTF-8?q?openeuler:=20=E6=B7=BB=E5=8A=A0=2025.03?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.en.md | 10 +++++----- README.md | 10 +++++----- reinstall.sh | 14 +++----------- 3 files changed, 13 insertions(+), 21 deletions(-) diff --git a/README.en.md b/README.en.md index 34e3114..1787875 100644 --- a/README.en.md +++ b/README.en.md @@ -38,10 +38,10 @@ The system requirements for the target system are as follows: | Anolis | 7, 8, 23 | 512 MB \* | 5 GB | | RHEL   AlmaLinux   Rocky   Oracle | 8, 9 | 512 MB \* | 5 GB | | OpenCloudOS | 8, 9, Stream 23 | 512 MB \* | 5 GB | -| CentOS | 9, 10 | 512 MB \* | 5 GB | +| CentOS Stream | 9, 10 | 512 MB \* | 5 GB | | Fedora | 40, 41 | 512 MB \* | 5 GB | -| openEuler | 20.03 LTS - 24.03 LTS, 24.09 | 512 MB \* | 5 GB | -| openSUSE | 15.6, Tumbleweed (Rolling) | 512 MB \* | 5 GB | +| openEuler | 20.03 LTS - 24.03 LTS, 25.03 | 512 MB \* | 5 GB | +| openSUSE | Leap 15.6, Tumbleweed (Rolling) | 512 MB \* | 5 GB | | NixOS | 24.11 | 512 MB | 5 GB | | Arch | Rolling | 512 MB | 5 GB | | Gentoo | Rolling | 512 MB | 5 GB | @@ -137,7 +137,7 @@ bash reinstall.sh anolis 7|8|23 debian 9|10|11|12 opensuse 15.6|tumbleweed alpine 3.18|3.19|3.20|3.21 - openeuler 20.03|22.03|24.03|24.09 + openeuler 20.03|22.03|24.03|25.03 ubuntu 16.04|18.04|20.04|22.04|24.04|24.10 [--minimal] kali arch @@ -465,7 +465,7 @@ Open File menu > Open Image File, select the iso to be installed to get the imag #### Considerations for Installing Windows on ARM -Most ARM machines support installing Windows 11 24H2. +Most ARM machines support installing latest Windows 11. During the installation process, you might encounter a black screen, and the serial console may display `ConvertPages: failed to find range`, but neither issue affects the installation. diff --git a/README.md b/README.md index f8a4428..3176190 100644 --- a/README.md +++ b/README.md @@ -38,10 +38,10 @@ | Anolis | 7, 8, 23 | 512 MB \* | 5 GB | | RHEL   AlmaLinux   Rocky   Oracle | 8, 9 | 512 MB \* | 5 GB | | OpenCloudOS | 8, 9, Stream 23 | 512 MB \* | 5 GB | -| CentOS | 9, 10 | 512 MB \* | 5 GB | +| CentOS Stream | 9, 10 | 512 MB \* | 5 GB | | Fedora | 40, 41 | 512 MB \* | 5 GB | -| openEuler | 20.03 LTS - 24.03 LTS, 24.09 | 512 MB \* | 5 GB | -| openSUSE | 15.6, Tumbleweed (滚动) | 512 MB \* | 5 GB | +| openEuler | 20.03 LTS - 24.03 LTS, 25.03 | 512 MB \* | 5 GB | +| openSUSE | Leap 15.6, Tumbleweed (滚动) | 512 MB \* | 5 GB | | NixOS | 24.11 | 512 MB | 5 GB | | Arch | 滚动 | 512 MB | 5 GB | | Gentoo | 滚动 | 512 MB | 5 GB | @@ -137,7 +137,7 @@ bash reinstall.sh anolis 7|8|23 debian 9|10|11|12 opensuse 15.6|tumbleweed alpine 3.18|3.19|3.20|3.21 - openeuler 20.03|22.03|24.03|24.09 + openeuler 20.03|22.03|24.03|25.03 ubuntu 16.04|18.04|20.04|22.04|24.04|24.10 [--minimal] kali arch @@ -465,7 +465,7 @@ Windows Server 2025 SERVERDATACENTER #### ARM 安装 Windows 的注意事项 -大部分 ARM 机器都支持安装 Windows 11 24H2 +大部分 ARM 机器都支持安装最新版 Windows 11 安装过程可能会黑屏,串行控制台可能会显示 `ConvertPages: failed to find range`,均不影响正常安装 diff --git a/reinstall.sh b/reinstall.sh index 5841e7a..925b181 100644 --- a/reinstall.sh +++ b/reinstall.sh @@ -57,7 +57,7 @@ Usage: $reinstall_____ anolis 7|8|23 debian 9|10|11|12 opensuse 15.6|tumbleweed alpine 3.18|3.19|3.20|3.21 - openeuler 20.03|22.03|24.03|24.09 + openeuler 20.03|22.03|24.03|25.03 ubuntu 16.04|18.04|20.04|22.04|24.04|24.10 [--minimal] kali arch @@ -1046,12 +1046,6 @@ setos() { setos_alpine() { is_virt && flavour=virt || flavour=lts - # alpine aarch64 3.16/3.17 virt 没有直连链接 - if [ "$basearch" = aarch64 ] && - { [ "$releasever" = 3.16 ] || [ "$releasever" = 3.17 ]; }; then - flavour=lts - fi - # 不要用https 因为甲骨文云arm initramfs阶段不会从硬件同步时钟,导致访问https出错 if is_in_china; then mirror=http://mirror.nju.edu.cn/alpine/v$releasever @@ -1761,7 +1755,7 @@ verify_os_name() { 'debian 9|10|11|12' \ 'opensuse 15.6|tumbleweed' \ 'alpine 3.18|3.19|3.20|3.21' \ - 'openeuler 20.03|22.03|24.03|24.09' \ + 'openeuler 20.03|22.03|24.03|25.03' \ 'ubuntu 16.04|18.04|20.04|22.04|24.04|24.10' \ 'kali' \ 'arch' \ @@ -3410,15 +3404,13 @@ EOF # grep -E -A5 'configure_ip\(\)' init # hack 4 运行 trans.start - # exec /bin/busybox switch_root $switch_root_opts $sysroot $chart_init "$KOPT_init" $KOPT_init_args # 3.17 - # exec switch_root $switch_root_opts $sysroot $chart_init "$KOPT_init" $KOPT_init_args # 3.18 # 1. alpine arm initramfs 时间问题 要添加 --no-check-certificate # 2. aws t4g arm 如果没设置console=ttyx,在initramfs里面wget https会出现bad header错误,chroot后正常 # Connecting to raw.githubusercontent.com (185.199.108.133:443) # 60C0BB2FFAFF0000:error:0A00009C:SSL routines:ssl3_get_record:http request:ssl/record/ssl3_record.c:345: # ssl_client: SSL_connect # wget: bad header line: � - insert_into_file init before '^exec (/bin/busybox )?switch_root' <\$sysroot/etc/local.d/trans.start # wget --no-check-certificate -O \$sysroot/etc/local.d/trans.start $confhome/trans.sh From d5b9c2da342068dfcc74a99cd157294602f9cbd7 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Fri, 4 Apr 2025 07:50:22 +0800 Subject: [PATCH 028/127] =?UTF-8?q?core:=20=E5=9B=BD=E5=86=85=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=20cnb=20=E4=BB=93=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/sync_to_cnb.yml | 18 ++++++++++++++++++ README.en.md | 4 ++-- README.md | 4 ++-- reinstall.bat | 2 +- reinstall.sh | 2 +- 5 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/sync_to_cnb.yml diff --git a/.github/workflows/sync_to_cnb.yml b/.github/workflows/sync_to_cnb.yml new file mode 100644 index 0000000..1369e4c --- /dev/null +++ b/.github/workflows/sync_to_cnb.yml @@ -0,0 +1,18 @@ +name: 同步到 CNB +on: + workflow_dispatch: + push: +jobs: + run: + name: 同步到 CNB + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: yesolutions/mirror-action@master + with: + REMOTE: https://cnb.cool/bin456789/reinstall.git + GIT_USERNAME: cnb + GIT_PASSWORD: ${{ secrets.CNB_TOKEN }} + PUSH_ALL_REFS: false diff --git a/README.en.md b/README.en.md index 1787875..5eb02bb 100644 --- a/README.en.md +++ b/README.en.md @@ -71,7 +71,7 @@ curl -O https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.sh For server inside China: ```bash -curl -O https://gitlab.com/bin456789/reinstall/-/raw/main/reinstall.sh || wget -O reinstall.sh $_ +curl -O https://cnb.cool/bin456789/reinstall/-/git/raw/main/reinstall.sh || wget -O reinstall.sh $_ ``` ## Download (Current system is Windows) @@ -104,7 +104,7 @@ certutil -urlcache -f -split https://raw.githubusercontent.com/bin456789/reinsta For server inside China: ```batch -certutil -urlcache -f -split https://gitlab.com/bin456789/reinstall/-/raw/main/reinstall.bat +certutil -urlcache -f -split https://cnb.cool/bin456789/reinstall/-/git/raw/main/reinstall.bat ``` ## Usage diff --git a/README.md b/README.md index 3176190..c9e84c8 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ curl -O https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.sh 国内服务器: ```bash -curl -O https://gitlab.com/bin456789/reinstall/-/raw/main/reinstall.sh || wget -O reinstall.sh $_ +curl -O https://cnb.cool/bin456789/reinstall/-/git/raw/main/reinstall.sh || wget -O reinstall.sh $_ ``` ## 下载(当前系统是 Windows) @@ -104,7 +104,7 @@ certutil -urlcache -f -split https://raw.githubusercontent.com/bin456789/reinsta 国内服务器: ```batch -certutil -urlcache -f -split https://gitlab.com/bin456789/reinstall/-/raw/main/reinstall.bat +certutil -urlcache -f -split https://cnb.cool/bin456789/reinstall/-/git/raw/main/reinstall.bat ``` ## 使用 diff --git a/reinstall.bat b/reinstall.bat index f27c12c..40a346b 100644 --- a/reinstall.bat +++ b/reinstall.bat @@ -3,7 +3,7 @@ mode con cp select=437 >nul setlocal EnableDelayedExpansion set confhome=https://raw.githubusercontent.com/bin456789/reinstall/main -set confhome_cn=https://gitlab.com/bin456789/reinstall/-/raw/main +set confhome_cn=https://cnb.cool/bin456789/reinstall/-/git/raw/main rem set confhome_cn=https://www.ghproxy.cc/https://raw.githubusercontent.com/bin456789/reinstall/main set pkgs=curl,cpio,p7zip,dos2unix,jq,xz,gzip,zstd,openssl,bind-utils,libiconv,binutils diff --git a/reinstall.sh b/reinstall.sh index 925b181..8c1b748 100644 --- a/reinstall.sh +++ b/reinstall.sh @@ -4,7 +4,7 @@ set -eE confhome=https://raw.githubusercontent.com/bin456789/reinstall/main -confhome_cn=https://gitlab.com/bin456789/reinstall/-/raw/main +confhome_cn=https://cnb.cool/bin456789/reinstall/-/git/raw/main # confhome_cn=https://www.ghproxy.cc/https://raw.githubusercontent.com/bin456789/reinstall/main # 默认密码 From b84fd9e8753a70c9a506c45859c2e971930b0d39 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Fri, 4 Apr 2025 08:24:20 +0800 Subject: [PATCH 029/127] =?UTF-8?q?tmp:=20=E5=88=A0=E9=99=A4=20Gitlab=20CN?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/sync_to_gitlabcn.yml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/sync_to_gitlabcn.yml b/.github/workflows/sync_to_gitlabcn.yml index 3f05944..595338e 100644 --- a/.github/workflows/sync_to_gitlabcn.yml +++ b/.github/workflows/sync_to_gitlabcn.yml @@ -1,15 +1,21 @@ -name: 同步到 Gitlab CN +name: 删除 Gitlab CN on: workflow_dispatch: push: jobs: run: - name: 同步到 Gitlab CN + name: 删除 Gitlab CN runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 + - run: | + rm -rf * + git config --global user.email "you@example.com" + git config --global user.name "Your Name" + git init . + git add . + git branch -m main + git commit -m "null" --allow-empty + - uses: yesolutions/mirror-action@master with: REMOTE: https://jihulab.com/bin456789/reinstall.git From 4105a0bb4182b7c85866fa5d21bf270080543f50 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Fri, 4 Apr 2025 08:50:02 +0800 Subject: [PATCH 030/127] =?UTF-8?q?core:=20=E5=88=A0=E9=99=A4=20Gitlab=20/?= =?UTF-8?q?=20Gitlab=20CN?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/sync_to_gitlab.yml | 18 ------------------ .github/workflows/sync_to_gitlabcn.yml | 24 ------------------------ 2 files changed, 42 deletions(-) delete mode 100644 .github/workflows/sync_to_gitlab.yml delete mode 100644 .github/workflows/sync_to_gitlabcn.yml diff --git a/.github/workflows/sync_to_gitlab.yml b/.github/workflows/sync_to_gitlab.yml deleted file mode 100644 index eb35139..0000000 --- a/.github/workflows/sync_to_gitlab.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: 同步到 Gitlab -on: - workflow_dispatch: - push: -jobs: - run: - name: 同步到 Gitlab - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - uses: yesolutions/mirror-action@master - with: - REMOTE: https://gitlab.com/bin456789/reinstall.git - GIT_USERNAME: username - GIT_PASSWORD: ${{ secrets.GITLAB_TOKEN }} - PUSH_ALL_REFS: false diff --git a/.github/workflows/sync_to_gitlabcn.yml b/.github/workflows/sync_to_gitlabcn.yml deleted file mode 100644 index 595338e..0000000 --- a/.github/workflows/sync_to_gitlabcn.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: 删除 Gitlab CN -on: - workflow_dispatch: - push: -jobs: - run: - name: 删除 Gitlab CN - runs-on: ubuntu-latest - steps: - - run: | - rm -rf * - git config --global user.email "you@example.com" - git config --global user.name "Your Name" - git init . - git add . - git branch -m main - git commit -m "null" --allow-empty - - - uses: yesolutions/mirror-action@master - with: - REMOTE: https://jihulab.com/bin456789/reinstall.git - GIT_USERNAME: username - GIT_PASSWORD: ${{ secrets.JIHULAB_TOKEN }} - PUSH_ALL_REFS: false From bd266fb12f058535d237d1b56461e9030ebb2b76 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Fri, 4 Apr 2025 08:50:02 +0800 Subject: [PATCH 031/127] =?UTF-8?q?windows:=20=E8=AE=BE=E7=BD=AE=E6=88=90?= =?UTF-8?q?=E9=AB=98=E6=80=A7=E8=83=BD=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- windows-setup.bat | 2 +- windows.xml | 21 ++++++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/windows-setup.bat b/windows-setup.bat index f001b4f..1789490 100644 --- a/windows-setup.bat +++ b/windows-setup.bat @@ -19,7 +19,7 @@ rem echo a | find "a" rem 使用高性能模式 rem https://learn.microsoft.com/windows-hardware/manufacture/desktop/capture-and-apply-windows-using-a-single-wim rem win8 pe 没有 powercfg -call powercfg /s 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c 2>nul +powercfg /s SCHEME_MIN 2>nul rem 安装 SCSI 驱动 if exist X:\drivers\ ( diff --git a/windows.xml b/windows.xml index cfc2754..c6faada 100644 --- a/windows.xml +++ b/windows.xml @@ -64,24 +64,31 @@ - + https://support.huaweicloud.com/usermanual-ims/zh-cn_topic_0047501112.html + powercfg /aliases 能显示 GUID/名称 的对应关系,vista 也能使用名称 --> 1 - powercfg /setacvalueindex 381b4222-f694-41f0-9685-ff5bb260df2e 7516b95f-f776-4464-8c53-06167f40cc99 3c0bc021-c8a8-4e07-a973-6b14cbcb2b7e 0 + powercfg /setacvalueindex SCHEME_BALANCED SUB_VIDEO VIDEOIDLE 0 2 - powercfg /setacvalueindex 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c 7516b95f-f776-4464-8c53-06167f40cc99 3c0bc021-c8a8-4e07-a973-6b14cbcb2b7e 0 + powercfg /setacvalueindex SCHEME_MIN SUB_VIDEO VIDEOIDLE 0 3 - powercfg /setacvalueindex a1841308-3541-4fab-bc81-f71556f20b4a 7516b95f-f776-4464-8c53-06167f40cc99 3c0bc021-c8a8-4e07-a973-6b14cbcb2b7e 0 + powercfg /setacvalueindex SCHEME_MAX SUB_VIDEO VIDEOIDLE 0 + + + + 4 + powercfg /setactive SCHEME_MIN - 4 + 5 @@ -91,7 +98,7 @@ - 5 + 6 reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\ReserveManager /v ShippedWithReserves /t REG_DWORD /d 0 /f From aaf6ad7c8334464c7ec04cfb9ec52cd4f0057805 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Thu, 10 Apr 2025 23:38:36 +0800 Subject: [PATCH 032/127] =?UTF-8?q?opensuse:=20=E6=B7=BB=E5=8A=A0=2016.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- reinstall.sh | 29 ++++++++++++--- trans.sh | 103 ++++++++++++++++++++++++++++++++++----------------- 2 files changed, 93 insertions(+), 39 deletions(-) diff --git a/reinstall.sh b/reinstall.sh index 8c1b748..d32a4ee 100644 --- a/reinstall.sh +++ b/reinstall.sh @@ -1363,12 +1363,29 @@ Continue? fi file=openSUSE-Tumbleweed-Minimal-VM.$basearch-Cloud.qcow2 else - # 常规版本 + # leap dir=distribution/leap/$releasever/appliances - file=openSUSE-Leap-$releasever-Minimal-VM.$basearch-Cloud.qcow2 - fi + if [ "$releasever" = 15.6 ]; then + file=openSUSE-Leap-$releasever-Minimal-VM.$basearch-Cloud.qcow2 + # https://build.opensuse.org/projects/Virtualization:Appliances:Images:openSUSE-Leap-15.6/packages/kiwi-templates-Minimal/files/Minimal.kiwi + # https://build.opensuse.org/projects/Virtualization:Appliances:Images:openSUSE-Tumbleweed/packages/kiwi-templates-Minimal/files/Minimal.kiwi + # 有专门的kvm镜像,openSUSE-Leap-15.5-Minimal-VM.x86_64-kvm-and-xen.qcow2,里面没有cloud-init + # file=openSUSE-Leap-15.5-Minimal-VM.x86_64-kvm-and-xen.qcow2 + else + # https://src.opensuse.org/openSUSE/Leap/raw/branch/16.0/Leap/Leap.kiwi + # Default 比 Base 多了以下组件 + # + # + # + # + # + # + # - # 有专门的kvm镜像,openSUSE-Leap-15.5-Minimal-VM.x86_64-kvm-and-xen.qcow2,但里面没有cloud-init + # file=Leap.x86_64-Default.raw.xz + file=Leap.x86_64-Base.raw.xz + fi + fi eval ${step}_img=$mirror/$dir/$file } @@ -1713,7 +1730,7 @@ Continue with DD? # 集中测试云镜像格式 if is_use_cloud_image && [ "$step" = finalos ]; then # shellcheck disable=SC2154 - test_url $finalos_img 'qemu qemu.gzip qemu.xz qemu.zstd' finalos_img_type + test_url $finalos_img 'qemu qemu.gzip qemu.xz qemu.zstd raw.xz' finalos_img_type fi } @@ -1753,7 +1770,7 @@ verify_os_name() { 'fedora 40|41' \ 'nixos 24.11' \ 'debian 9|10|11|12' \ - 'opensuse 15.6|tumbleweed' \ + 'opensuse 15.6|16.0|tumbleweed' \ 'alpine 3.18|3.19|3.20|3.21' \ 'openeuler 20.03|22.03|24.03|25.03' \ 'ubuntu 16.04|18.04|20.04|22.04|24.04|24.10' \ diff --git a/trans.sh b/trans.sh index 22078b9..229d038 100644 --- a/trans.sh +++ b/trans.sh @@ -3152,7 +3152,8 @@ EOF remove_cloud_init $os_dir - disable_selinux_kdump $os_dir + disable_selinux $os_dir + disable_kdump $os_dir if fw_pkgs=$(get_ucode_firmware_pkgs) && [ -n "$fw_pkgs" ]; then is_have_cmd_on_disk $os_dir dnf && mgr=dnf || mgr=yum @@ -3344,9 +3345,17 @@ EOF disable_jeos_firstboot $os_dir - # opensuse leap - if grep opensuse-leap $os_dir/etc/os-release; then + # 16.0 需要安装 openssh + if ! chroot $os_dir rpm -qi openssh-server; then + chroot $os_dir zypper install -y openssh-server + fi + # 禁用 selinux + disable_selinux $os_dir + + # opensuse leap 15.6 用 wicked + # opensuse leap 16.0 / tumbleweed 用 NetworkManager + if chroot $os_dir rpm -qi wicked; then # sysconfig ifcfg create_cloud_init_network_config $os_dir/net.cfg chroot $os_dir cloud-init devel net-convert \ @@ -3388,11 +3397,8 @@ EOF # 清理 rm -rf $os_dir/net.cfg $os_dir/out - fi - # opensuse tumbleweed - # network-manager - if grep opensuse-tumbleweed $os_dir/etc/os-release; then + else # 如果使用 cloud-init 则需要 touch NetworkManager.conf # 更新到 cloud-init 24.1 后删除 # touch $os_dir/etc/NetworkManager/NetworkManager.conf @@ -3403,34 +3409,45 @@ EOF rm /net.cfg fi + # 选择新内核 + # 只有 leap 有 kernel-azure + if grep -iq leap $os_dir/etc/os-release && [ "$(get_cloud_vendor)" = azure ]; then + target_kernel='kernel-azure' + else + target_kernel='kernel-default' + fi + + # rpm -qi 不支持通配符 + installed_kernel=$(chroot $os_dir rpm -qa 'kernel-*' --qf '%{NAME}\n' | grep -v firmware) + if ! [ "$(echo "$installed_kernel" | wc -l)" -eq 1 ]; then + error_and_exit "Unexpected kernel installed: $installed_kernel" + fi + + # 15.6 / tumbleweed 自带的是 kernel-default-base + # 16.0 自带的是 kernel-default # 不能同时装 kernel-default-base 和 kernel-default - chroot $os_dir zypper remove -y -u kernel-default-base + + if ! [ "$installed_kernel" = "$target_kernel" ]; then + chroot $os_dir zypper remove -y -u $installed_kernel + + # x86 必须设置一个密码,否则报错,arm 没有这个问题 + # Failed to get root password hash + # Failed to import /etc/uefi/certs/76B6A6A0.crt + # warning: %post(kernel-default-5.14.21-150500.55.83.1.x86_64) scriptlet failed, exit status 255 + if grep -q '^root:[:!*]' $os_dir/etc/shadow; then + echo "root:$(mkpasswd '')" | chroot $os_dir chpasswd -e + chroot $os_dir zypper install -y $target_kernel + chroot $os_dir passwd -d root + else + chroot $os_dir zypper install -y $target_kernel + fi + fi # 固件+微码 if fw_pkgs=$(get_ucode_firmware_pkgs) && [ -n "$fw_pkgs" ]; then chroot $os_dir zypper install -y $fw_pkgs fi - # 选择新内核 - # 只有 leap 有 kernel-azure - if grep -q opensuse-leap $os_dir/etc/os-release && [ "$(get_cloud_vendor)" = azure ]; then - kernel='kernel-azure' - else - kernel='kernel-default' - fi - - # x86 必须设置一个密码,否则报错,arm 没有这个问题 - # Failed to get root password hash - # Failed to import /etc/uefi/certs/76B6A6A0.crt - # warning: %post(kernel-default-5.14.21-150500.55.83.1.x86_64) scriptlet failed, exit status 255 - if grep -q '^root:[:!*]' $os_dir/etc/shadow; then - echo "root:$(mkpasswd '')" | chroot $os_dir chpasswd -e - chroot $os_dir zypper install -y $kernel - chroot $os_dir passwd -d root - else - chroot $os_dir zypper install -y $kernel - fi - # 最后才删除 cloud-init # 因为生成 sysconfig 网络配置要用目标系统的 cloud-init remove_cloud_init $os_dir @@ -3707,10 +3724,9 @@ change_root_password() { fi } -disable_selinux_kdump() { +disable_selinux() { os_dir=$1 - # selinux # https://access.redhat.com/solutions/3176 # centos7 也建议将 selinux 开关写在 cmdline # grep selinux=0 /usr/lib/dracut/modules.d/98selinux/selinux-loadpolicy.sh @@ -3718,9 +3734,28 @@ disable_selinux_kdump() { if [ -f $os_dir/etc/selinux/config ]; then sed -i 's/^SELINUX=enforcing/SELINUX=disabled/g' $os_dir/etc/selinux/config fi - chroot $os_dir grubby --update-kernel ALL --args selinux=0 - # kdump + # opensuse 没有安装 grubby + if is_have_cmd_on_disk $os_dir grubby; then + # grubby 只处理 GRUB_CMDLINE_LINUX,不会处理 GRUB_CMDLINE_LINUX_DEFAULT + # rocky 的 GRUB_CMDLINE_LINUX_DEFAULT 有 crashkernel=auto + chroot $os_dir grubby --update-kernel ALL --args selinux=0 + + # el7 上面那条 grubby 命令不能设置 /etc/default/grub + sed -i 's/selinux=1/selinux=0/' $os_dir/etc/default/grub + else + # 有可能没有 selinux 参数,但现在的镜像没有这个问题 + # sed -Ei 's/[[:space:]]?(security|selinux|enforcing)=[^ ]*//g' $os_dir/etc/default/grub + sed -i 's/selinux=1/selinux=0/' $os_dir/etc/default/grub + + # 如果需要用 snapshot 可以用 transactional-update grub.cfg + chroot $os_dir grub2-mkconfig -o /boot/grub2/grub.cfg + fi +} + +disable_kdump() { + os_dir=$1 + # grubby 只处理 GRUB_CMDLINE_LINUX,不会处理 GRUB_CMDLINE_LINUX_DEFAULT # rocky 的 GRUB_CMDLINE_LINUX_DEFAULT 有 crashkernel=auto @@ -4111,7 +4146,8 @@ install_qcow_by_copy() { del_default_user /os # selinux kdump - disable_selinux_kdump /os + disable_selinux /os + disable_kdump /os # el7 删除 machine-id 后不会自动重建 clear_machine_id /os @@ -4877,6 +4913,7 @@ fix_gpt_backup_partition_table_by_sgdisk() { # 适用于 DD 后修复 gpt 备份分区表 fix_gpt_backup_partition_table_by_parted() { + apk add parted parted /dev/$xda -f -s print update_part } From afb958a60c14bc22f39c1aa2dd1dcb477e403077 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Thu, 10 Apr 2025 23:49:08 +0800 Subject: [PATCH 033/127] =?UTF-8?q?core:=20=E4=BF=AE=E5=A4=8D=20resolv.con?= =?UTF-8?q?f=20=E5=8C=85=E5=90=AB=20%eth0=20=E6=97=B6=EF=BC=8C=E7=94=9F?= =?UTF-8?q?=E6=88=90=E7=BD=91=E7=BB=9C=E9=85=8D=E7=BD=AE=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fixes #310 --- trans.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/trans.sh b/trans.sh index 229d038..f9a79f2 100644 --- a/trans.sh +++ b/trans.sh @@ -761,9 +761,9 @@ get_current_dns() { # debian 11 initrd 没有 xargs awk # debian 12 initrd 没有 xargs if false; then - grep '^nameserver' /etc/resolv.conf | awk '{print $2}' | grep -F "$mark" + grep '^nameserver' /etc/resolv.conf | awk '{print $2}' | grep -F "$mark" | cut -d '%' -f1 else - grep '^nameserver' /etc/resolv.conf | cut -d' ' -f2 | grep -F "$mark" + grep '^nameserver' /etc/resolv.conf | cut -d' ' -f2 | grep -F "$mark" | cut -d '%' -f1 fi } From fde78de2f799834b742d23fb45acf36f186d3f37 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Sat, 12 Apr 2025 15:44:20 +0800 Subject: [PATCH 034/127] =?UTF-8?q?core:=20=E4=BF=AE=E5=A4=8D=E7=BA=AF=20I?= =?UTF-8?q?Pv6=20=E6=97=A0=E6=B3=95=E4=B8=8B=E8=BD=BD=E9=83=A8=E5=88=86?= =?UTF-8?q?=E6=96=87=E4=BB=B6=20#317?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit dl.fedoraproject.org 不支持 IPv6 --- reinstall.sh | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/reinstall.sh b/reinstall.sh index d32a4ee..7566077 100644 --- a/reinstall.sh +++ b/reinstall.sh @@ -1249,7 +1249,7 @@ Continue? fi # iso - filename=$(curl -L $mirror | grep -oP "ubuntu-$releasever.*?-live-server-$basearch_alt.iso" | + filename=$(curl -L $mirror/ | grep -oP "ubuntu-$releasever.*?-live-server-$basearch_alt.iso" | sort -uV | tail -1 | grep .) iso=$mirror/$filename # 在 ubuntu 20.04 上,file 命令检测 ubuntu 22.04 iso 结果是 DOS/MBR boot sector @@ -1559,7 +1559,7 @@ Continue with DD? centos) ci_mirror="https://cloud.centos.org/centos" ;; almalinux) ci_mirror="https://repo.almalinux.org/almalinux/$releasever/cloud/$basearch/images" ;; rocky) ci_mirror="https://download.rockylinux.org/pub/rocky/$releasever/images/$basearch" ;; - fedora) ci_mirror="https://dl.fedoraproject.org/pub/fedora/linux/releases/$releasever/Cloud/$basearch/images" ;; + fedora) ci_mirror="https://d2lzkl7pfhq30w.cloudfront.net/pub/fedora/linux/releases/$releasever/Cloud/$basearch/images" ;; esac fi case $distro in @@ -1583,7 +1583,10 @@ Continue with DD? almalinux) ci_image=$ci_mirror/AlmaLinux-$releasever-GenericCloud-latest.$basearch.qcow2 ;; rocky) ci_image=$ci_mirror/Rocky-$releasever-GenericCloud-Base.latest.$basearch.qcow2 ;; fedora) - filename=$(curl -L $ci_mirror | grep -oP "Fedora-Cloud-Base-Generic.*?.qcow2" | + # 不加 / 会跳转到 https://dl.fedoraproject.org,纯 ipv6 无法访问 + # curl -L -6 https://d2lzkl7pfhq30w.cloudfront.net/pub/fedora/linux/releases/41/Cloud/x86_64/images + # curl -L -6 https://d2lzkl7pfhq30w.cloudfront.net/pub/fedora/linux/releases/41/Cloud/x86_64/images/ + filename=$(curl -L $ci_mirror/ | grep -oP "Fedora-Cloud-Base-Generic.*?.qcow2" | sort -uV | tail -1 | grep .) ci_image=$ci_mirror/$filename ;; @@ -1752,6 +1755,11 @@ is_distro_like_debian() { [ "$_distro" = debian ] || [ "$_distro" = kali ] } +get_latest_distro_releasever() { + get_function_content verify_os_name | + grep -wo "$1 [^'\"]*" | awk -F'|' '{print $NF}' +} + # 检查是否为正确的系统名 verify_os_name() { if [ -z "$*" ]; then @@ -2670,13 +2678,16 @@ install_grub_linux_efi() { # fcix 经常 404 # https://mirror.fcix.net/opensuse/tumbleweed/repo/oss/EFI/BOOT/bootx64.efi # https://mirror.fcix.net/opensuse/tumbleweed/appliances/openSUSE-Tumbleweed-Minimal-VM.x86_64-Cloud.qcow2 + + # dl.fedoraproject.org 不支持 ipv6 + if [ "$efi_distro" = fedora ]; then - fedora_ver=41 + fedora_ver=$(get_latest_distro_releasever fedora) if is_in_china; then mirror=https://mirror.nju.edu.cn/fedora else - mirror=https://dl.fedoraproject.org/pub/fedora/linux + mirror=https://d2lzkl7pfhq30w.cloudfront.net/pub/fedora/linux fi curl -Lo $tmp/$grub_efi $mirror/releases/$fedora_ver/Everything/$basearch/os/EFI/BOOT/$grub_efi @@ -4015,8 +4026,7 @@ if is_netboot_xyz || setos nextos $distro $releasever else # alpine 作为中间系统时,使用最新版 - alpine_ver_for_trans=$(get_function_content verify_os_name | - grep -o 'alpine[ 0-9\.\|]*' | awk -F'|' '{print $NF}') + alpine_ver_for_trans=$(get_latest_distro_releasever alpine) setos finalos $distro $releasever setos nextos alpine $alpine_ver_for_trans fi From 6b35479515a0becfbb2511aae33165e63bdf0a37 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Sat, 12 Apr 2025 22:20:18 +0800 Subject: [PATCH 035/127] =?UTF-8?q?windows:=20=E4=BF=AE=E5=A4=8D=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E5=9C=B0=E6=8E=92=E9=99=A4=E4=BA=86=20win11=20intel?= =?UTF-8?q?=20nic=20=E9=A9=B1=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- trans.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/trans.sh b/trans.sh index f9a79f2..dac1462 100644 --- a/trans.sh +++ b/trans.sh @@ -5600,8 +5600,8 @@ install_windows() { 26100 WS2025 EOF case "$windows_type" in - client) grep -E 'NDIS|^WS' ;; - server) grep -E 'NDIS|WS' ;; + client) grep -E ' (NDIS|W)[0-9]' ;; + server) grep -E ' (NDIS|WS)[0-9]' ;; esac) for ethx in $(get_eths); do From 0b2eed1750c79249414aac5e68bafd8c4d088447 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Tue, 15 Apr 2025 17:30:35 +0800 Subject: [PATCH 036/127] =?UTF-8?q?core:=20=E4=BF=AE=E5=A4=8D=20cygwin=20?= =?UTF-8?q?=E4=B8=8B=E6=97=A0=E6=B3=95=E8=8E=B7=E5=BE=97=E5=86=85=E5=AD=98?= =?UTF-8?q?=E5=A4=A7=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit cygwin 要装 procps-ng 才有 free 命令 --- reinstall.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/reinstall.sh b/reinstall.sh index 7566077..1b51a9f 100644 --- a/reinstall.sh +++ b/reinstall.sh @@ -2093,9 +2093,10 @@ check_ram() { fi # 用于兜底,不太准确 + # cygwin 要装 procps-ng 才有 free 命令 if [ -z $ram_size ]; then - ram_size=$(free -m | grep ^Mem: | awk '{print $2}') - ram_size=$((ram_size + 64 + 4)) + ram_size_k=$(grep '^MemTotal:' /proc/meminfo | awk '{print $2}') + ram_size=$((ram_size_k / 1024 + 64 + 4)) fi if [ -z $ram_size ] || [ $ram_size -le 0 ]; then From 71ad989672d407554220ee158e83274424283c52 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Tue, 15 Apr 2025 23:40:58 +0800 Subject: [PATCH 037/127] =?UTF-8?q?windows:=20=E5=88=A4=E6=96=AD=20win7=20?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E6=94=AF=E6=8C=81=20sha256=20=E9=A9=B1?= =?UTF-8?q?=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复 Image Name 为空时报错,例如 7601.24214.180801-1700.win7sp1_ldr_escrow_CLIENT_ULTIMATE_x64FRE_en-us.iso --- trans.sh | 198 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 114 insertions(+), 84 deletions(-) diff --git a/trans.sh b/trans.sh index dac1462..3c40319 100644 --- a/trans.sh +++ b/trans.sh @@ -704,26 +704,27 @@ is_have_rdnss() { [ -n "$rdnss" ] } +# dd 完检测到镜像是 windows 时会改写此方法 is_windows() { - for dir in /os /wim; do - [ -d $dir/Windows/System32 ] && return 0 - done - return 1 + [ "$distro" = windows ] } # 15063 或之后才支持 rdnss is_windows_support_rdnss() { + [ "$build_ver" -ge 15063 ] +} + +get_windows_version_from_dll() { + local dll=$1 + [ -f "$dll" ] || error_and_exit "File not found: $dll" + apk add pev - for dir in /os /wim; do - dll=$dir/Windows/System32/kernel32.dll - if [ -f $dll ]; then - build_ver="$(peres -v $dll | grep 'Product Version:' | cut -d. -f3)" - echo "Windows Build Version: $build_ver" - apk del pev - [ "$build_ver" -ge 15063 ] && return 0 || return 1 - fi - done - error_and_exit "Not found kernel32.dll" + local ver + ver="$(peres -v "$dll" | grep 'Product Version:' | awk '{print $NF}')" + echo "Version: $ver" >&2 + IFS=. read -r nt_ver_major nt_ver_minor build_ver rev_ver _ < <(echo "$ver") + nt_ver="$nt_ver_major.$nt_ver_minor" + apk del pev } is_elts() { @@ -2781,9 +2782,15 @@ modify_windows() { # https://learn.microsoft.com/windows-hardware/manufacture/desktop/add-a-custom-script-to-windows-setup # 判断用 SetupComplete 还是组策略 - state_ini=$os_dir/Windows/Setup/State/State.ini - cat $state_ini - if grep -q IMAGE_STATE_COMPLETE $state_ini; then + # 默认视为 IMAGE_STATE_COMPLETE,除非有 State.ini,因为 dd 镜像可能精简了 State.ini + # 但最好还是从注册表获取 + image_state=IMAGE_STATE_COMPLETE + if state_ini=$(find_file_ignore_case $os_dir/Windows/Setup/State/State.ini); then + cat -n $state_ini + image_state=$(grep -i '^ImageState=' $state_ini | cut -d= -f2 | tr -d '\r') + fi + + if [ "$image_state" = IMAGE_STATE_COMPLETE ]; then use_gpo=true else use_gpo=false @@ -3556,8 +3563,12 @@ modify_os_on_disk() { # find /mnt/c -iname windows -type d -maxdepth 1 # find: /mnt/c/pagefile.sys: Permission denied # find: /mnt/c/swapfile.sys: Permission denied - # shellcheck disable=SC2010 - if ls -d /os/*/ | grep -i '/windows/' 2>/dev/null; then + # shellcheck disable=SC1090 + # find_file_ignore_case 也在这个文件里面 + . <(wget -O- $confhome/windows-driver-utils.sh) + if ntoskrnl_exe=$(find_file_ignore_case /os/Windows/System32/ntoskrnl.exe 2>/dev/null); then + # 其他地方会用到 + is_windows() { true; } # 重新挂载为读写、忽略大小写 umount /os mount -t ntfs3 -o nocase /dev/$part /os @@ -3565,6 +3576,8 @@ modify_os_on_disk() { if mount | grep ' /os ' | grep -wq ro; then error_and_exit "Can't mount windows partition /dev/$part as rw." fi + # 获取版本号,其他地方会用到 + get_windows_version_from_dll "$ntoskrnl_exe" modify_windows /os return fi @@ -4846,6 +4859,7 @@ dd_qcow() { # 将前1M从内存 dd 到硬盘 umount /installer/ dd if=/first-1M of=/dev/$xda + rm -f /first-1M # gpt 分区表开头记录了备份分区表的位置 # 如果 qcow2 虚拟容量 大于 实际硬盘容量 @@ -5148,7 +5162,7 @@ get_server_name_by_build_ver() { echo 2012 elif [ "$build_ver" -ge 7600 ]; then echo 2008 r2 - elif [ "$build_ver" -ge 6000 ]; then + elif [ "$build_ver" -ge 6001 ]; then echo 2008 else error_and_exit "Unknown Build Version: $build_ver" @@ -5230,11 +5244,15 @@ install_windows() { } info "Process windows iso" + mkdir -p /iso /wim + + # find_file_ignore_case 也在这个文件里面 + # shellcheck disable=SC1090 + . <(wget -O- $confhome/windows-driver-utils.sh) apk add wimlib download $iso /os/windows.iso - mkdir -p /iso mount -o ro /os/windows.iso /iso # 防止用了不兼容架构的 iso @@ -5272,12 +5290,14 @@ install_windows() { if [ "$image_count" = 1 ]; then # 只有一个版本就用那个版本 image_name=$all_image_names + image_index=1 else while true; do # 匹配成功 # 改成正确的大小写 if matched_image_name=$(echo "$all_image_names" | grep -ix "$image_name"); then image_name=$matched_image_name + image_index=$(wiminfo "$iso_install_wim" "$image_name" | grep 'Index:' | awk '{print $NF}') break fi @@ -5298,7 +5318,7 @@ install_windows() { fi get_selected_image_prop() { - get_image_prop "$iso_install_wim" "$image_name" "$1" + get_image_prop "$iso_install_wim" "$image_index" "$1" } # 多会话的信息来自注册表,因为没有官方 iso @@ -5344,12 +5364,45 @@ install_windows() { ;; esac + # 挂载 install.wim,检查 + # 1. 是否自带 sac 组件 + # 2. 是否自带 nvme 驱动 + # 3. 是否支持 sha256 + + wimmount "$iso_install_wim" "$image_index" /wim/ + { + find_file_ignore_case /wim/Windows/System32/sacsess.exe && has_sac=true || has_sac=false + find_file_ignore_case /wim/Windows/INF/stornvme.inf && has_stornvme=true || has_stornvme=false + } >/dev/null 2>&1 + + support_sha256=false + if is_nt_ver_ge 6.2; then + support_sha256=true + else + # https://www.hummingheads.co.jp/press/info-certificates.html + # https://support.microsoft.com/kb/KB3033929 + # https://support.microsoft.com/kb/KB4474419 + # Windows Vista SP2 ldr_escrow 6.0.6003 + KB4474419 + # Windows 7 SP1 6.1.7601 + KB3033929 + ntoskrnl_exe=$(find_file_ignore_case /wim/Windows/System32/ntoskrnl.exe) + get_windows_version_from_dll "$ntoskrnl_exe" + if { [ "$nt_ver" = 6.0 ] && [ "$build_ver" -ge 6003 ] && [ "$rev_ver" -ge 20555 ]; } || + { [ "$nt_ver" = 6.1 ] && [ "$build_ver" -ge 7601 ] && [ "$rev_ver" -ge 18741 ]; }; then + support_sha256=true + fi + fi + wimunmount /wim/ + info "Selected image info" echo "Image Name: $image_name" echo "Product Version: $product_ver" echo "Windows Type: $windows_type" echo "NT Version: $nt_ver" echo "Build Version: $build_ver" + echo "-------------------------" + echo "Has SAC: $has_sac" + echo "Has StorNVMe: $has_stornvme" + echo "Support SHA256: $support_sha256" echo # 复制 boot.wim 到 /os,用于临时编辑 @@ -5401,7 +5454,7 @@ install_windows() { # (意义不大,因为已经删除了 boot.wim 用来创建虚拟内存,vista 除外) # 缺点: 如果 install.wim 只有一个镜像,则只能缩小 10M+ if false; then - time wimexport --threads "$(get_build_threads 512)" "$iso_install_wim" "$image_name" "$install_wim" + time wimexport --threads "$(get_build_threads 512)" "$iso_install_wim" "$image_index" "$install_wim" info "install.wim size" echo "Original: $(get_filesize_mb "$iso_install_wim")" echo "Optimized: $(get_filesize_mb "$install_wim")" @@ -5415,7 +5468,7 @@ install_windows() { # https://github.com/pbatard/rufus/issues/1990 # https://learn.microsoft.com/windows/iot/iot-enterprise/Hardware/System_Requirements if [ "$product_ver" = "11" ] && [ "$(nproc)" -le 1 ]; then - wiminfo "$install_wim" "$image_name" --image-property WINDOWS/INSTALLATIONTYPE=Server + wiminfo "$install_wim" "$image_index" --image-property WINDOWS/INSTALLATIONTYPE=Server fi # 变量名 使用场景 @@ -5450,10 +5503,6 @@ install_windows() { drv=/os/drivers mkdir -p "$drv" # 驱动下载临时文件夹 - # 下载脚本 - # shellcheck disable=SC1090 - . <(wget -O- $confhome/windows-driver-utils.sh) - # 这里有坑 # $(get_cloud_vendor) 调用了 cache_dmi_and_virt # 但是 $(get_cloud_vendor) 运行在 subshell 里面 @@ -5473,18 +5522,19 @@ install_windows() { add_driver_huawei_virtio # gcp 官方驱动不全,需要用公版补全 - elif [ "$vendor" = gcp ] && [ "$nt_ver" = 6.1 ] && [ "$arch_wim" = x86_64 ]; then - add_driver_gcp_virtio_win6_1_sha1_x64 - add_driver_generic_virtio \( -iname viorng.inf -or -iname balloon.inf \) - - elif [ "$vendor" = gcp ] && is_nt_ver_ge 6.2 && [ "$arch_wim" = x86 ]; then + # 官方 windows server 模板没有 viorng 设备,但 linux 模板有 + elif [ "$vendor" = gcp ] && is_nt_ver_ge 6.1 && [ "$arch_wim" = x86 ] && $support_sha256; then add_driver_gcp_virtio add_driver_generic_virtio \( -iname viorng.inf -or -iname pvpanic.inf \) - elif [ "$vendor" = gcp ] && is_nt_ver_ge 6.2 && [ "$arch_wim" = x86_64 ]; then + elif [ "$vendor" = gcp ] && is_nt_ver_ge 6.1 && [ "$arch_wim" = x86_64 ] && $support_sha256; then add_driver_gcp_virtio add_driver_generic_virtio -iname viorng.inf + elif [ "$vendor" = gcp ] && [ "$nt_ver" = 6.1 ] && [ "$arch_wim" = x86_64 ] && ! $support_sha256; then + add_driver_gcp_virtio_win6_1_sha1_x64 + add_driver_generic_virtio \( -iname viorng.inf -or -iname balloon.inf \) + else # 兜底 add_driver_generic_virtio @@ -5554,8 +5604,9 @@ install_windows() { file=$( case "$product_ver" in - '7' | '2008 r2') echo 29323/eng/prowin${arch_intel}legacy.exe ;; # 24.3 sha1 签名 - # '7' | '2008 r2') echo 18713/eng/prowin${arch_intel}legacy.exe ;; # 25.0 有部分文件是 sha256 签名 + '7' | '2008 r2') $support_sha256 && + echo echo 18713/eng/prowin${arch_intel}legacy.exe || # 25.0 有部分文件是 sha256 签名 + echo 29323/eng/prowin${arch_intel}legacy.exe ;; # 24.3 sha1 签名 '8') echo 21642/eng/prowin${arch_intel}.exe ;; '8.1') echo 764813/Wired_driver_27.8_${arch_intel}.zip ;; '2012' | '2012 r2') echo 785805/Wired_driver_28.2_${arch_intel}.zip ;; @@ -5663,8 +5714,7 @@ EOF ena_ver=$( case "$nt_ver" in - 6.1) echo 2.1.4 ;; # sha1 签名 - # 6.1) echo 2.2.3 ;; # sha256 签名 + 6.1) $support_sha256 && echo 2.2.3 || echo 2.1.4 ;; 6.2 | 6.3) echo 2.6.0 ;; *) echo Latest ;; esac @@ -5708,8 +5758,7 @@ EOF aws_pv_ver=$( case "$nt_ver" in - 6.1) echo 8.3.2 ;; # sha1 签名 - # 6.1) echo 8.3.5 ;; # sha256 签名 + 6.1) $support_sha256 && echo 8.3.5 || echo echo 8.3.2 ;; 6.2 | 6.3) echo 8.4.3 ;; *) echo Latest ;; esac @@ -5790,14 +5839,15 @@ EOF # 173-9 不是稳定版? # 185 ~ 187 win7 vioscsi 是 sha256 签名 # 189 ~ 215 win7 vultr 气球驱动死机 - # 217 ~ 266 win7 甲骨文 vioscsi 用不了,即使是红帽的 virtio-win-1.9.44 也用不了 - # 217 ~ 266 2k12 证书有问题 + # 217 ~ 271 win7 甲骨文 vioscsi 用不了,即使是红帽的 virtio-win-1.9.45 也用不了 + # 217 ~ 271 2k12 证书有问题 # 2008 安装的气球驱动不能用,需要到硬件管理器重新安装设备才能用,无需更新驱动 # https://github.com/virtio-win/virtio-win-pkg-scripts/issues/40 # https://github.com/virtio-win/virtio-win-pkg-scripts/issues/61 case "$nt_ver" in + # 最新版里面的 win2008 win7 是 sha1 签名的,但是甲骨文 vioscsi 用不了 6.0 | 6.1) dir=archive-virtio/virtio-win-0.1.173-9 ;; # vista|w7|2k8|2k8R2 6.2 | 6.3) dir=archive-virtio/virtio-win-0.1.215-2 ;; # w8|w8.1|2k12|2k12R2 *) dir=stable-virtio ;; @@ -5941,38 +5991,21 @@ EOF add_driver_aliyun_virtio() { info "Add drivers: Aliyun virtio" - # win7 旧驱动是 sha1 签名 - if [ "$nt_ver" = 6.1 ]; then - # 旧驱动 - aliyun_sys=$( - case "$nt_ver" in - 6.1) echo 7 ;; - 6.2 | 6.3) echo 8 ;; - *) echo 10 ;; - esac - ) + # win7 sha1 旧驱动 + if [ "$nt_ver" = 6.1 ] && ! $support_sha256; then + filename=210408.1454.1459_bin.zip # sha1 + # filename=220915.0953.0953_bin.zip # sha256 + # filename=new_virtio.zip # sha256 - filename=$( - case "$nt_ver" in - 6.1) echo 210408.1454.1459_bin.zip ;; # sha1 - *) echo 220915.0953.0953_bin.zip ;; # sha256 - # *) echo new_virtio.zip ;; - esac - ) - - region=$( - if is_in_china; then - echo cn-beijing - else - echo us-west-1 - fi - ) + if is_in_china; then + region=cn-beijing + else + region=us-west-1 + fi download https://windows-driver-$region.oss-$region.aliyuncs.com/virtio/$filename $drv/aliyun.zip unzip -o -d $drv/aliyun/ $drv/aliyun.zip - - # 注意文件夹是 win7 Win8 win10 大小写不一致 - cp_drivers $drv/aliyun -ipath "*/win${aliyun_sys}/${arch}/*" + cp_drivers $drv/aliyun -ipath "*/win7/${arch}/*" else # 新驱动 aliyun_sys=$( @@ -5996,7 +6029,7 @@ EOF fi } - # gcp virtio win7 x64 + # gcp virtio win7 x64 sha1 # 缺 balloon viorng add_driver_gcp_virtio_win6_1_sha1_x64() { info "Add drivers: GCP virtio win6.1 sha1 x64" @@ -6005,15 +6038,15 @@ EOF for file in \ WdfCoInstaller01009.dll WdfCoInstaller01011.dll \ netkvm.inf netkvm.cat netkvm.sys netkvmco.dll \ - nvme.inf nvme64.cat nvme.sys \ pvpanic.inf pvpanic.sys pvpanic.cat \ - vioscsi.inf vioscsi.sys vioscsi.cat; do + vioscsi.inf vioscsi.sys vioscsi.cat \ + $([ -d /sys/module/nvme ] && ! $has_stornvme && echo nvme.inf nvme64.cat nvme.sys); do download https://storage.googleapis.com/gce-windows-drivers-public/win6.1sha1/$file $drv/gce/win6.1sha1/$file done cp_drivers $drv/gce/win6.1sha1 } - # gcp virtio win8+ + # gcp virtio win7+ sha256 # x86 缺 viorng pvpanic # x64 缺 viorng # https://github.com/GoogleCloudPlatform/compute-image-tools/tree/master/daisy_workflows/image_build/windows @@ -6063,7 +6096,9 @@ EOF link=$(grep -o "/pool/.*-google-compute-engine-driver-$part.*\.goo" $drv/gce/gce.json) wget $gce_repo$link -O- | tar xz -C $drv/gce/$part - # inf 不限版本,6.0 能装 6.1 的驱动但用不了 + # inf 不限版本 + # 但 win7 gvnic ndis 版本是 6.2,vista/2008 能装但用不了 + # https://github.com/GoogleCloudPlatform/compute-virtual-ethernet-windows/blob/cad1edf7a05465f4972a81f2c015952fd228b5e3/src/gvnic.vcxproj#L298 if false; then for suffix in '' '-32'; do if [ -d "$drv/gce/$part/win6.1$suffix" ]; then @@ -6126,6 +6161,8 @@ EOF locale=$(get_selected_image_prop 'Default Language') use_default_rdp_port=$(is_need_change_rdp_port && echo false || echo true) password_base64=$(get_password_windows_administrator_base64) + # 7601.24214.180801-1700.win7sp1_ldr_escrow_CLIENT_ULTIMATE_x64FRE_en-us.iso Image Name 为空 + # 将 xml Image Name 的值设为空可以正常安装 sed -i \ -e "s|%arch%|$arch|" \ -e "s|%image_name%|$image_name|" \ @@ -6152,7 +6189,7 @@ EOF # 评估版 iso ei.cfg 有 EVAL 字样,填空白 key 报错 Windows Cannot find Microsoft software license terms # key - if [[ "$image_name" = 'Windows Vista*' ]]; then + if [ "$product_ver" = vista ]; then # vista 需密钥,密钥可与 edition 不一致 # TODO: 改成从网页获取? # https://learn.microsoft.com/en-us/windows-server/get-started/kms-client-activation-keys @@ -6169,13 +6206,6 @@ EOF fi fi - mkdir -p /wim - - # 挂载 install.wim,检查是否有 sac 组件 - wimmount "$install_wim" "$image_name" /wim/ - [ -f /wim/Windows/System32/sacsess.exe ] && has_sac=true || has_sac=false - wimunmount /wim/ - # 挂载 boot.wim info "mount boot.wim" wimmountrw /os/boot.wim "$boot_index" /wim/ @@ -6306,7 +6336,7 @@ EOF # 所以复制 resize.bat 到 install.wim if true; then info "mount install.wim" - wimmountrw $install_wim "$image_name" /wim/ + wimmountrw $install_wim "$image_index" /wim/ if false; then # 使用 autounattend.xml # win7 在此阶段找不到网卡 From 4346f4b460e89fa1c8a381824570f2028d182619 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Tue, 15 Apr 2025 23:40:58 +0800 Subject: [PATCH 038/127] =?UTF-8?q?core:=20=E4=B8=8D=E9=87=8D=E8=A6=81?= =?UTF-8?q?=E7=9A=84=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.en.md | 12 ++++++------ README.md | 12 ++++++------ reinstall.sh | 27 ++++++++++++++++++++------- trans.sh | 6 +++++- 4 files changed, 37 insertions(+), 20 deletions(-) diff --git a/README.en.md b/README.en.md index 5eb02bb..7bd68ca 100644 --- a/README.en.md +++ b/README.en.md @@ -39,7 +39,7 @@ The system requirements for the target system are as follows: | RHEL   AlmaLinux   Rocky   Oracle | 8, 9 | 512 MB \* | 5 GB | | OpenCloudOS | 8, 9, Stream 23 | 512 MB \* | 5 GB | | CentOS Stream | 9, 10 | 512 MB \* | 5 GB | -| Fedora | 40, 41 | 512 MB \* | 5 GB | +| Fedora | 41, 42 | 512 MB \* | 5 GB | | openEuler | 20.03 LTS - 24.03 LTS, 25.03 | 512 MB \* | 5 GB | | openSUSE | Leap 15.6, Tumbleweed (Rolling) | 512 MB \* | 5 GB | | NixOS | 24.11 | 512 MB | 5 GB | @@ -132,7 +132,7 @@ bash reinstall.sh anolis 7|8|23 oracle 8|9 almalinux 8|9 centos 9|10 - fedora 40|41 + fedora 41|42 nixos 24.11 debian 9|10|11|12 opensuse 15.6|tumbleweed @@ -163,9 +163,9 @@ bash reinstall.sh anolis 7|8|23 - `--hold 2` Prevent reboot after installation completes, allowing SSH login to modify system content; the system is mounted at `/os` (this feature is not supported on Debian/Kali). > [!TIP] -> When installing Debian/Kali, x86 architectures can monitor the installation progress through VNC in the background, while ARM architectures can use the serial console. +> When installing Debian/Kali, x86 architectures can monitor the installation progress through VNC from server provider, while ARM architectures can use the serial console. > -> When installing other systems, can monitor the progress through various methods (SSH, HTTP 80 port, VNC in the background, serial console). +> When installing other systems, can monitor the progress through various methods (SSH, HTTP 80 port, VNC from server provider, serial console). >
Even if errors occur during the installation process, you can still install to Alpine via SSH by running `/trans.sh alpine`
@@ -219,7 +219,7 @@ bash reinstall.sh dd --img "https://example.com/xxx.xz" - `--hold 2` Prevent reboot after the DD process finishes, allowing SSH login to modify system content. The Windows system will be mounted at `/os`, but Linux systems will **NOT** be automatically mounted. > [!TIP] -> Can monitor the progress through various methods (SSH, HTTP 80 port, VNC in the background, serial console). +> Can monitor the progress through various methods (SSH, HTTP 80 port, VNC from server provider, serial console). >
Even if errors occur during the installation process, you can still install to Alpine via SSH by running `/trans.sh alpine` ### Feature 3: Reboot to Alpine Live OS (RAM OS) @@ -400,7 +400,7 @@ bash reinstall.sh windows \ - AWS ([ENA Network Adapter][aws-ena], [NVME Storage Controller][aws-nvme]) - GCP ([gVNIC Network Adapter][gcp-gvnic], [GGA Display Adapter][gcp-gga]) - Azure ([MANA Network Adapter][azure-mana]) -- Intel ([VMD Storage Controller][intel-vmd], Network Adapter: [7][intel-nic-7-sha1], [8][intel-nic-8], [8.1][intel-nic-8.1], [10][intel-nic-10], [11][intel-nic-11], [2008 R2][intel-nic-7-sha1], [2012][intel-nic-2012], [2012 R2][intel-nic-2012-r2], [2016][intel-nic-2016], [2019][intel-nic-2019], [2022][intel-nic-2022], [2025][intel-nic-2025]) +- Intel ([VMD Storage Controller][intel-vmd], Network Adapter: [7][intel-nic-7-sha256], [8][intel-nic-8], [8.1][intel-nic-8.1], [10][intel-nic-10], [11][intel-nic-11], [2008 R2][intel-nic-7-sha1], [2012][intel-nic-2012], [2012 R2][intel-nic-2012-r2], [2016][intel-nic-2016], [2019][intel-nic-2019], [2022][intel-nic-2022], [2025][intel-nic-2025]) [virtio-virtio]: https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/ [virtio-aliyun]: https://www.alibabacloud.com/help/ecs/user-guide/install-the-virtio-driver-1 diff --git a/README.md b/README.md index c9e84c8..7a0c0e4 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ | RHEL   AlmaLinux   Rocky   Oracle | 8, 9 | 512 MB \* | 5 GB | | OpenCloudOS | 8, 9, Stream 23 | 512 MB \* | 5 GB | | CentOS Stream | 9, 10 | 512 MB \* | 5 GB | -| Fedora | 40, 41 | 512 MB \* | 5 GB | +| Fedora | 41, 42 | 512 MB \* | 5 GB | | openEuler | 20.03 LTS - 24.03 LTS, 25.03 | 512 MB \* | 5 GB | | openSUSE | Leap 15.6, Tumbleweed (滚动) | 512 MB \* | 5 GB | | NixOS | 24.11 | 512 MB | 5 GB | @@ -132,7 +132,7 @@ bash reinstall.sh anolis 7|8|23 oracle 8|9 almalinux 8|9 centos 9|10 - fedora 40|41 + fedora 41|42 nixos 24.11 debian 9|10|11|12 opensuse 15.6|tumbleweed @@ -163,9 +163,9 @@ bash reinstall.sh anolis 7|8|23 - `--hold 2` 安装结束后不重启,此时可以 SSH 登录修改系统内容,系统挂载在 `/os` (此功能不支持 Debian/Kali) > [!TIP] -> 安装 Debian/Kali 时,x86 可通过后台 VNC 查看安装进度,ARM 可通过串行控制台查看安装进度。 +> 安装 Debian/Kali 时,x86 可通过商家后台 VNC 查看安装进度,ARM 可通过串行控制台查看安装进度。 > -> 安装其它系统时,可通过多种方式(SSH、HTTP 80 端口、后台 VNC、串行控制台)查看安装进度。 +> 安装其它系统时,可通过多种方式(SSH、HTTP 80 端口、商家后台 VNC、串行控制台)查看安装进度。 >
即使安装过程出错,也能通过 SSH 运行 `/trans.sh alpine` 安装到 Alpine。
@@ -219,7 +219,7 @@ bash reinstall.sh dd --img "https://example.com/xxx.xz" - `--hold 2` DD 结束后不重启,此时可以 SSH 登录修改系统内容,Windows 系统会挂载在 `/os`,Linux 系统**不会**自动挂载 > [!TIP] -> 可通过多种方式(SSH、HTTP 80 端口、后台 VNC、串行控制台)查看安装进度。 +> 可通过多种方式(SSH、HTTP 80 端口、商家后台 VNC、串行控制台)查看安装进度。 >
即使安装过程出错,也能通过 SSH 运行 `/trans.sh alpine` 安装到 Alpine。 ### 功能 3: 重启到 Alpine Live OS(内存系统) @@ -400,7 +400,7 @@ bash reinstall.sh windows \ - AWS ([ENA 网卡][aws-ena], [NVME 存储控制器][aws-nvme]) - GCP ([gVNIC 网卡][gcp-gvnic], [GGA 显卡][gcp-gga]) - Azure ([MANA 网卡][azure-mana]) -- Intel ([VMD 存储控制器][intel-vmd], 网卡: [7][intel-nic-7-sha1], [8][intel-nic-8], [8.1][intel-nic-8.1], [10][intel-nic-10], [11][intel-nic-11], [2008 R2][intel-nic-7-sha1], [2012][intel-nic-2012], [2012 R2][intel-nic-2012-r2], [2016][intel-nic-2016], [2019][intel-nic-2019], [2022][intel-nic-2022], [2025][intel-nic-2025]) +- Intel ([VMD 存储控制器][intel-vmd], 网卡: [7][intel-nic-7-sha256], [8][intel-nic-8], [8.1][intel-nic-8.1], [10][intel-nic-10], [11][intel-nic-11], [2008 R2][intel-nic-7-sha256], [2012][intel-nic-2012], [2012 R2][intel-nic-2012-r2], [2016][intel-nic-2016], [2019][intel-nic-2019], [2022][intel-nic-2022], [2025][intel-nic-2025]) [virtio-virtio]: https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/ [virtio-aliyun]: https://www.alibabacloud.com/help/ecs/user-guide/install-the-virtio-driver-1 diff --git a/reinstall.sh b/reinstall.sh index 1b51a9f..ef8dca8 100644 --- a/reinstall.sh +++ b/reinstall.sh @@ -52,7 +52,7 @@ Usage: $reinstall_____ anolis 7|8|23 oracle 8|9 almalinux 8|9 centos 9|10 - fedora 40|41 + fedora 41|42 nixos 24.11 debian 9|10|11|12 opensuse 15.6|tumbleweed @@ -200,13 +200,25 @@ get_os_part() { awk '($2=="/") { print $1 }' /proc/mounts } +umount_all() { + # windows defender 打开时,cygwin 运行 mount 很慢,但 cat /proc/mounts 很快 + if mount_lists=$(mount | grep -w "on $1" | awk '{print $3}' | grep .); then + # alpine 没有 -R + if umount --help 2>&1 | grep -wq -- '-R'; then + umount -R "$1" + else + echo "$mount_lists" | tac | xargs -n1 umount + fi + fi +} + cp_to_btrfs_root() { mount_dir=$tmp/reinstall-btrfs-root if ! grep -q $mount_dir /proc/mounts; then mkdir -p $mount_dir mount "$(get_os_part)" $mount_dir -t btrfs -o subvol=/ fi - cp -rf "$@" $tmp/reinstall-btrfs-root + cp -rf "$@" "$mount_dir" } is_host_has_ipv4_and_ipv6() { @@ -1584,8 +1596,8 @@ Continue with DD? rocky) ci_image=$ci_mirror/Rocky-$releasever-GenericCloud-Base.latest.$basearch.qcow2 ;; fedora) # 不加 / 会跳转到 https://dl.fedoraproject.org,纯 ipv6 无法访问 - # curl -L -6 https://d2lzkl7pfhq30w.cloudfront.net/pub/fedora/linux/releases/41/Cloud/x86_64/images - # curl -L -6 https://d2lzkl7pfhq30w.cloudfront.net/pub/fedora/linux/releases/41/Cloud/x86_64/images/ + # curl -L -6 https://d2lzkl7pfhq30w.cloudfront.net/pub/fedora/linux/releases/42/Cloud/x86_64/images + # curl -L -6 https://d2lzkl7pfhq30w.cloudfront.net/pub/fedora/linux/releases/42/Cloud/x86_64/images/ filename=$(curl -L $ci_mirror/ | grep -oP "Fedora-Cloud-Base-Generic.*?.qcow2" | sort -uV | tail -1 | grep .) ci_image=$ci_mirror/$filename @@ -1775,7 +1787,7 @@ verify_os_name() { 'rocky 8|9' \ 'redhat 8|9' \ 'oracle 8|9' \ - 'fedora 40|41' \ + 'fedora 41|42' \ 'nixos 24.11' \ 'debian 9|10|11|12' \ 'opensuse 15.6|16.0|tumbleweed' \ @@ -2979,8 +2991,9 @@ mkdir_clear() { return fi - # alpine 没有 -R - # { umount $dir || umount -R $dir || true; } 2>/dev/null + # 再次运行时,有可能 mount 了 btrfs root,因此先要 umount_all + # 但目前不需要 mount ,因此用不到 + # umount_all $dir rm -rf $dir mkdir -p $dir } diff --git a/trans.sh b/trans.sh index 3c40319..2ee9847 100644 --- a/trans.sh +++ b/trans.sh @@ -2030,6 +2030,8 @@ EOF cat -n net.cfg # 正常应该是 -D gentoo,但 alpine 的 cloud-init 包缺少 gentoo 配置 cloud-init devel net-convert -p net.cfg -k yaml -d out -D alpine -O networkd + + # 注意名字是 10-cloud-init-eth*.network,fix-eth-name.sh 会此文件名查找配置文件 cp out/etc/systemd/network/10-cloud-init-eth*.network $os_dir/etc/systemd/network/ # 删除网卡名匹配 @@ -2359,7 +2361,7 @@ create_part() { # 向下取整 MiB # gpt 最后 33 个扇区是备份分区表,不可用 - # parted 会忽略最后不足 1MiB 的部分 + # parted 结束位置填 100% 时也会忽略最后不足 1MiB 的部分,我们模仿它 max_can_use_m=$((total_sector_count_except_backup_gpt * sector_size / 1024 / 1024)) echo "expect_m: $expect_m" @@ -6726,6 +6728,8 @@ elif [ "$1" = "alpine" ]; then distro=alpine # 后面的步骤很多都会用到这个,例如分区布局 cloud_image=0 +elif [ -n "$1" ]; then + error_and_exit "unknown option $1" fi # 无参数运行部分 From 2c15d1be980754dc1399c59f0b6759ead47bd474 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Wed, 16 Apr 2025 00:12:27 +0800 Subject: [PATCH 039/127] =?UTF-8?q?core:=20=E6=94=B9=E5=9B=9E=E7=94=A8=20o?= =?UTF-8?q?pensuse=20=E7=9A=84=20grub.efi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit closes #288 #292 #319 --- reinstall.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reinstall.sh b/reinstall.sh index ef8dca8..a9c8975 100644 --- a/reinstall.sh +++ b/reinstall.sh @@ -2680,7 +2680,7 @@ install_grub_linux_efi() { info 'download grub efi' # fedora 39 的 efi 无法识别 opensuse tumbleweed 的 xfs - efi_distro=fedora + efi_distro=opensuse grub_efi=$(get_grub_efi_filename) # 不要用 download.opensuse.org 和 download.fedoraproject.org From 89f01de6b6e797adfef28bd904127dbabe0301ee Mon Sep 17 00:00:00 2001 From: bin456789 Date: Thu, 17 Apr 2025 00:05:28 +0800 Subject: [PATCH 040/127] =?UTF-8?q?windows:=20=E4=BC=98=E5=8C=96=E9=A9=B1?= =?UTF-8?q?=E5=8A=A8=E9=80=89=E6=8B=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 从注册表 Installation Type 判断是 Client 还是 Server,修复 2012 r2 评估版识别成 Client - 添加 virtio sha256 驱动 - 必要时才安装 GCP win7 nvme 驱动 --- README.en.md | 2 +- README.md | 2 +- trans.sh | 158 ++++++++++++++++++++++++++++++++++----------------- 3 files changed, 108 insertions(+), 54 deletions(-) diff --git a/README.en.md b/README.en.md index 7bd68ca..aa63905 100644 --- a/README.en.md +++ b/README.en.md @@ -400,7 +400,7 @@ bash reinstall.sh windows \ - AWS ([ENA Network Adapter][aws-ena], [NVME Storage Controller][aws-nvme]) - GCP ([gVNIC Network Adapter][gcp-gvnic], [GGA Display Adapter][gcp-gga]) - Azure ([MANA Network Adapter][azure-mana]) -- Intel ([VMD Storage Controller][intel-vmd], Network Adapter: [7][intel-nic-7-sha256], [8][intel-nic-8], [8.1][intel-nic-8.1], [10][intel-nic-10], [11][intel-nic-11], [2008 R2][intel-nic-7-sha1], [2012][intel-nic-2012], [2012 R2][intel-nic-2012-r2], [2016][intel-nic-2016], [2019][intel-nic-2019], [2022][intel-nic-2022], [2025][intel-nic-2025]) +- Intel ([VMD Storage Controller][intel-vmd], Network Adapter: [7][intel-nic-7-sha256], [8][intel-nic-8], [8.1][intel-nic-8.1], [10][intel-nic-10], [11][intel-nic-11], [2008 R2][intel-nic-2008-r2-sha256], [2012][intel-nic-2012], [2012 R2][intel-nic-2012-r2], [2016][intel-nic-2016], [2019][intel-nic-2019], [2022][intel-nic-2022], [2025][intel-nic-2025]) [virtio-virtio]: https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/ [virtio-aliyun]: https://www.alibabacloud.com/help/ecs/user-guide/install-the-virtio-driver-1 diff --git a/README.md b/README.md index 7a0c0e4..816ac2d 100644 --- a/README.md +++ b/README.md @@ -400,7 +400,7 @@ bash reinstall.sh windows \ - AWS ([ENA 网卡][aws-ena], [NVME 存储控制器][aws-nvme]) - GCP ([gVNIC 网卡][gcp-gvnic], [GGA 显卡][gcp-gga]) - Azure ([MANA 网卡][azure-mana]) -- Intel ([VMD 存储控制器][intel-vmd], 网卡: [7][intel-nic-7-sha256], [8][intel-nic-8], [8.1][intel-nic-8.1], [10][intel-nic-10], [11][intel-nic-11], [2008 R2][intel-nic-7-sha256], [2012][intel-nic-2012], [2012 R2][intel-nic-2012-r2], [2016][intel-nic-2016], [2019][intel-nic-2019], [2022][intel-nic-2022], [2025][intel-nic-2025]) +- Intel ([VMD 存储控制器][intel-vmd], 网卡: [7][intel-nic-7-sha256], [8][intel-nic-8], [8.1][intel-nic-8.1], [10][intel-nic-10], [11][intel-nic-11], [2008 R2][intel-nic-2008-r2-sha256], [2012][intel-nic-2012], [2012 R2][intel-nic-2012-r2], [2016][intel-nic-2016], [2019][intel-nic-2019], [2022][intel-nic-2022], [2025][intel-nic-2025]) [virtio-virtio]: https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/ [virtio-aliyun]: https://www.alibabacloud.com/help/ecs/user-guide/install-the-virtio-driver-1 diff --git a/trans.sh b/trans.sh index 2ee9847..50d62c3 100644 --- a/trans.sh +++ b/trans.sh @@ -2789,7 +2789,9 @@ modify_windows() { image_state=IMAGE_STATE_COMPLETE if state_ini=$(find_file_ignore_case $os_dir/Windows/Setup/State/State.ini); then cat -n $state_ini - image_state=$(grep -i '^ImageState=' $state_ini | cut -d= -f2 | tr -d '\r') + if tmp=$(grep -i '^ImageState=' $state_ini | cut -d= -f2 | tr -d '\r' | grep .); then + image_state=$tmp + fi fi if [ "$image_state" = IMAGE_STATE_COMPLETE ]; then @@ -5229,12 +5231,24 @@ is_list_has() { echo "$list" | grep -qFx "$item" } +get_installation_type_from_windows_drive() { + os_dir=$1 + + apk add hivex + software_hive=$(find_file_ignore_case $os_dir/Windows/System32/config/SOFTWARE) + hivexsh "$software_hive" </dev/null 2>&1 - - support_sha256=false - if is_nt_ver_ge 6.2; then - support_sha256=true - else - # https://www.hummingheads.co.jp/press/info-certificates.html - # https://support.microsoft.com/kb/KB3033929 - # https://support.microsoft.com/kb/KB4474419 - # Windows Vista SP2 ldr_escrow 6.0.6003 + KB4474419 - # Windows 7 SP1 6.1.7601 + KB3033929 - ntoskrnl_exe=$(find_file_ignore_case /wim/Windows/System32/ntoskrnl.exe) - get_windows_version_from_dll "$ntoskrnl_exe" - if { [ "$nt_ver" = 6.0 ] && [ "$build_ver" -ge 6003 ] && [ "$rev_ver" -ge 20555 ]; } || - { [ "$nt_ver" = 6.1 ] && [ "$build_ver" -ge 7601 ] && [ "$rev_ver" -ge 18741 ]; }; then - support_sha256=true - fi - fi wimunmount /wim/ + # https://www.hummingheads.co.jp/press/info-certificates.html + # https://support.microsoft.com/kb/KB3033929 + # https://support.microsoft.com/kb/KB4474419 + # Windows Vista SP2 ldr_escrow 6.0.6003 + KB4474419 + # Windows 7 SP1 6.1.7601 + KB3033929 + support_sha256=false + if is_nt_ver_ge 6.2 || + { [ "$nt_ver" = 6.1 ] && [ "$build_ver" -ge 7601 ] && [ "$rev_ver" -ge 18741 ]; } || + { [ "$nt_ver" = 6.0 ] && [ "$build_ver" -ge 6003 ] && [ "$rev_ver" -ge 20555 ]; }; then + support_sha256=true + fi + + case "$installation_type" in + Client | Embedded) + windows_type=client + product_ver=$(get_client_name_by_build_ver "$build_ver") + ;; + Server | 'Server Core') + windows_type=server + product_ver=$(get_server_name_by_build_ver "$build_ver") + ;; + *) error_and_exit "Unknown Installation Type: $installation_type" ;; + esac + info "Selected image info" echo "Image Name: $image_name" echo "Product Version: $product_ver" @@ -5499,6 +5519,10 @@ install_windows() { ;; esac + # win7 drvload 可以加载 sha256 签名的驱动 + # 但系统安装完重启报错 windows cannot verify the digital signature for this file + # 需要按 F8 禁用驱动签名 + add_drivers() { info "Add drivers" @@ -5836,21 +5860,46 @@ EOF esac ) - # https://fedorapeople.org/groups/virt/virtio-win/repo/stable/ - # 171-1 是稳定版 - # 173-9 不是稳定版? - # 185 ~ 187 win7 vioscsi 是 sha256 签名 - # 189 ~ 215 win7 vultr 气球驱动死机 - # 217 ~ 271 win7 甲骨文 vioscsi 用不了,即使是红帽的 virtio-win-1.9.45 也用不了 - # 217 ~ 271 2k12 证书有问题 + # win7-drivers 分支 win7 文件夹只有一次提交,也就是 173 全家桶 + # 1. 2020.1.24 https://github.com/virtio-win/virtio-win-pkg-scripts/tree/win7-drivers/data/old-drivers/Win7 + + # master 分支 win7 文件夹有 3 次提交,从古到今 + # https://github.com/virtio-win/virtio-win-pkg-scripts/commits/master/data/old-drivers/Win7 + # 1. 2020/6/4 sha256,176 全家桶,相当于没发布的 176 iso + # 2. 2020/8/10 将部分文件降到 17400,相当于 189~215 iso + # 3. 2022/4/14 将部分文件降级,相当于 217~最新版 iso # 2008 安装的气球驱动不能用,需要到硬件管理器重新安装设备才能用,无需更新驱动 - # https://github.com/virtio-win/virtio-win-pkg-scripts/issues/40 + # 2k12 # https://github.com/virtio-win/virtio-win-pkg-scripts/issues/61 + # 217 ~ 271 2k12 证书有问题,红帽的 virtio-win-1.9.45 没问题 + + # win7 + # https://fedorapeople.org/groups/virt/virtio-win/repo/stable/ + # https://github.com/virtio-win/virtio-win-pkg-scripts/issues/40 + # 171-1 sha1 稳定版 + # 173-9 sha1 对应上面的 win7-drivers 分支,最后一次编译 win7 + sha1,但不是稳定版? + # 176 sha256 对应上面的 master-1 最后一次编译 win7,从这次开始是 sha256,此次不提供 iso,编译的文件在之后的 iso 可以找到 + # 185 ~ 187 sha256 正常工作,win7 文件来自 176 + # 189 ~ 215 sha1 对应上面的 master-2 气球版本 17400,vultr 死机 + # 217 ~ 271 sha1 对应上面的 master-3 甲骨文 vioscsi 因硬件 ID 不同用不了,红帽的 virtio-win-1.9.45 也是 + + # 甲骨文 vioscsi 硬件 ID 是 PCI\VEN_1AF4&DEV_1004&SUBSYS_0008108E&REV_00 + # SUBSYS 的厂商 ID 是甲骨文 + + # virtio-win-0.1.173-9 + # %VirtioScsi.DeviceDesc% = scsi_inst, PCI\VEN_1AF4&DEV_1004&SUBSYS_00081AF4&REV_00, PCI\VEN_1AF4&DEV_1004 + # %VirtioScsi.DeviceDesc% = scsi_inst, PCI\VEN_1AF4&DEV_1048&SUBSYS_11001AF4&REV_01, PCI\VEN_1AF4&DEV_1048 + + # stable-virtio + # %RHELScsi.DeviceDesc% = rhelscsi_inst, PCI\VEN_1AF4&DEV_1004&SUBSYS_00081AF4&REV_00 + # %RHELScsi.DeviceDesc% = rhelscsi_inst, PCI\VEN_1AF4&DEV_1048&SUBSYS_11001AF4&REV_01 + case "$nt_ver" in - # 最新版里面的 win2008 win7 是 sha1 签名的,但是甲骨文 vioscsi 用不了 - 6.0 | 6.1) dir=archive-virtio/virtio-win-0.1.173-9 ;; # vista|w7|2k8|2k8R2 + 6.0 | 6.1) $support_sha256 && + dir=archive-virtio/virtio-win-0.1.187-1 || + dir=archive-virtio/virtio-win-0.1.173-9 ;; # vista|w7|2k8|2k8R2 6.2 | 6.3) dir=archive-virtio/virtio-win-0.1.215-2 ;; # w8|w8.1|2k12|2k12R2 *) dir=stable-virtio ;; esac @@ -6036,6 +6085,10 @@ EOF add_driver_gcp_virtio_win6_1_sha1_x64() { info "Add drivers: GCP virtio win6.1 sha1 x64" + # 用到 nvme 时才下载 nvme 驱动 + # 因为 win7 可以通过更新获得 nvme 驱动 + # 而且谷歌推荐使用微软 nvme 驱动 + # (google-compute-engine-driver-nvme 2.0.0 更新内容是删除谷歌 nvme 驱动) mkdir -p $drv/gce/win6.1sha1 for file in \ WdfCoInstaller01009.dll WdfCoInstaller01011.dll \ @@ -6435,7 +6488,8 @@ sync_time() { ;; esac - hwclock -w + # 重启时 alpine 会自动写入到硬件时钟,因此这里跳过 + # hwclock -w } is_ubuntu_lts() { From 4061c5c6b6d64247b1a514acedb5c7b648f010d4 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Thu, 17 Apr 2025 21:10:24 +0800 Subject: [PATCH 041/127] =?UTF-8?q?dd:=20`State.ini`=20=E4=B8=8D=E5=AD=98?= =?UTF-8?q?=E5=9C=A8=E6=97=B6=E4=BB=8E=E6=B3=A8=E5=86=8C=E8=A1=A8=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E7=B3=BB=E7=BB=9F=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- trans.sh | 52 +++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/trans.sh b/trans.sh index 50d62c3..b1c16b6 100644 --- a/trans.sh +++ b/trans.sh @@ -2775,6 +2775,28 @@ EOF create_cloud_init_network_config "$ci_file" "$recognize_static6" "$recognize_ipv6_types" } +get_image_state() { + local os_dir=$1 + local image_state= + + # 如果 dd 镜像精简了 State.ini,则从注册表获取 + if state_ini=$(find_file_ignore_case $os_dir/Windows/Setup/State/State.ini); then + image_state=$(grep -i '^ImageState=' $state_ini | cut -d= -f2 | tr -d '\r') + fi + if [ -z "$image_state" ]; then + apk add hivex + hive=$(find_file_ignore_case $os_dir/Windows/System32/config/SOFTWARE) + image_state=$(hivexget $hive '\Microsoft\Windows\CurrentVersion\Setup\State' ImageState) + apk del hivex + fi + + if [ -n "$image_state" ]; then + echo "$image_state" + else + error_and_exit "Cannot get ImageState." + fi +} + modify_windows() { os_dir=$1 info "Modify Windows" @@ -2784,15 +2806,8 @@ modify_windows() { # https://learn.microsoft.com/windows-hardware/manufacture/desktop/add-a-custom-script-to-windows-setup # 判断用 SetupComplete 还是组策略 - # 默认视为 IMAGE_STATE_COMPLETE,除非有 State.ini,因为 dd 镜像可能精简了 State.ini - # 但最好还是从注册表获取 - image_state=IMAGE_STATE_COMPLETE - if state_ini=$(find_file_ignore_case $os_dir/Windows/Setup/State/State.ini); then - cat -n $state_ini - if tmp=$(grep -i '^ImageState=' $state_ini | cut -d= -f2 | tr -d '\r' | grep .); then - image_state=$tmp - fi - fi + image_state=$(get_image_state "$os_dir") + echo "ImageState: $image_state" if [ "$image_state" = IMAGE_STATE_COMPLETE ]; then use_gpo=true @@ -5231,15 +5246,18 @@ is_list_has() { echo "$list" | grep -qFx "$item" } +# hivexget 是 shell 脚本,开头是 #!/bin/bash +# 但 alpine 没安装 bash,直接运行 hivexget 会报错 +hivexget() { + ash "$(which hivexget)" "$@" +} + get_installation_type_from_windows_drive() { - os_dir=$1 + local os_dir=$1 apk add hivex - software_hive=$(find_file_ignore_case $os_dir/Windows/System32/config/SOFTWARE) - hivexsh "$software_hive" < Date: Thu, 17 Apr 2025 21:10:25 +0800 Subject: [PATCH 042/127] =?UTF-8?q?core:=20=E4=BC=98=E5=8C=96=20windows=20?= =?UTF-8?q?=E4=B8=8B=E7=9A=84=E6=96=87=E4=BB=B6=E4=B8=8B=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- reinstall.bat | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/reinstall.bat b/reinstall.bat index 40a346b..a34aa22 100644 --- a/reinstall.bat +++ b/reinstall.bat @@ -126,11 +126,8 @@ call :check_cygwin_installed || ( --packages %pkgs% rem 检查 Cygwin 是否成功安装 - if errorlevel 1 ( - goto :install_cygwin_failed - ) else ( - call :check_cygwin_installed || goto :install_cygwin_failed - ) + if errorlevel 1 goto :install_cygwin_failed + call :check_cygwin_installed || goto :install_cygwin_failed ) rem 在c盘根目录下执行 cygpath -ua . 会得到 /cygdrive/c,因此末尾要有 / @@ -159,23 +156,28 @@ rem 或者添加 export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/ %SystemDrive%\cygwin\bin\bash %thisdir%reinstall.sh %* exit /b - - - - -:download rem bits 要求有 Content-Length 才能下载 +rem cloudflare 的 cdn-cgi/trace 没有 Content-Length rem 据说如果网络设为“按流量计费” bits 也无法下载 rem https://learn.microsoft.com/en-us/windows/win32/bits/http-requirements-for-bits-downloads +rem bitsadmin /transfer "%~3" /priority foreground %~1 %~2 + +:download rem certutil 会被 windows Defender 报毒 rem windows server 2019 要用第二条 certutil 命令 echo Download: %~1 %~2 del /q "%~2" 2>nul if exist "%~2" (echo Cannot delete %~2 & exit /b 1) -if not exist "%~2" certutil -urlcache -f -split "%~1" "%~2" >nul -if not exist "%~2" certutil -urlcache -split "%~1" "%~2" >nul -if not exist "%~2" exit /b 1 -exit /b + +certutil -urlcache -f -split "%~1" "%~2" >nul +if not errorlevel 1 if exist "%~2" exit /b 0 + +certutil -urlcache -split "%~1" "%~2" >nul +if not errorlevel 1 if exist "%~2" exit /b 0 + +rem 下载失败时删除文件,防止下载了一部分导致下次运行时跳过了下载 +del /q "%~2" 2>nul +exit /b 1 :download_with_curl rem 加 --insecure 防止以下错误 From 5409cecbcb1b5a8d8150ace07abfa272715a77b7 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Fri, 18 Apr 2025 18:42:48 +0800 Subject: [PATCH 043/127] =?UTF-8?q?ubuntu:=20=E6=B7=BB=E5=8A=A0=2025.04?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.en.md | 13 ++++++------- README.md | 13 ++++++------- reinstall.sh | 9 +++++---- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/README.en.md b/README.en.md index aa63905..9192f47 100644 --- a/README.en.md +++ b/README.en.md @@ -1,4 +1,4 @@ - + # reinstall @@ -34,7 +34,7 @@ The system requirements for the target system are as follows: | Alpine | 3.18, 3.19, 3.20, 3.21 | 256 MB | 1 GB | | Debian | 9, 10, 11, 12 | 256 MB | 1 ~ 1.5 GB ^ | | Kali | Rolling | 256 MB | 1 ~ 1.5 GB ^ | -| Ubuntu | 16.04 LTS - 24.04 LTS, 24.10 | 512 MB \* | 2 GB | +| Ubuntu | 16.04 LTS - 24.04 LTS, 25.04 | 512 MB \* | 2 GB | | Anolis | 7, 8, 23 | 512 MB \* | 5 GB | | RHEL   AlmaLinux   Rocky   Oracle | 8, 9 | 512 MB \* | 5 GB | | OpenCloudOS | 8, 9, Stream 23 | 512 MB \* | 5 GB | @@ -138,7 +138,7 @@ bash reinstall.sh anolis 7|8|23 opensuse 15.6|tumbleweed alpine 3.18|3.19|3.20|3.21 openeuler 20.03|22.03|24.03|25.03 - ubuntu 16.04|18.04|20.04|22.04|24.04|24.10 [--minimal] + ubuntu 16.04|18.04|20.04|22.04|24.04|25.04 [--minimal] kali arch gentoo @@ -400,7 +400,7 @@ bash reinstall.sh windows \ - AWS ([ENA Network Adapter][aws-ena], [NVME Storage Controller][aws-nvme]) - GCP ([gVNIC Network Adapter][gcp-gvnic], [GGA Display Adapter][gcp-gga]) - Azure ([MANA Network Adapter][azure-mana]) -- Intel ([VMD Storage Controller][intel-vmd], Network Adapter: [7][intel-nic-7-sha256], [8][intel-nic-8], [8.1][intel-nic-8.1], [10][intel-nic-10], [11][intel-nic-11], [2008 R2][intel-nic-2008-r2-sha256], [2012][intel-nic-2012], [2012 R2][intel-nic-2012-r2], [2016][intel-nic-2016], [2019][intel-nic-2019], [2022][intel-nic-2022], [2025][intel-nic-2025]) +- Intel ([VMD Storage Controller][intel-vmd], Network Adapter: [7][intel-nic-7], [8][intel-nic-8], [8.1][intel-nic-8.1], [10][intel-nic-10], [11][intel-nic-11], [2008 R2][intel-nic-2008-r2], [2012][intel-nic-2012], [2012 R2][intel-nic-2012-r2], [2016][intel-nic-2016], [2019][intel-nic-2019], [2022][intel-nic-2022], [2025][intel-nic-2025]) [virtio-virtio]: https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/ [virtio-aliyun]: https://www.alibabacloud.com/help/ecs/user-guide/install-the-virtio-driver-1 @@ -415,13 +415,12 @@ bash reinstall.sh windows \ [gcp-gga]: https://cloud.google.com/compute/docs/instances/enable-instance-virtual-display [azure-mana]: https://learn.microsoft.com/azure/virtual-network/accelerated-networking-mana-windows [intel-vmd]: https://www.intel.com/content/www/us/en/download/849936/intel-rapid-storage-technology-driver-installation-software-with-intel-optane-memory-12th-to-15th-gen-platforms.html -[intel-nic-7-sha1]: https://www.intel.com/content/www/us/en/download/15590/29323/intel-network-adapter-driver-for-windows-7-final-release.html -[intel-nic-7-sha256]: https://www.intel.com/content/www/us/en/download/15590/intel-network-adapter-driver-for-windows-7-final-release.html +[intel-nic-7]: https://www.intel.com/content/www/us/en/download/15590/intel-network-adapter-driver-for-windows-7-final-release.html [intel-nic-8]: https://www.intel.com/content/www/us/en/download/16765/intel-network-adapter-driver-for-windows-8-final-release.html [intel-nic-8.1]: https://www.intel.com/content/www/us/en/download/17479/intel-network-adapter-driver-for-windows-8-1.html [intel-nic-10]: https://www.intel.com/content/www/us/en/download/18293/intel-network-adapter-driver-for-windows-10.html [intel-nic-11]: https://www.intel.com/content/www/us/en/download/727998/intel-network-adapter-driver-for-microsoft-windows-11.html -[intel-nic-2008-r2-sha256]: https://www.intel.com/content/www/us/en/download/15591/intel-network-adapter-driver-for-windows-server-2008-r2-final-release.html +[intel-nic-2008-r2]: https://www.intel.com/content/www/us/en/download/15591/intel-network-adapter-driver-for-windows-server-2008-r2-final-release.html [intel-nic-2012]: https://www.intel.com/content/www/us/en/download/16789/intel-network-adapter-driver-for-windows-server-2012.html [intel-nic-2012-r2]: https://www.intel.com/content/www/us/en/download/17480/intel-network-adapter-driver-for-windows-server-2012-r2.html [intel-nic-2016]: https://www.intel.com/content/www/us/en/download/18737/intel-network-adapter-driver-for-windows-server-2016.html diff --git a/README.md b/README.md index 816ac2d..d34f4d1 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ - + # reinstall @@ -34,7 +34,7 @@ | Alpine | 3.18, 3.19, 3.20, 3.21 | 256 MB | 1 GB | | Debian | 9, 10, 11, 12 | 256 MB | 1 ~ 1.5 GB ^ | | Kali | 滚动 | 256 MB | 1 ~ 1.5 GB ^ | -| Ubuntu | 16.04 LTS - 24.04 LTS, 24.10 | 512 MB \* | 2 GB | +| Ubuntu | 16.04 LTS - 24.04 LTS, 25.04 | 512 MB \* | 2 GB | | Anolis | 7, 8, 23 | 512 MB \* | 5 GB | | RHEL   AlmaLinux   Rocky   Oracle | 8, 9 | 512 MB \* | 5 GB | | OpenCloudOS | 8, 9, Stream 23 | 512 MB \* | 5 GB | @@ -138,7 +138,7 @@ bash reinstall.sh anolis 7|8|23 opensuse 15.6|tumbleweed alpine 3.18|3.19|3.20|3.21 openeuler 20.03|22.03|24.03|25.03 - ubuntu 16.04|18.04|20.04|22.04|24.04|24.10 [--minimal] + ubuntu 16.04|18.04|20.04|22.04|24.04|25.04 [--minimal] kali arch gentoo @@ -400,7 +400,7 @@ bash reinstall.sh windows \ - AWS ([ENA 网卡][aws-ena], [NVME 存储控制器][aws-nvme]) - GCP ([gVNIC 网卡][gcp-gvnic], [GGA 显卡][gcp-gga]) - Azure ([MANA 网卡][azure-mana]) -- Intel ([VMD 存储控制器][intel-vmd], 网卡: [7][intel-nic-7-sha256], [8][intel-nic-8], [8.1][intel-nic-8.1], [10][intel-nic-10], [11][intel-nic-11], [2008 R2][intel-nic-2008-r2-sha256], [2012][intel-nic-2012], [2012 R2][intel-nic-2012-r2], [2016][intel-nic-2016], [2019][intel-nic-2019], [2022][intel-nic-2022], [2025][intel-nic-2025]) +- Intel ([VMD 存储控制器][intel-vmd], 网卡: [7][intel-nic-7], [8][intel-nic-8], [8.1][intel-nic-8.1], [10][intel-nic-10], [11][intel-nic-11], [2008 R2][intel-nic-2008-r2], [2012][intel-nic-2012], [2012 R2][intel-nic-2012-r2], [2016][intel-nic-2016], [2019][intel-nic-2019], [2022][intel-nic-2022], [2025][intel-nic-2025]) [virtio-virtio]: https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/ [virtio-aliyun]: https://www.alibabacloud.com/help/ecs/user-guide/install-the-virtio-driver-1 @@ -415,13 +415,12 @@ bash reinstall.sh windows \ [gcp-gga]: https://cloud.google.com/compute/docs/instances/enable-instance-virtual-display [azure-mana]: https://learn.microsoft.com/azure/virtual-network/accelerated-networking-mana-windows [intel-vmd]: https://www.intel.com/content/www/us/en/download/849936/intel-rapid-storage-technology-driver-installation-software-with-intel-optane-memory-12th-to-15th-gen-platforms.html -[intel-nic-7-sha1]: https://www.intel.com/content/www/us/en/download/15590/29323/intel-network-adapter-driver-for-windows-7-final-release.html -[intel-nic-7-sha256]: https://www.intel.com/content/www/us/en/download/15590/intel-network-adapter-driver-for-windows-7-final-release.html +[intel-nic-7]: https://www.intel.com/content/www/us/en/download/15590/intel-network-adapter-driver-for-windows-7-final-release.html [intel-nic-8]: https://www.intel.com/content/www/us/en/download/16765/intel-network-adapter-driver-for-windows-8-final-release.html [intel-nic-8.1]: https://www.intel.com/content/www/us/en/download/17479/intel-network-adapter-driver-for-windows-8-1.html [intel-nic-10]: https://www.intel.com/content/www/us/en/download/18293/intel-network-adapter-driver-for-windows-10.html [intel-nic-11]: https://www.intel.com/content/www/us/en/download/727998/intel-network-adapter-driver-for-microsoft-windows-11.html -[intel-nic-2008-r2-sha256]: https://www.intel.com/content/www/us/en/download/15591/intel-network-adapter-driver-for-windows-server-2008-r2-final-release.html +[intel-nic-2008-r2]: https://www.intel.com/content/www/us/en/download/15591/intel-network-adapter-driver-for-windows-server-2008-r2-final-release.html [intel-nic-2012]: https://www.intel.com/content/www/us/en/download/16789/intel-network-adapter-driver-for-windows-server-2012.html [intel-nic-2012-r2]: https://www.intel.com/content/www/us/en/download/17480/intel-network-adapter-driver-for-windows-server-2012-r2.html [intel-nic-2016]: https://www.intel.com/content/www/us/en/download/18737/intel-network-adapter-driver-for-windows-server-2016.html diff --git a/reinstall.sh b/reinstall.sh index a9c8975..86aae8e 100644 --- a/reinstall.sh +++ b/reinstall.sh @@ -58,7 +58,7 @@ Usage: $reinstall_____ anolis 7|8|23 opensuse 15.6|tumbleweed alpine 3.18|3.19|3.20|3.21 openeuler 20.03|22.03|24.03|25.03 - ubuntu 16.04|18.04|20.04|22.04|24.04|24.10 [--minimal] + ubuntu 16.04|18.04|20.04|22.04|24.04|25.04 [--minimal] kali arch gentoo @@ -1204,7 +1204,7 @@ Continue? 20.04) codename=focal ;; 22.04) codename=jammy ;; 24.04) codename=noble ;; - 24.10) codename=oracular ;; # non-lts + 25.04) codename=plucky ;; # non-lts esac if is_use_cloud_image; then @@ -1244,7 +1244,8 @@ Continue? fi eval ${step}_img="$ci_mirror/minimal/releases/$codename/release/ubuntu-$releasever-minimal-cloudimg-$basearch_alt$(get_suffix).img" else - eval ${step}_img="$ci_mirror/releases/$releasever/release/ubuntu-$releasever-server-cloudimg-$basearch_alt$(get_suffix).img" + # 用 codename 而不是 releasever,可减少一次跳转 + eval ${step}_img="$ci_mirror/releases/$codename/release/ubuntu-$releasever-server-cloudimg-$basearch_alt$(get_suffix).img" fi else # 传统安装 @@ -1793,7 +1794,7 @@ verify_os_name() { 'opensuse 15.6|16.0|tumbleweed' \ 'alpine 3.18|3.19|3.20|3.21' \ 'openeuler 20.03|22.03|24.03|25.03' \ - 'ubuntu 16.04|18.04|20.04|22.04|24.04|24.10' \ + 'ubuntu 16.04|18.04|20.04|22.04|24.04|25.04' \ 'kali' \ 'arch' \ 'gentoo' \ From f4e497883f22269632db73b0716c3bc41943ea1c Mon Sep 17 00:00:00 2001 From: bin456789 Date: Mon, 21 Apr 2025 21:32:01 +0800 Subject: [PATCH 044/127] =?UTF-8?q?dd:=20=E4=BF=AE=E5=A4=8D=E9=83=A8?= =?UTF-8?q?=E5=88=86=E9=95=9C=E5=83=8F=E7=B3=BB=E7=BB=9F=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=A4=A7=E5=B0=8F=E5=86=99=E4=B8=8D=E5=90=8C=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- trans.sh | 6 ++-- windows-driver-utils.sh | 68 +++++++++++++++++++++++++++++------------ 2 files changed, 52 insertions(+), 22 deletions(-) diff --git a/trans.sh b/trans.sh index b1c16b6..c440d52 100644 --- a/trans.sh +++ b/trans.sh @@ -2843,9 +2843,9 @@ modify_windows() { if $use_gpo; then # 使用组策略 - gpt_ini=$os_dir/Windows/System32/GroupPolicy/gpt.ini - scripts_ini=$os_dir/Windows/System32/GroupPolicy/Machine/Scripts/scripts.ini + scripts_ini=$(get_path_in_correct_case $os_dir/Windows/System32/GroupPolicy/Machine/Scripts/scripts.ini) mkdir -p "$(dirname $scripts_ini)" + gpt_ini=$(get_path_in_correct_case $os_dir/Windows/System32/GroupPolicy/gpt.ini) # 备份 ini for file in $gpt_ini $scripts_ini; do @@ -2892,7 +2892,7 @@ EOF download $confhome/windows-del-gpo.bat $os_dir/windows-del-gpo.bat else # 使用 SetupComplete - setup_complete=$os_dir/Windows/Setup/Scripts/SetupComplete.cmd + setup_complete=$(get_path_in_correct_case $os_dir/Windows/Setup/Scripts/SetupComplete.cmd) mkdir -p "$(dirname $setup_complete)" # 添加到 C:\Setup\Scripts\SetupComplete.cmd 最前面 diff --git a/windows-driver-utils.sh b/windows-driver-utils.sh index a9fc69c..30ba377 100644 --- a/windows-driver-utils.sh +++ b/windows-driver-utils.sh @@ -115,6 +115,9 @@ list_files_from_inf() { # [Intel.NTamd64.6.0] # ; Empty section. + + # 如果后期改成不从 Manufacturer 获取支持的架构,而是从[]获取支持的架构,注意这种情况 + # [Intel.NTamd64.10.0.1..22000] ############################################## # 例子1 @@ -206,8 +209,7 @@ list_files_from_inf() { dir=$(echo "$line" | awk -F, '{print $4}' | simply_inf_word) # 每行一条记录 if [ -n "$SourceDisksNames" ]; then - SourceDisksNames="$SourceDisksNames -" + SourceDisksNames=$SourceDisksNames$'\n' fi SourceDisksNames="$SourceDisksNames$num:$dir" fi @@ -237,7 +239,11 @@ list_files_from_inf() { done < <(echo "$inf_txts") } -find_file_ignore_case() { +# windows 安装驱动时,只会安装相同架构的驱动文件到系统,即使 inf 里有列出其它架构的驱动 +# 因此 DISM 导出驱动时,也就没有包含其它架构的驱动文件 + +# 用于尽可能匹配路径大小写 +get_path_in_correct_case() { # 同时支持参数和管道 local path path=$({ if [ -n "$1" ]; then echo "$1"; else cat; fi; }) @@ -247,42 +253,66 @@ find_file_ignore_case() { # shellcheck disable=SC2046 set -- $(echo "$path" | grep -o '[^/]*') ( - # windows 安装驱动时,只会安装相同架构的驱动文件到系统,即使 inf 里有列出其它架构的驱动 - # 因此导出驱动时,也就不会包含其它架构的驱动文件 - # 因此这里只警告,不中断脚本 - local output= if is_absolute_path "$path"; then cd / output=/ fi + stop_find=false + while [ $# -gt 0 ]; do local part=$1 + local tmp # shellcheck disable=SC2010 - if part=$(ls -1 | grep -Fix "$part"); then - # 大于 1 表示当前 part 是目录 - if [ $# -gt 1 ]; then - if cd "$part"; then - output="$output$part/" - else - warn "Can't cd $path" - return 1 + if ! $stop_find; then + if tmp=$(ls -1 | grep -Fix "$part"); then + part=$tmp + # 大于 1 表示当前 part 是目录 + if [ $# -gt 1 ]; then + if ! cd "$part" 2>/dev/null; then + warn "Can't cd $path" + stop_find=true + fi fi else - # 最后 part - output="$output$part" + stop_find=true fi + fi + + if [ $# -gt 1 ]; then + output="$output$part/" else - warn "Can't find $path" >&2 - return 1 + # 最后 part + output="$output$part" fi shift done + echo "$output" ) } +is_file_or_link() { + # -e / -f 坏软连接,返回 false + # -L 坏软连接,返回 true + [ -f "$1" ] || [ -L "$1" ] +} + +find_file_ignore_case() { + # 同时支持参数和管道 + local path + path=$({ if [ -n "$1" ]; then echo "$1"; else cat; fi; }) + + path=$(get_path_in_correct_case "$path") + if is_file_or_link "$path"; then + echo "$path" + else + warn "Can't find $path" >&2 + return 1 + fi +} + parse_inf_and_cp_driever() { local inf=$1 local dst=$2 From e09ec4131c27500eccec26c3bfee5e51fe435751 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Tue, 22 Apr 2025 20:52:27 +0800 Subject: [PATCH 045/127] =?UTF-8?q?windows:=20=E4=BF=AE=E5=A4=8D=20install?= =?UTF-8?q?.wim/boot.wim=20=E6=96=87=E4=BB=B6=E5=90=8D=E4=B8=8D=E6=98=AF?= =?UTF-8?q?=E5=85=A8=E5=B0=8F=E5=86=99=E6=97=B6=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- trans.sh | 107 +++++++++++++++++++++++++++++++++---------------------- 1 file changed, 65 insertions(+), 42 deletions(-) diff --git a/trans.sh b/trans.sh index c440d52..a9e7023 100644 --- a/trans.sh +++ b/trans.sh @@ -5289,9 +5289,24 @@ install_windows() { download $iso /os/windows.iso mount -o ro /os/windows.iso /iso + sources_boot_wim=$( + cd /iso + find_file_ignore_case sources/boot.wim 2>/dev/null || + error_and_exit "can't find boot.wim" + ) + + # 一般镜像是 install.wim + # en_server_install_disc_windows_home_server_2011_x64_dvd_658487.iso 是 Install.wim + source_install_wim=$( + cd /iso + { find_file_ignore_case sources/install.wim || + find_file_ignore_case sources/install.esd; } 2>/dev/null || + error_and_exit "can't find install.wim or install.esd" + ) + # 防止用了不兼容架构的 iso - boot_index=$(get_wim_prop /iso/sources/boot.wim 'Boot Index') - arch_wim=$(get_image_prop /iso/sources/boot.wim "$boot_index" 'Architecture' | to_lower) + boot_index=$(get_wim_prop "/iso/$sources_boot_wim" 'Boot Index') + arch_wim=$(get_image_prop "/iso/$sources_boot_wim" "$boot_index" 'Architecture' | to_lower) if ! { { [ "$(uname -m)" = "x86_64" ] && [ "$arch_wim" = x86_64 ]; } || { [ "$(uname -m)" = "x86_64" ] && [ "$arch_wim" = x86 ]; } || @@ -5305,13 +5320,8 @@ install_windows() { error_and_exit "EFI machine can't install 32-bit Windows." fi - if [ -e /iso/sources/install.esd ]; then - iso_install_wim=/iso/sources/install.esd - install_wim=/os/installer/sources/install.esd - else - iso_install_wim=/iso/sources/install.wim - install_wim=/os/installer/sources/install.wim - fi + iso_install_wim=/iso/$source_install_wim + install_wim=/os/installer/$source_install_wim # 匹配映像版本 # 需要整行匹配,因为要区分 Windows 10 Pro 和 Windows 10 Pro for Workstations @@ -5450,7 +5460,7 @@ install_windows() { # 自定义 boot.wim 链接 download "$boot_wim" /os/boot.wim else - cp /iso/sources/boot.wim /os/boot.wim + cp /iso/$sources_boot_wim /os/boot.wim fi # efi 启动目录为 efi 分区 @@ -5464,15 +5474,16 @@ install_windows() { # 复制启动相关的文件 # efi 额外复制efi目录 echo 'Copying boot files...' - cp -r /iso/boot* $boot_dir + cp -r "$(get_path_in_correct_case /iso/boot)"* $boot_dir if is_efi; then echo 'Copying efi files...' - cp -r /iso/efi/ $boot_dir + cp -r "$(get_path_in_correct_case /iso/efi)" $boot_dir fi # 复制iso全部文件(除了boot.wim)到installer分区 echo 'Copying installer files...' if false; then + # 还需忽略大小写 rsync -rv \ --exclude=/sources/boot.wim \ --exclude=/sources/install.wim \ @@ -5482,9 +5493,9 @@ install_windows() { ( cd /iso find . -type f \ - -not -name boot.wim \ - -not -name install.wim \ - -not -name install.esd \ + -not -iname boot.wim \ + -not -iname install.wim \ + -not -iname install.esd \ -exec cp -r --parents {} /os/installer/ \; ) fi @@ -6292,9 +6303,9 @@ EOF cp_drivers() { if [ "$1" = custom ]; then shift - dst="/wim/custom_drivers" + dst=$(get_path_in_correct_case "/wim/custom_drivers") else - dst=/wim/drivers + dst=$(get_path_in_correct_case "/wim/drivers") fi src=$1 @@ -6316,61 +6327,73 @@ EOF add_drivers # win7 要添加 bootx64.efi 到 efi 目录 - [ $arch = amd64 ] && boot_efi=bootx64.efi || boot_efi=bootaa64.efi - if is_efi && [ ! -e /os/boot/efi/efi/boot/$boot_efi ]; then - mkdir -p /os/boot/efi/efi/boot/ - cp /wim/Windows/Boot/EFI/bootmgfw.efi /os/boot/efi/efi/boot/$boot_efi + if is_efi; then + [ $arch = amd64 ] && boot_efi=bootx64.efi || boot_efi=bootaa64.efi + + local src dst + dst=$(get_path_in_correct_case /os/boot/efi/EFI/boot/$boot_efi) + if ! [ -f $dst ]; then + mkdir -p "$(dirname $dst)" + src=$(get_path_in_correct_case /wim/Windows/Boot/EFI/bootmgfw.efi) + cp "$src" "$dst" + fi fi # 复制应答文件 # 移除注释,否则 windows-setup.bat 重新生成的 autounattend.xml 有问题 + wim_autounattend_xml=$(get_path_in_correct_case /wim/autounattend.xml) + wim_windows_xml=$(get_path_in_correct_case /wim/windows.xml) + wim_setup_exe=$(get_path_in_correct_case /wim/setup.exe) + apk add xmlstarlet - xmlstarlet ed -d '//comment()' /tmp/autounattend.xml >/wim/autounattend.xml - unix2dos /wim/autounattend.xml + xmlstarlet ed -d '//comment()' /tmp/autounattend.xml >$wim_autounattend_xml + unix2dos $wim_autounattend_xml info "autounattend.xml" # 查看最终文件,并屏蔽密码 - xmlstarlet ed -d '//*[name()="AdministratorPassword" or name()="Password"]' /wim/autounattend.xml | cat -n + xmlstarlet ed -d '//*[name()="AdministratorPassword" or name()="Password"]' $wim_autounattend_xml | cat -n apk del xmlstarlet # 避免无参数运行 setup.exe 时自动安装 - mv /wim/autounattend.xml /wim/windows.xml + mv $wim_autounattend_xml $wim_windows_xml # 复制安装脚本 # https://slightlyovercomplicated.com/2016/11/07/windows-pe-startup-sequence-explained/ # https://learn.microsoft.com/previous-versions/windows/it-pro/windows-vista/cc721977(v=ws.10) - mv /wim/setup.exe /wim/setup.exe.disabled + mv $wim_setup_exe $wim_setup_exe.disabled # 如果有重复的 Windows/System32 文件夹,会提示找不到 winload.exe 无法引导 # win7 win10 boot.wim 是 Windows/System32,install.wim 是 Windows/System32 # win2016 boot.wim 是 windows/system32,install.wim 是 Windows/System32 # wimmount 无法挂载成忽略大小写 - # shellcheck disable=SC2010 - system32_dir=$(ls -d /wim/*/*32 | grep -i windows/system32) - download $confhome/windows-setup.bat $system32_dir/startnet.cmd + + startnet_cmd=$(get_path_in_correct_case /wim/Windows/System32/startnet.cmd) + winpeshl_ini=$(get_path_in_correct_case /wim/Windows/System32/winpeshl.ini) + + download $confhome/windows-setup.bat $startnet_cmd # dism 手动释放镜像时用 - # sed -i "s|@image_name@|$image_name|" $system32_dir/startnet.cmd + # sed -i "s|@image_name@|$image_name|" "$startnet.cmd" # shellcheck disable=SC2154 if [ "$force_old_windows_setup" = 1 ]; then - sed -i 's/ForceOldSetup=0/ForceOldSetup=1/i' $system32_dir/startnet.cmd + sed -i 's/ForceOldSetup=0/ForceOldSetup=1/i' $startnet_cmd fi # 有 SAC 组件时,启用 EMS if $has_sac; then - sed -i 's/EnableEMS=0/EnableEMS=1/i' $system32_dir/startnet.cmd + sed -i 's/EnableEMS=0/EnableEMS=1/i' $startnet_cmd fi # Windows Thin PC 有 Windows\System32\winpeshl.ini # [LaunchApps] # %SYSTEMDRIVE%\windows\system32\drvload.exe, %SYSTEMDRIVE%\windows\inf\sdbus.inf # %SYSTEMDRIVE%\setup.exe - if [ -f $system32_dir/winpeshl.ini ]; then + if [ -f "$winpeshl_ini" ]; then info "mod winpeshl.ini" # https://learn.microsoft.com/previous-versions/windows/it-pro/windows-vista/cc721977(v=ws.10) # 两种方法都可以,第一种是原版命令 - sed -i 's|setup.exe|windows\\system32\\cmd.exe, "/k %SYSTEMROOT%\\system32\\startnet.cmd"|i' $system32_dir/winpeshl.ini - # sed -i 's|setup.exe|windows\\system32\\startnet.cmd|i' $system32_dir/winpeshl.ini - cat -n $system32_dir/winpeshl.ini + sed -i 's|setup.exe|windows\\system32\\cmd.exe, "/k %SYSTEMROOT%\\system32\\startnet.cmd"|i' "$winpeshl_ini" + # sed -i 's|setup.exe|windows\\system32\\startnet.cmd|i' "$winpeshl_ini" + cat -n "$winpeshl_ini" fi # 提交修改 boot.wim @@ -6382,7 +6405,6 @@ EOF # wimoptimize /os/boot.wim # 优化 boot.wim 并复制到正确的位置 - mkdir -p $boot_dir/sources/ if is_nt_ver_ge 6.1; then # win7 或以上删除 boot.wim 镜像 1 不会报错 # 因为 win7 winre 镜像在 install.wim Windows\System32\Recovery\winRE.wim @@ -6395,17 +6417,18 @@ EOF # vista install.wim 没有 Windows\System32\Recovery\winRE.wim images=all fi - wimexport --boot /os/boot.wim "$images" $boot_dir/sources/boot.wim + mkdir -p "$(get_path_in_correct_case "$(dirname $boot_dir/$sources_boot_wim)")" + wimexport --boot /os/boot.wim "$images" $boot_dir/$sources_boot_wim info "boot.wim size" - echo "Original: $(get_filesize_mb /iso/sources/boot.wim)" + echo "Original: $(get_filesize_mb /iso/$sources_boot_wim)" echo "Added Drivers: $(get_filesize_mb /os/boot.wim)" - echo "Optimized: $(get_filesize_mb "$boot_dir/sources/boot.wim")" + echo "Optimized: $(get_filesize_mb "$boot_dir/$sources_boot_wim")" echo # vista 安装时需要 boot.wim,原因见上面 if [ "$nt_ver" = 6.0 ] && - ! [ -e /os/installer/sources/boot.wim ]; then - cp $boot_dir/sources/boot.wim /os/installer/sources/boot.wim + ! [ -e /os/installer/$sources_boot_wim ]; then + cp $boot_dir/$sources_boot_wim /os/installer/$sources_boot_wim fi # windows 7 没有 invoke-webrequest From dd5df4da89d1375ba4a49a5a571b1e756ed4b889 Mon Sep 17 00:00:00 2001 From: MkQtS <81752398+MkQtS@users.noreply.github.com> Date: Thu, 24 Apr 2025 20:41:28 +0800 Subject: [PATCH 046/127] trans.sh: fix typo (#323) --- trans.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trans.sh b/trans.sh index a9e7023..421f8a4 100644 --- a/trans.sh +++ b/trans.sh @@ -3693,7 +3693,7 @@ change_ssh_conf() { allow_password_login() { os_dir=$1 - change_ssh_conf "$os_dir" PasswordAuthentication yes 01-PasswordAuthenticaton.conf + change_ssh_conf "$os_dir" PasswordAuthentication yes 01-PasswordAuthentication.conf } allow_root_password_login() { From 3f1d5ce9fa00929316fc340b646e9e1837d5151a Mon Sep 17 00:00:00 2001 From: bin456789 Date: Fri, 25 Apr 2025 23:23:49 +0800 Subject: [PATCH 047/127] =?UTF-8?q?ubuntu:=2025.04=20=E8=BF=98=E8=A6=81?= =?UTF-8?q?=E5=8D=B8=E8=BD=BD=20cloud-init-base?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- trans.sh | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/trans.sh b/trans.sh index 421f8a4..e46d524 100644 --- a/trans.sh +++ b/trans.sh @@ -3052,11 +3052,17 @@ remove_cloud_init() { if false && [ -d $os_dir/etc/cloud ]; then touch $os_dir/etc/cloud/cloud-init.disabled fi - for name in cloud-init-local cloud-init cloud-config cloud-final; do - for type in service socket; do - # 服务不存在时会报错 - chroot $os_dir systemctl disable "$name.$type" 2>/dev/null || true - done + + # systemctl is-enabled cloud-init-hotplugd.service 状态是 static + # disable 会出现一堆提示信息,也无法 disable + for unit in $( + chroot $os_dir systemctl list-unit-files | + grep -E '^(cloud-init-.*|cloud-config|cloud-final)\.(service|socket)' | grep enabled | awk '{print $1}' + ); do + # 服务不存在时会报错 + if chroot $os_dir systemctl -q is-enabled "$unit"; then + chroot $os_dir systemctl disable "$unit" + fi done for pkg_mgr in dnf yum zypper apt-get; do @@ -3070,7 +3076,8 @@ remove_cloud_init() { chroot $os_dir zypper remove -y -u cloud-init ;; apt-get) - chroot_apt_remove $os_dir cloud-init + # ubuntu 25.04 开始有 cloud-init-base + chroot_apt_remove $os_dir cloud-init cloud-init-base chroot_apt_autoremove $os_dir ;; esac From bbf78e6d9ac9eb0d17986e81ab537ddfbfe1498a Mon Sep 17 00:00:00 2001 From: bin456789 Date: Mon, 28 Apr 2025 23:18:27 +0800 Subject: [PATCH 048/127] =?UTF-8?q?core:=20=E6=B7=BB=E5=8A=A0=20frpc=20?= =?UTF-8?q?=E5=86=85=E7=BD=91=E7=A9=BF=E9=80=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .editorconfig | 6 +- README.en.md | 12 ++-- README.md | 10 ++- debian.cfg | 17 +++++ frpc-example.toml | 24 +++++++ frpc.service | 17 +++++ get-frpc-url.sh | 96 +++++++++++++++++++++++++ initrd-network.sh | 5 +- reinstall.sh | 44 ++++++++++-- trans.sh | 136 ++++++++++++++++++++++++++++++++---- windows-frpc-workaround.bat | 18 +++++ windows-frpc.bat | 39 +++++++++++ windows-frpc.xml | Bin 0 -> 3156 bytes 13 files changed, 397 insertions(+), 27 deletions(-) create mode 100644 frpc-example.toml create mode 100644 frpc.service create mode 100644 get-frpc-url.sh create mode 100644 windows-frpc-workaround.bat create mode 100644 windows-frpc.bat create mode 100644 windows-frpc.xml diff --git a/.editorconfig b/.editorconfig index f5df4e8..403a682 100644 --- a/.editorconfig +++ b/.editorconfig @@ -8,9 +8,13 @@ charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true -[windows.xml] +[{windows.xml,windows-*.xml}] end_of_line = crlf +[windows-frpc.xml] +charset = utf-16-le +indent_size = 2 + [*.{bat,cmd,ps1}] end_of_line = crlf diff --git a/README.en.md b/README.en.md index 9192f47..e50f003 100644 --- a/README.en.md +++ b/README.en.md @@ -34,7 +34,7 @@ The system requirements for the target system are as follows: | Alpine | 3.18, 3.19, 3.20, 3.21 | 256 MB | 1 GB | | Debian | 9, 10, 11, 12 | 256 MB | 1 ~ 1.5 GB ^ | | Kali | Rolling | 256 MB | 1 ~ 1.5 GB ^ | -| Ubuntu | 16.04 LTS - 24.04 LTS, 25.04 | 512 MB \* | 2 GB | +| Ubuntu | 16.04 LTS - 24.04 LTS, 25.04 | 512 MB \* | 2 GB | | Anolis | 7, 8, 23 | 512 MB \* | 5 GB | | RHEL   AlmaLinux   Rocky   Oracle | 8, 9 | 512 MB \* | 5 GB | | OpenCloudOS | 8, 9, Stream 23 | 512 MB \* | 5 GB | @@ -42,7 +42,7 @@ The system requirements for the target system are as follows: | Fedora | 41, 42 | 512 MB \* | 5 GB | | openEuler | 20.03 LTS - 24.03 LTS, 25.03 | 512 MB \* | 5 GB | | openSUSE | Leap 15.6, Tumbleweed (Rolling) | 512 MB \* | 5 GB | -| NixOS | 24.11 | 512 MB | 5 GB | +| NixOS | 24.11 | 512 MB | 5 GB | | Arch | Rolling | 512 MB | 5 GB | | Gentoo | Rolling | 512 MB | 5 GB | | AOSC OS | Rolling | 512 MB | 5 GB | @@ -160,6 +160,7 @@ bash reinstall.sh anolis 7|8|23 - `--ssh-key C:\path\to\public_key` - `--ssh-port PORT` Change the SSH port (for log observation during installation and for the new system) - `--web-port PORT` Change the Web port (for log observation during installation) +- `--frpc-toml /path/to/frpc.toml` Add frpc for intranet tunneling - `--hold 2` Prevent reboot after installation completes, allowing SSH login to modify system content; the system is mounted at `/os` (this feature is not supported on Debian/Kali). > [!TIP] @@ -212,10 +213,11 @@ bash reinstall.sh dd --img "https://example.com/xxx.xz" #### Optional parameters -- `--allow-ping` Allow ping responses (DD Windows only) +- `--allow-ping` Configure Windows Firewall to Allow Ping Responses (DD Windows only) - `--rdp-port PORT` Change RDP port (DD Windows only) - `--ssh-port PORT` Change SSH port (for log observation during installation) - `--web-port PORT` Change Web port (for log observation during installation) +- `--frpc-toml /path/to/frpc.toml` Add frpc for intranet tunneling (DD Windows only) - `--hold 2` Prevent reboot after the DD process finishes, allowing SSH login to modify system content. The Windows system will be mounted at `/os`, but Linux systems will **NOT** be automatically mounted. > [!TIP] @@ -245,6 +247,7 @@ bash reinstall.sh alpine --hold=1 - `--ssh-key gitlab:your_username` - `--ssh-key /path/to/public_key` - `--ssh-key C:\path\to\public_key` +- `--frpc-toml /path/to/frpc.toml` Add frpc for intranet tunneling ### Feature 4: Reboot to netboot.xyz @@ -384,13 +387,14 @@ bash reinstall.sh windows \ #### Optional parameters - `--password PASSWORD` Set Password -- `--allow-ping` Configures the Windows firewall to allow ping requests +- `--allow-ping` Configure Windows Firewall to Allow Ping Responses - `--rdp-port PORT` Change RDP port - `--ssh-port PORT` Change SSH port (for log observation during installation) - `--web-port PORT` Change Web port (for log observation during installation) - `--add-driver INF_OR_DIR` Add additional driver, specifying .inf path, or the folder contains .inf file. - The driver must be downloaded locally first. - This parameter can be set multiple times to add different driver. +- `--frpc-toml /path/to/frpc.toml` Add frpc for intranet tunneling - `--hold 2` Allow SSH connections for modifying the disk content before rebooting into the official Windows installation program, with the disk mounted at `/os`. #### The following drivers will automatic download and install as needed, without the need for manual addition diff --git a/README.md b/README.md index d34f4d1..af7c6c5 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ | Alpine | 3.18, 3.19, 3.20, 3.21 | 256 MB | 1 GB | | Debian | 9, 10, 11, 12 | 256 MB | 1 ~ 1.5 GB ^ | | Kali | 滚动 | 256 MB | 1 ~ 1.5 GB ^ | -| Ubuntu | 16.04 LTS - 24.04 LTS, 25.04 | 512 MB \* | 2 GB | +| Ubuntu | 16.04 LTS - 24.04 LTS, 25.04 | 512 MB \* | 2 GB | | Anolis | 7, 8, 23 | 512 MB \* | 5 GB | | RHEL   AlmaLinux   Rocky   Oracle | 8, 9 | 512 MB \* | 5 GB | | OpenCloudOS | 8, 9, Stream 23 | 512 MB \* | 5 GB | @@ -42,7 +42,7 @@ | Fedora | 41, 42 | 512 MB \* | 5 GB | | openEuler | 20.03 LTS - 24.03 LTS, 25.03 | 512 MB \* | 5 GB | | openSUSE | Leap 15.6, Tumbleweed (滚动) | 512 MB \* | 5 GB | -| NixOS | 24.11 | 512 MB | 5 GB | +| NixOS | 24.11 | 512 MB | 5 GB | | Arch | 滚动 | 512 MB | 5 GB | | Gentoo | 滚动 | 512 MB | 5 GB | | 安同 OS | 滚动 | 512 MB | 5 GB | @@ -160,6 +160,7 @@ bash reinstall.sh anolis 7|8|23 - `--ssh-key C:\path\to\public_key` - `--ssh-port PORT` 修改 SSH 端口(安装期间观察日志用,也作用于新系统) - `--web-port PORT` 修改 Web 端口(安装期间观察日志用) +- `--frpc-toml /path/to/frpc.toml` 添加 frpc 内网穿透 - `--hold 2` 安装结束后不重启,此时可以 SSH 登录修改系统内容,系统挂载在 `/os` (此功能不支持 Debian/Kali) > [!TIP] @@ -212,10 +213,11 @@ bash reinstall.sh dd --img "https://example.com/xxx.xz" #### 可选参数 -- `--allow-ping` 允许被 Ping (仅限 DD Windows) +- `--allow-ping` 设置 Windows 防火墙允许被 Ping (仅限 DD Windows) - `--rdp-port PORT` 修改 RDP 端口 (仅限 DD Windows) - `--ssh-port PORT` 修改 SSH 端口(安装期间观察日志用) - `--web-port PORT` 修改 Web 端口(安装期间观察日志用) +- `--frpc-toml /path/to/frpc.toml` 添加 frpc 内网穿透(仅限 DD Windows) - `--hold 2` DD 结束后不重启,此时可以 SSH 登录修改系统内容,Windows 系统会挂载在 `/os`,Linux 系统**不会**自动挂载 > [!TIP] @@ -245,6 +247,7 @@ bash reinstall.sh alpine --hold=1 - `--ssh-key gitlab:your_username` - `--ssh-key /path/to/public_key` - `--ssh-key C:\path\to\public_key` +- `--frpc-toml /path/to/frpc.toml` 添加 frpc 内网穿透 ### 功能 4: 重启到 netboot.xyz @@ -391,6 +394,7 @@ bash reinstall.sh windows \ - `--add-driver INF_OR_DIR` 添加额外驱动,填写 .inf 路径,或者 .inf 所在的文件夹 - 需先下载驱动到本地 - 可多次设置该参数以添加不同的驱动 +- `--frpc-toml /path/to/frpc.toml` 添加 frpc 内网穿透 - `--hold 2` 在进入 Windows 官方安装程序之前,可以 SSH 登录修改硬盘内容,硬盘挂载在 `/os` #### 以下驱动会自动按需下载安装,无需手动添加 diff --git a/debian.cfg b/debian.cfg index e30e4d9..80047ba 100644 --- a/debian.cfg +++ b/debian.cfg @@ -164,6 +164,7 @@ d-i partman/early_command string true; \ # kali ssh 默认关闭 # 另一种方法处理 cloudcone # if [ "$link_grub_dir" = 1 ]; then mkdir /target/boot/grub2; echo 'chainloader (hd0)+1' >/target/boot/grub2/grub.cfg; fi; \ +# debian 9 tar 不支持 --strip-components d-i preseed/late_command string true; \ for str in $(grep -wo "extra_[^ ]*" /proc/cmdline | sed 's/^extra_//'); do eval "$str"; done; \ @@ -186,6 +187,22 @@ d-i preseed/late_command string true; \ echo "Port $ssh_port" >>/target/etc/ssh/sshd_config; \ fi; \ + if [ -s /configs/frpc.toml ]; then \ + url=$(sh /get-frpc-url.sh linux); \ + basename=$(echo "$url" | sed 's,.*/,,' | sed 's,\.tar\.gz,,'); \ + mkdir -p /target/usr/local/bin; \ + mkdir -p /target/usr/local/etc/frpc; \ + for i in {1..5}; do \ + wget -O /target/frpc.tar.gz "$url" && break; \ + done; \ + tar xzf /target/frpc.tar.gz "$basename/frpc" -O >/target/usr/local/bin/frpc; \ + rm -f /target/frpc.tar.gzx; \ + chmod a+x /target/usr/local/bin/frpc; \ + cp /configs/frpc.toml /target/usr/local/etc/frpc/; \ + cp /frpc.service /target/etc/systemd/system/; \ + in-target systemctl enable frpc; \ + fi; \ + cp /fix-eth-name.sh /target/; \ cp /fix-eth-name.service /target/etc/systemd/system/; \ in-target systemctl enable fix-eth-name diff --git a/frpc-example.toml b/frpc-example.toml new file mode 100644 index 0000000..f549500 --- /dev/null +++ b/frpc-example.toml @@ -0,0 +1,24 @@ +serverAddr = "YOUR_FRP_SERVER_IP" +serverPort = 7000 +auth.token = "YOUR_FRP_TOKEN" + +[[proxies]] +name = "ssh" +type = "tcp" +localIP = "127.0.0.1" +localPort = 22 +remotePort = 2222 + +[[proxies]] +name = "rdp_tcp" +type = "tcp" +localIP = "127.0.0.1" +localPort = 3389 +remotePort = 33890 + +[[proxies]] +name = "rdp_udp" +type = "udp" +localIP = "127.0.0.1" +localPort = 3389 +remotePort = 33890 diff --git a/frpc.service b/frpc.service new file mode 100644 index 0000000..ba56d04 --- /dev/null +++ b/frpc.service @@ -0,0 +1,17 @@ +# https://github.com/archlinuxcn/repo/blob/master/archlinuxcn/frp/frpc.service + +[Unit] +Description=Frp Client Service +After=network-online.target +Wants=network-online.target + +[Service] +Type=simple +User=nobody +Restart=on-failure +RestartSec=5s +ExecStart=/usr/local/bin/frpc -c /usr/local/etc/frpc/frpc.toml +ExecReload=/usr/local/bin/frpc reload -c /usr/local/etc/frpc/frpc.toml + +[Install] +WantedBy=multi-user.target diff --git a/get-frpc-url.sh b/get-frpc-url.sh new file mode 100644 index 0000000..edc4ce0 --- /dev/null +++ b/get-frpc-url.sh @@ -0,0 +1,96 @@ +#!/bin/ash +# shellcheck shell=dash +# trans.sh/debian.cfg 共用此脚本 + +# debian 9 不支持 set -E +set -e + +is_in_china() { + grep -q 1 /dev/netconf/*/is_in_china +} + +is_ipv6_only() { + ! grep -q 1 /dev/netconf/eth*/ipv4_has_internet +} + +get_frpc_url() { + # 传入 windows 或者 linux + local os_type=$1 + local nt_ver=$2 + + is_need_old_version() { + [ "$nt_ver" = "6.0" ] || [ "$nt_ver" = "6.1" ] + } + + version=$( + if is_need_old_version; then + echo 0.54.0 + else + # debian 11 initrd 没有 xargs awk + # debian 12 initrd 没有 xargs + # github 不支持 ipv6 + if is_in_china || is_ipv6_only; then + wget -O- https://mirrors.nju.edu.cn/github-release/fatedier/frp/LatestRelease/frp_sha256_checksums.txt | + grep -m1 frp_ | cut -d_ -f2 + else + # https://api.github.com/repos/fatedier/frp/releases/latest 有请求次数限制 + + # root@localhost:~# wget --spider -S https://github.com/fatedier/frp/releases/latest 2>&1 | grep Location: + # Location: https://github.com/fatedier/frp/releases/tag/v0.62.0 + # Location: https://github.com/fatedier/frp/releases/tag/v0.62.0 [following] # 原版 wget 多了这行 + + wget --spider -S https://github.com/fatedier/frp/releases/latest 2>&1 | + grep -m1 '^ Location:' | sed 's,.*/tag/v,,' + fi + fi + ) + + if [ -z "$version" ]; then + echo 'cannot find version' + return 1 + fi + + suffix=$( + case "$os_type" in + linux) echo tar.gz ;; + windows) echo zip ;; + esac + ) + + mirror=$( + # nju 没有 win7 用的旧版 + # github 不支持 ipv6 + # jsdelivr 不支持 github releases 文件 + if is_ipv6_only; then + if is_need_old_version; then + echo 'NOT_SUPPORT' + return 1 + else + echo https://mirrors.nju.edu.cn/github-release/fatedier/frp + fi + else + if is_in_china; then + if is_need_old_version; then + echo https://github.com/fatedier/frp/releases/download + else + echo https://mirrors.nju.edu.cn/github-release/fatedier/frp + fi + else + echo https://github.com/fatedier/frp/releases/download + fi + fi + ) + + arch=$( + case "$(uname -m)" in + x86_64) echo amd64 ;; + aarch64) echo arm64 ;; + esac + ) + + filename=frp_${version}_${os_type}_${arch}.$suffix + + echo "${mirror}/v${version}/${filename}" +} + +get_frpc_url "$@" diff --git a/initrd-network.sh b/initrd-network.sh index cce3e91..a5918c7 100644 --- a/initrd-network.sh +++ b/initrd-network.sh @@ -1,6 +1,6 @@ #!/bin/ash # shellcheck shell=dash -# alpine / debian initrd 共用此脚本 +# alpine/debian initrd 共用此脚本 # accept_ra 接收 RA + 自动配置网关 # autoconf 自动配置地址,依赖 accept_ra @@ -288,6 +288,9 @@ fi echo "Configuring $ethx ($mac_addr)..." +# 不开启 lo 则 frp 无法连接 127.0.0.1 22 +ip link set dev lo up + # 开启 ethx ip link set dev "$ethx" up sleep 1 diff --git a/reinstall.sh b/reinstall.sh index 86aae8e..f74c2d6 100644 --- a/reinstall.sh +++ b/reinstall.sh @@ -69,12 +69,17 @@ Usage: $reinstall_____ anolis 7|8|23 windows --image-name="windows xxx yyy" --iso="http://xxx.com/xxx.iso" netboot.xyz - Options: [--password PASSWORD] - [--ssh-key KEY] - [--ssh-port PORT] - [--rdp-port PORT] - [--web-port PORT] + Options: For Linux/Windows: + [--password PASSWORD] + [--ssh-key KEY] + [--ssh-port PORT] + [--web-port PORT] + [--frpc-toml TOML] + + For Windows Only: [--allow-ping] + [--rdp-port PORT] + [--add-driver INF_OR_DIR] Manual: https://github.com/bin456789/reinstall @@ -3148,11 +3153,15 @@ EOF curl -LO "$confhome/fix-eth-name.sh" curl -LO "$confhome/fix-eth-name.service" - # 最近 kali initrd 删除了原版 wget + # 有段时间 kali initrd 删除了原版 wget # 但 initrd 的 busybox wget 又不支持 https # 因此改成在这里下载 curl -LO "$confhome/get-xda.sh" curl -LO "$confhome/ttys.sh" + if [ -n "$frpc_config" ]; then + curl -LO "$confhome/get-frpc-url.sh" + curl -LO "$confhome/frpc.service" + fi # 可以节省一点内存? echo 'export DEBCONF_DROP_TRANSLATIONS=1' | @@ -3522,6 +3531,9 @@ This script is outdated, please download reinstall.sh again. else save_password $initrd_dir/configs fi + if [ -n "$frpc_config" ]; then + cat "$frpc_config" >$initrd_dir/configs/frpc.toml + fi if is_distro_like_debian $nextos_distro; then mod_initrd_debian_kali @@ -3690,6 +3702,7 @@ for o in ci installer debug minimal allow-ping force-cn help \ web-port: http-port: \ allow-ping: \ commit: \ + frpc-conf: frpc-config: frpc-toml: \ force: \ force-old-windows-setup:; do [ -n "$long_opts" ] && long_opts+=, @@ -3744,6 +3757,25 @@ while true; do error_and_exit "Invalid $1 value: $2" fi hold=$2 + shift 2 + ;; + --frpc-conf | --frpc-config | --frpc-toml) + [ -n "$2" ] || error_and_exit "Need value for $1" + + # windows 路径转换 + frpc_config=$(get_unix_path "$2") + + # alpine busybox 不支持 readlink -m + # readlink -m /asfsafasfsaf/fasf + # 因此需要先判断路径是否存在 + + if ! [ -f "$frpc_config" ]; then + error_and_exit "Not a toml file: $2" + fi + + # 转为绝对路径 + frpc_config=$(readlink -f "$frpc_config") + shift 2 ;; --force) diff --git a/trans.sh b/trans.sh index e46d524..c22e2b5 100644 --- a/trans.sh +++ b/trans.sh @@ -331,7 +331,7 @@ get_ttys() { find_xda() { # 出错后再运行脚本,硬盘可能已经格式化,之前记录的分区表 id 无效 - # 因此找到 xda 后要保存 xda 到 /config/xda + # 因此找到 xda 后要保存 xda 到 /configs/xda # 先读取之前保存的 if xda=$(get_config xda 2>/dev/null) && [ -n "$xda" ]; then @@ -1401,6 +1401,15 @@ install_alpine() { chmod +x /os/etc/init.d/fix-eth-name chroot /os rc-update add fix-eth-name boot + # 安装 frpc + if [ -s /configs/frpc.toml ]; then + chroot /os apk add frp + # chroot rc-update add 默认添加到 sysinit + # 但不加 chroot 默认添加到 default + chroot /os rc-update add frpc boot + cp /configs/frpc.toml /os/etc/frp/frpc.toml + fi + # 安装固件微码会触发 grub-probe # 如果没挂载会报错 # Executing grub-2.12-r5.trigger @@ -1480,7 +1489,8 @@ install_nixos() { show_nixos_config() { echo - cat -n /os/etc/nixos/configuration.nix + # 过滤 frp auth.token + cat -n /os/etc/nixos/configuration.nix | grep -Fv 'auth.token' echo cat -n /os/etc/nixos/hardware-configuration.nix echo @@ -1549,7 +1559,7 @@ install_nixos() { sh=https://nixos.org/nix/install fi apk add xz - wget -O- "$sh" | sh -s -- --no-channel-add + wget -O- "$sh" | sh -s -- --no-daemon --no-channel-add apk del xz # shellcheck source=/dev/null . /root/.nix-profile/etc/profile.d/nix.sh @@ -1605,6 +1615,22 @@ $(del_comment_lines "$os_dir/usr/lib/systemd/system-preset/01-fix-eth-name.preset" + echo "enable $service_name.service" >"$os_dir/usr/lib/systemd/system-preset/01-$service_name.preset" else - echo 'enable fix-eth-name.service' >"$os_dir/lib/systemd/system-preset/01-fix-eth-name.preset" + echo "enable $service_name.service" >"$os_dir/lib/systemd/system-preset/01-$service_name.preset" + fi +} + +add_fix_eth_name_systemd_service() { + local os_dir=$1 + + # 无需执行 systemctl daemon-reload + # 因为 chroot 下执行会提示 Running in chroot, ignoring command 'daemon-reload' + download "$confhome/fix-eth-name.sh" "$os_dir/fix-eth-name.sh" + add_systemd_service "$os_dir" fix-eth-name +} + +get_frpc_url() { + wget "$confhome/get-frpc-url.sh" -O- | sh -s "$@" +} + +add_frpc_systemd_service_if_need() { + local os_dir=$1 + + if [ -s /configs/frpc.toml ]; then + mkdir -p "$os_dir/usr/local/bin" + mkdir -p "$os_dir/usr/local/etc/frpc" + + # 下载 frpc + # 注意下载的 frpc owner 不是 root:root + frpc_url=$(get_frpc_url linux) + basename=$(echo "$frpc_url" | awk -F/ '{print $NF}' | sed 's/\.tar\.gz//') + download "$frpc_url" "$os_dir/frpc.tar.gz" + tar xzf "$os_dir/frpc.tar.gz" "$basename/frpc" -O >"$os_dir/usr/local/bin/frpc" + rm -f "$os_dir/frpc.tar.gz" + chmod a+x "$os_dir/usr/local/bin/frpc" + + # frpc conf + cp /configs/frpc.toml "$os_dir/usr/local/etc/frpc/frpc.toml" + + # 添加服务 + add_systemd_service "$os_dir" frpc fi } @@ -1775,6 +1837,9 @@ basic_init() { # 即使开了 net.ifnames=0 也需要 # 因为 alpine live 和目标系统的网卡顺序可能不同 add_fix_eth_name_systemd_service $os_dir + + # frpc + add_frpc_systemd_service_if_need $os_dir } install_arch_gentoo_aosc() { @@ -2841,6 +2906,28 @@ modify_windows() { bats="$bats windows-set-netconf-$ethx.bat" done + # 5 frp + if [ -s /configs/frpc.toml ]; then + # 好像 win7 无法运行 frpc,暂时不管 + windows_arch=$(get_windows_arch_from_windows_drive "$os_dir" | to_lower) + if [ "$windows_arch" = amd64 ] || [ "$windows_arch" = arm64 ]; then + mkdir -p "$os_dir/frpc/" + url=$(get_frpc_url windows "$nt_ver") + download "$url" $os_dir/frpc/frpc.zip + # -j 去除文件夹 + # -C 筛选文件时不区分大小写,但 busybox zip 不支持 + unzip -o -j "$os_dir/frpc/frpc.zip" '*/frpc.exe' -d "$os_dir/frpc/" + rm -f "$os_dir/frpc/frpc.zip" + cp -f /configs/frpc.toml "$os_dir/frpc/frpc.toml" + download "$confhome/windows-frpc.xml" "$os_dir/frpc/frpc.xml" + download "$confhome/windows-frpc.bat" "$os_dir/frpc/frpc.bat" + download "$confhome/windows-frpc-workaround.bat" "$os_dir/frpc/frpc-workaround.bat" + bats="$bats frpc\frpc.bat" + else + warn "$windows_arch Not Support frpc" + fi + fi + if $use_gpo; then # 使用组策略 scripts_ini=$(get_path_in_correct_case $os_dir/Windows/System32/GroupPolicy/Machine/Scripts/scripts.ini) @@ -2911,6 +2998,9 @@ EOF # cat 可以保留权限 cat $setup_complete_mod >$setup_complete + + # 查看最终内容 + cat -n $setup_complete fi } @@ -5268,6 +5358,16 @@ get_installation_type_from_windows_drive() { apk del hivex } +get_windows_arch_from_windows_drive() { + local os_dir=$1 + + apk add hivex + hive=$(find_file_ignore_case $os_dir/Windows/System32/config/SYSTEM) + # 没有 CurrentControlSet + hivexget $hive 'ControlSet001\Control\Session Manager\Environment' PROCESSOR_ARCHITECTURE + apk del hivex +} + install_windows() { get_wim_prop() { wim=$1 @@ -6866,6 +6966,18 @@ else printf '\nyes' | setup-sshd fi +# 设置 frpc +# 并防止重复运行 +if [ -s /configs/frpc.toml ] && ! pidof frpc >/dev/null; then + info 'run frpc' + add_community_repo + apk add frp + while true; do + frpc -c /configs/frpc.toml || true + sleep 5 + done & +fi + # shellcheck disable=SC2154 if [ "$hold" = 1 ]; then if is_run_from_locald; then diff --git a/windows-frpc-workaround.bat b/windows-frpc-workaround.bat new file mode 100644 index 0000000..d1ba31e --- /dev/null +++ b/windows-frpc-workaround.bat @@ -0,0 +1,18 @@ +@echo off +mode con cp select=437 >nul + +rem 如果找到 LOCAL SERVICE 运行的 frpc,则结束 SYSTEM 运行的 frpc +rem 如果没找到 frpc,则运行 frpc(本脚本是用 SYSTEM 运行,好像无法 runas "NT AUTHORITY\LOCAL SERVICE") + +rem tasklist 返回值始终为 0,因此需要用 findstr + +:loop +tasklist /FI "IMAGENAME eq frpc.exe" /FI "USERNAME eq NT AUTHORITY\LOCAL SERVICE" | findstr /I "frpc.exe" && goto :kill_system_frpc +tasklist /FI "IMAGENAME eq frpc.exe" | findstr /I "frpc.exe" || start %SystemDrive%\frpc\frpc.exe -c %SystemDrive%\frpc\frpc.toml +timeout 5 +goto :loop + +:kill_system_frpc +taskkill /F /T /FI "IMAGENAME eq frpc.exe" /FI "USERNAME eq NT AUTHORITY\SYSTEM" + +del "%~f0" diff --git a/windows-frpc.bat b/windows-frpc.bat new file mode 100644 index 0000000..afb1ca2 --- /dev/null +++ b/windows-frpc.bat @@ -0,0 +1,39 @@ +@echo off +mode con cp select=437 >nul + +rem Windows Deferder 会误报,因此要添加白名单 +powershell -ExecutionPolicy Bypass -Command "Add-MpPreference -ExclusionPath '%SystemDrive%\frpc\frpc.exe'" + +rem ---------- DEBUG ---------- +rem 检查服务状态 +rem sc query Schedule >%SystemDrive%\x.txt 2>&1 + +rem 启用日志 +rem wevtutil set-log Microsoft-Windows-TaskScheduler/Operational /enabled:true +rem ---------- DEBUG ---------- + +rem 创建计划任务并立即运行 +schtasks /Create /TN "frpc" /XML "%SystemDrive%\frpc\frpc.xml" +schtasks /Run /TN "frpc" +del "%SystemDrive%\frpc\frpc.xml" + +rem win11 在首次登录后计划任务才生效 +rem 即使手动重启,计划任务也没有运行 + +rem 如果 10 秒内有 frpc 进程,则代表计划任务已经生效,不需要首次登录 +rem 如果 10 秒后也没有 frpc 进程,则需要运行 frpc-workaround.bat +for /L %%i in (1,1,10) do ( + timeout 1 + tasklist /FI "IMAGENAME eq frpc.exe" | find /I "frpc.exe" && ( + del "%SystemDrive%\frpc\frpc-workaround.bat" + goto :end + ) +) + +rem 后台运行 frpc-workaround.bat +rem 需要加 cmd /c,不然 frpc-workaround.bat 结束后有 cmd 窗口残留 +start cmd /c "%SystemDrive%\frpc\frpc-workaround.bat" + +:end +rem 删除此脚本 +del "%~f0" diff --git a/windows-frpc.xml b/windows-frpc.xml new file mode 100644 index 0000000000000000000000000000000000000000..d8bb0c0e79d760bff986cc9ad056d75a6ce8ca4e GIT binary patch literal 3156 zcmbW3+fQ0S5XR@ZN&g38;-jFZm)KAYR;?u3Hj443FBA}oTnymtpKts7b~thO97HrH zc#d=V=9}4>-Tn8sYPJvxQ{{= zyY>V9eaPdrC~21apije^4nV$#v*J(q+h7uY5^s4;+&cC3%#T9e9VS7UYG=~KDeru~tNEmHp6YrLcEFL<>C_fc2K@E8 zPN#Y`k2H$+w5m3sV^mA^$&7W?>|HO6nXctq5K<1BVa?g{?)M4ER!)pFKka7P;Zk19 zEaUjuZlLMOIypwqRx%QMHVT>0XLm4d!$Yo zKjoXehsch@yN|raUfSg5a5g_NSMf-r_-UXy5}x+s&jG6_PyLD=c1X^e`&+QIyTtb1 zzd8wg$JHL8(@gBQ>?A}iYKsWpsHaXuWxf+0b#N?=eWY8Rr>vi!0rh{IxV{oo?oEp7 z`8*)kt#H|mpvry5S7%XWgf)z&XdNbxVS+VV`(br-16Yr4a!+@ Date: Tue, 29 Apr 2025 09:05:09 +0800 Subject: [PATCH 049/127] =?UTF-8?q?fnos:=20=E6=B7=BB=E5=8A=A0=20frpc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- trans.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/trans.sh b/trans.sh index c22e2b5..4cecfca 100644 --- a/trans.sh +++ b/trans.sh @@ -4256,6 +4256,9 @@ install_fnos() { # 修正网卡名 add_fix_eth_name_systemd_service $os_dir + + # frpc + add_frpc_systemd_service_if_need $os_dir } install_qcow_by_copy() { From fb13af7a3d68cf36a5d0439816bfac37e3c9780c Mon Sep 17 00:00:00 2001 From: bin456789 Date: Tue, 29 Apr 2025 15:10:42 +0800 Subject: [PATCH 050/127] =?UTF-8?q?debian:=20=E4=BF=AE=E5=A4=8D=E4=BA=86?= =?UTF-8?q?=E6=B2=A1=E6=9C=89=E7=94=9F=E6=88=90=20bootx64.efi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fixes #326 --- debian.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian.cfg b/debian.cfg index 80047ba..ce24257 100644 --- a/debian.cfg +++ b/debian.cfg @@ -96,7 +96,7 @@ d-i pkgsel/upgrade select none # B.4.11. 安装 bootloader # 添加 bootx64.efi -d-i grub2/force_efi_extra_removable boolean true +d-i grub-installer/force-efi-extra-removable boolean true # B.4.12. 完成安装 d-i finish-install/reboot_in_progress note From e11024319f73fb6cde97fc0064c2fd7d53f69364 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Wed, 30 Apr 2025 00:00:16 +0800 Subject: [PATCH 051/127] =?UTF-8?q?windows:=20=E4=BC=98=E5=8C=96=20frpc=20?= =?UTF-8?q?=E8=AE=A1=E5=88=92=E4=BB=BB=E5=8A=A1=E8=BF=90=E8=A1=8C=E6=96=B9?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- trans.sh | 1 - windows-frpc-workaround.bat | 18 ------------------ windows-frpc.bat | 17 ++++++----------- 3 files changed, 6 insertions(+), 30 deletions(-) delete mode 100644 windows-frpc-workaround.bat diff --git a/trans.sh b/trans.sh index 4cecfca..5fe6f20 100644 --- a/trans.sh +++ b/trans.sh @@ -2921,7 +2921,6 @@ modify_windows() { cp -f /configs/frpc.toml "$os_dir/frpc/frpc.toml" download "$confhome/windows-frpc.xml" "$os_dir/frpc/frpc.xml" download "$confhome/windows-frpc.bat" "$os_dir/frpc/frpc.bat" - download "$confhome/windows-frpc-workaround.bat" "$os_dir/frpc/frpc-workaround.bat" bats="$bats frpc\frpc.bat" else warn "$windows_arch Not Support frpc" diff --git a/windows-frpc-workaround.bat b/windows-frpc-workaround.bat deleted file mode 100644 index d1ba31e..0000000 --- a/windows-frpc-workaround.bat +++ /dev/null @@ -1,18 +0,0 @@ -@echo off -mode con cp select=437 >nul - -rem 如果找到 LOCAL SERVICE 运行的 frpc,则结束 SYSTEM 运行的 frpc -rem 如果没找到 frpc,则运行 frpc(本脚本是用 SYSTEM 运行,好像无法 runas "NT AUTHORITY\LOCAL SERVICE") - -rem tasklist 返回值始终为 0,因此需要用 findstr - -:loop -tasklist /FI "IMAGENAME eq frpc.exe" /FI "USERNAME eq NT AUTHORITY\LOCAL SERVICE" | findstr /I "frpc.exe" && goto :kill_system_frpc -tasklist /FI "IMAGENAME eq frpc.exe" | findstr /I "frpc.exe" || start %SystemDrive%\frpc\frpc.exe -c %SystemDrive%\frpc\frpc.toml -timeout 5 -goto :loop - -:kill_system_frpc -taskkill /F /T /FI "IMAGENAME eq frpc.exe" /FI "USERNAME eq NT AUTHORITY\SYSTEM" - -del "%~f0" diff --git a/windows-frpc.bat b/windows-frpc.bat index afb1ca2..0f6efa8 100644 --- a/windows-frpc.bat +++ b/windows-frpc.bat @@ -4,35 +4,30 @@ mode con cp select=437 >nul rem Windows Deferder 会误报,因此要添加白名单 powershell -ExecutionPolicy Bypass -Command "Add-MpPreference -ExclusionPath '%SystemDrive%\frpc\frpc.exe'" -rem ---------- DEBUG ---------- -rem 检查服务状态 -rem sc query Schedule >%SystemDrive%\x.txt 2>&1 - rem 启用日志 rem wevtutil set-log Microsoft-Windows-TaskScheduler/Operational /enabled:true -rem ---------- DEBUG ---------- rem 创建计划任务并立即运行 schtasks /Create /TN "frpc" /XML "%SystemDrive%\frpc\frpc.xml" schtasks /Run /TN "frpc" del "%SystemDrive%\frpc\frpc.xml" -rem win11 在首次登录后计划任务才生效 +rem win10+ 在首次登录后计划任务才生效 rem 即使手动重启,计划任务也没有运行 rem 如果 10 秒内有 frpc 进程,则代表计划任务已经生效,不需要首次登录 -rem 如果 10 秒后也没有 frpc 进程,则需要运行 frpc-workaround.bat +rem 如果 10 秒后也没有 frpc 进程,则需要临时改用 SYSTEM 用户运行计划任务 for /L %%i in (1,1,10) do ( timeout 1 tasklist /FI "IMAGENAME eq frpc.exe" | find /I "frpc.exe" && ( - del "%SystemDrive%\frpc\frpc-workaround.bat" goto :end ) ) -rem 后台运行 frpc-workaround.bat -rem 需要加 cmd /c,不然 frpc-workaround.bat 结束后有 cmd 窗口残留 -start cmd /c "%SystemDrive%\frpc\frpc-workaround.bat" +rem 临时改用 SYSTEM 用户运行计划任务,运行后再改回 Local Service 用户 +schtasks /Change /TN "frpc" /RU "S-1-5-18" +schtasks /Run /TN "frpc" +schtasks /Change /TN "frpc" /RU "S-1-5-19" :end rem 删除此脚本 From 770000ea9d807dcf8e9c61785041337aba02787b Mon Sep 17 00:00:00 2001 From: bin456789 Date: Sun, 4 May 2025 19:28:37 +0800 Subject: [PATCH 052/127] =?UTF-8?q?windows:=20=E4=BF=AE=E6=AD=A3=E9=83=A8?= =?UTF-8?q?=E5=88=86=20win7=20=E9=A9=B1=E5=8A=A8=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- trans.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/trans.sh b/trans.sh index 5fe6f20..8cac83a 100644 --- a/trans.sh +++ b/trans.sh @@ -5770,8 +5770,8 @@ install_windows() { case "$product_ver" in '7' | '2008 r2') $support_sha256 && # 25.0 比 24.5 只更新了 ProSet 软件,驱动相同 - echo echo 18713/eng/prowin${arch_intel}legacy.exe || # 25.0 有部分文件是 sha256 签名 - echo 29323/eng/prowin${arch_intel}legacy.exe ;; # 24.3 sha1 签名 + echo 18713/eng/prowin${arch_intel}legacy.exe || # 25.0 有部分文件是 sha256 签名 + echo 29323/eng/prowin${arch_intel}legacy.exe ;; # 24.3 sha1 签名 '8') echo 21642/eng/prowin${arch_intel}.exe ;; '8.1') echo 764813/Wired_driver_27.8_${arch_intel}.zip ;; '2012' | '2012 r2') echo 785805/Wired_driver_28.2_${arch_intel}.zip ;; @@ -5923,7 +5923,7 @@ EOF aws_pv_ver=$( case "$nt_ver" in - 6.1) $support_sha256 && echo 8.3.5 || echo echo 8.3.2 ;; + 6.1) $support_sha256 && echo 8.3.5 || echo 8.3.2 ;; 6.2 | 6.3) echo 8.4.3 ;; *) echo Latest ;; esac From 36ee398eb6c967de03a0bdbf0da8c85a54dc6fe6 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Mon, 5 May 2025 21:27:07 +0800 Subject: [PATCH 053/127] =?UTF-8?q?core:=20=E6=94=B9=E8=BF=9B=20reinstall.?= =?UTF-8?q?bat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- reinstall.bat | 68 +++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 49 insertions(+), 19 deletions(-) diff --git a/reinstall.bat b/reinstall.bat index a34aa22..919b81e 100644 --- a/reinstall.bat +++ b/reinstall.bat @@ -30,15 +30,25 @@ if errorlevel 1 ( rem 有时 %tmp% 带会话 id,且文件夹不存在 rem https://learn.microsoft.com/troubleshoot/windows-server/shell-experience/temp-folder-with-logon-session-id-deleted -if not exist %tmp% ( - md %tmp% -) +rem if not exist %tmp% ( +rem md %tmp% +rem ) -rem 检查是否国内 +rem 下载 geoip if not exist geoip ( rem www.cloudflare.com/dash.cloudflare.com 国内访问的是美国服务器,而且部分地区被墙 call :download http://www.qualcomm.cn/cdn-cgi/trace %~dp0geoip || goto :download_failed ) + +rem 判断是否有 loc= +findstr /c:"loc=" geoip >nul +if errorlevel 1 ( + echo Invalid geoip file + del geoip + exit /b 1 +) + +rem 检查是否国内 findstr /c:"loc=CN" geoip >nul if not errorlevel 1 ( rem mirrors.tuna.tsinghua.edu.cn 会强制跳转 https @@ -60,37 +70,49 @@ if not errorlevel 1 ( call :check_cygwin_installed || ( rem win10 arm 支持运行 x86 软件 rem win11 arm 支持运行 x86 和 x86_64 软件 - rem wmic os get osarchitecture 显示中文 - rem wmic ComputerSystem get SystemType 显示英文 - rem SystemType rem windows 11 24h2 没有 wmic + rem wmic os get osarchitecture 显示中文,即使设置了 mode con cp select=437 + rem wmic ComputerSystem get SystemType 显示英文 + rem for /f "tokens=*" %%a in ('wmic ComputerSystem get SystemType ^| find /i "based"') do ( + rem set "SystemType=%%a" + rem ) + rem 有的系统精简了 powershell - where wmic >nul 2>&1 - if not errorlevel 1 ( - for /f "tokens=*" %%a in ('wmic ComputerSystem get SystemType ^| find /i "based"') do ( - set "SystemType=%%a" - ) - ) else ( - for /f "delims=" %%a in ('powershell -NoLogo -NoProfile -NonInteractive -Command "(Get-WmiObject win32_computersystem).SystemType"') do ( - set "SystemType=%%a" - ) + rem for /f "delims=" %%a in ('powershell -NoLogo -NoProfile -NonInteractive -Command "(Get-WmiObject win32_computersystem).SystemType"') do ( + rem set "SystemType=%%a" + rem ) + + rem SystemArch + for /f "tokens=3" %%a in ('reg query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v PROCESSOR_ARCHITECTURE') do ( + set SystemArch=%%a ) + rem 也可以用 PROCESSOR_ARCHITEW6432 和 PROCESSOR_ARCHITECTURE 判断 + rem ARM64 win11 PROCESSOR_ARCHITEW6432 PROCESSOR_ARCHITECTURE + rem 原生cmd 未定义 ARM64 + rem 32位cmd ARM64 x86 + + rem if defined PROCESSOR_ARCHITEW6432 ( + rem set "SystemArch=%PROCESSOR_ARCHITEW6432%" + rem ) else ( + rem set "SystemArch=%PROCESSOR_ARCHITECTURE%" + rem ) + rem BuildNumber for /f "tokens=3" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v CurrentBuildNumber') do ( - set /a BuildNumber=%%a + set /a BuildNumber=%%a ) set CygwinEOL=1 - echo !SystemType! | find "ARM" > nul + echo !SystemArch! | find "ARM" > nul if not errorlevel 1 ( if !BuildNumber! GEQ 22000 ( set CygwinEOL=0 ) ) else ( - echo !SystemType! | find "x64" > nul + echo !SystemArch! | find "AMD64" > nul if not errorlevel 1 ( if !BuildNumber! GEQ 9600 ( set CygwinEOL=0 @@ -114,6 +136,14 @@ call :check_cygwin_installed || ( call :download http://www.cygwin.com/setup-!CygwinArch!.exe %~dp0setup-!CygwinArch!.exe || goto :download_failed ) + rem 少于 1M 视为无效 + rem 有的 IP 被官网拉黑,无法下载 exe,下载得到 html + for %%A in (setup-!CygwinArch!.exe) do if %%~zA LSS 1048576 ( + echo Invalid Cgywin installer + del setup-!CygwinArch!.exe + exit /b 1 + ) + rem 安装 Cygwin set site=!mirror!!dir! start /wait setup-!CygwinArch!.exe ^ From 318f0e589a8247575a51634abbfe1bca1caf6d3a Mon Sep 17 00:00:00 2001 From: bin456789 Date: Mon, 5 May 2025 21:27:07 +0800 Subject: [PATCH 054/127] =?UTF-8?q?core:=20=E4=BF=AE=E5=A4=8D=E5=9B=BD?= =?UTF-8?q?=E5=86=85=E6=9C=BA=E4=BB=8E=20github=20=E4=B8=8B=E8=BD=BD=20wmi?= =?UTF-8?q?c.ps1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- reinstall.sh | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/reinstall.sh b/reinstall.sh index f74c2d6..7981218 100644 --- a/reinstall.sh +++ b/reinstall.sh @@ -4002,16 +4002,24 @@ redhat | centos | almalinux | rocky | fedora | ubuntu) ;; esac -# 检查内存 -check_ram - # 检查硬件架构 if is_in_windows; then # x86-based PC # x64-based PC # ARM-based PC # ARM64-based PC - basearch=$(wmic ComputerSystem get SystemType | grep '=' | cut -d= -f2 | cut -d- -f1) + + if false; then + # 如果机器没有 wmic 则需要下载 wmic.ps1,但此时未判断国内外,还是用国外源 + basearch=$(wmic ComputerSystem get SystemType | grep '=' | cut -d= -f2 | cut -d- -f1) + elif true; then + # 可以用 + basearch=$(reg query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v PROCESSOR_ARCHITECTURE | + grep . | tail -1 | awk '{print $NF}') + else + # 也可以用 + basearch=$(cmd /c "if defined PROCESSOR_ARCHITEW6432 (echo %PROCESSOR_ARCHITEW6432%) else (echo %PROCESSOR_ARCHITECTURE%)") + fi else # archlinux 云镜像没有 arch 命令 # https://en.wikipedia.org/wiki/Uname @@ -4045,6 +4053,7 @@ if false && [[ "$confhome" = http*://raw.githubusercontent.com/* ]]; then fi # 设置国内代理 +# 要在使用 wmic 前设置,否则国内机器会从国外源下载 wmic.ps1 # gitee 不支持ipv6 # jsdelivr 有12小时缓存 # https://github.com/XIU2/UserScript/blob/master/GithubEnhanced-High-Speed-Download.user.js#L31 @@ -4057,6 +4066,10 @@ if is_in_china; then fi fi +# 检查内存 +# 会用到 wmic,因此要在设置国内 confhome 后使用 +check_ram + # 以下目标系统不需要两步安装 # alpine # debian From 2fb31ed7c3abb7c095b4f01a56ceb2a716ca1919 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Mon, 5 May 2025 21:27:08 +0800 Subject: [PATCH 055/127] =?UTF-8?q?windows:=20=E4=BF=AE=E5=A4=8D=20vista?= =?UTF-8?q?=20=E6=B2=A1=E6=9C=89=20InstallationType=20=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- trans.sh | 43 +++++++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/trans.sh b/trans.sh index 8cac83a..4fb94ce 100644 --- a/trans.sh +++ b/trans.sh @@ -5351,13 +5351,29 @@ hivexget() { ash "$(which hivexget)" "$@" } -get_installation_type_from_windows_drive() { +get_windows_type_from_windows_drive() { local os_dir=$1 apk add hivex - hive=$(find_file_ignore_case $os_dir/Windows/System32/config/SOFTWARE) - hivexget $hive '\Microsoft\Windows NT\CurrentVersion' InstallationType + software_hive=$(find_file_ignore_case $os_dir/Windows/System32/config/SOFTWARE) + system_hive=$(find_file_ignore_case $os_dir/Windows/System32/config/SYSTEM) + installation_type=$(hivexget $software_hive '\Microsoft\Windows NT\CurrentVersion' InstallationType || true) + product_type=$(hivexget $system_hive '\ControlSet001\Control\ProductOptions' ProductType || true) apk del hivex + + # 根据 win11 multi-session 的情况 + # InstallationType 比 ProductType 准确 + + # Vista wim 和注册表都没有 InstallationType + case "$installation_type" in + Client | Embedded) echo client ;; + Server | 'Server Core') echo server ;; + *) case "$product_type" in + WinNT) echo client ;; + ServerNT) echo server ;; + *) error_and_exit "Unknown Windows Type" ;; + esac ;; + esac } get_windows_arch_from_windows_drive() { @@ -5506,7 +5522,7 @@ install_windows() { # 用内核版本号筛选驱动 # 使得可以安装 Hyper-V Server / Azure Stack HCI 等 Windows Server 变种 # 7601.24214.180801-1700.win7sp1_ldr_escrow_CLIENT_ULTIMATE_x64FRE_en-us.iso wim 没有 Installation Type - # 因此改成从注册表获取 + # Vista wim 和 注册表 都没有 InstallationType if false; then nt_ver=$(get_selected_image_prop "Major Version").$(get_selected_image_prop "Minor Version") build_ver=$(get_selected_image_prop "Build") @@ -5521,7 +5537,7 @@ install_windows() { wimmount "$iso_install_wim" "$image_index" /wim/ ntoskrnl_exe=$(find_file_ignore_case /wim/Windows/System32/ntoskrnl.exe) get_windows_version_from_dll "$ntoskrnl_exe" - installation_type=$(get_installation_type_from_windows_drive /wim) + windows_type=$(get_windows_type_from_windows_drive /wim) { find_file_ignore_case /wim/Windows/System32/sacsess.exe && has_sac=true || has_sac=false find_file_ignore_case /wim/Windows/INF/stornvme.inf && has_stornvme=true || has_stornvme=false @@ -5540,17 +5556,12 @@ install_windows() { support_sha256=true fi - case "$installation_type" in - Client | Embedded) - windows_type=client - product_ver=$(get_client_name_by_build_ver "$build_ver") - ;; - Server | 'Server Core') - windows_type=server - product_ver=$(get_server_name_by_build_ver "$build_ver") - ;; - *) error_and_exit "Unknown Installation Type: $installation_type" ;; - esac + product_ver=$( + case "$windows_type" in + client) get_client_name_by_build_ver "$build_ver" ;; + server) get_server_name_by_build_ver "$build_ver" ;; + esac + ) info "Selected image info" echo "Image Name: $image_name" From f4f248100960246eea4b743f1ca634d1db8a999e Mon Sep 17 00:00:00 2001 From: bin456789 Date: Mon, 5 May 2025 21:27:09 +0800 Subject: [PATCH 056/127] =?UTF-8?q?windows:=20=E9=99=8D=E7=BA=A7=20aws=20x?= =?UTF-8?q?en=20win2012r2=20=E9=A9=B1=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #329 --- trans.sh | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/trans.sh b/trans.sh index 4fb94ce..7e6782a 100644 --- a/trans.sh +++ b/trans.sh @@ -5932,15 +5932,39 @@ EOF apk add msitools + # 8.4.3 的 xenbus 挑创建实例时的初始系统 + # 初始系统为 windows 的实例支持 8.4.3 + # 初始系统为 linux 的实例不支持 8.4.3 + + # 初始系统为 linux + 安装 8.4.3 + # 如果用 msi 安装,则不会启用 xenbus,结果是能启动但无法上网 + # 如果通过 inf 安装,则会启用 xenbus,结果是无法启动 + + apk add lscpu + hypervisor_vendor=$(lscpu | grep 'Hypervisor vendor:' | awk '{print $3}') + apk del lscpu + aws_pv_ver=$( case "$nt_ver" in 6.1) $support_sha256 && echo 8.3.5 || echo 8.3.2 ;; - 6.2 | 6.3) echo 8.4.3 ;; + 6.2 | 6.3) + case "$hypervisor_vendor" in + Microsoft) echo 8.4.3 ;; # 实例初始系统为 Windows,能使用 8.4.3 + Xen) echo 8.3.5 ;; # 实例初始系统为 Linux,不能使用 8.4.3 + esac + ;; *) echo Latest ;; esac ) - download "$(get_aws_repo)/AWSPV/$aws_pv_ver/AWSPVDriver.zip" $drv/AWSPVDriver.zip + url=$( + case "$aws_pv_ver" in + 8.3.2) echo https://web.archive.org/web/20221016194548/https://s3.amazonaws.com/ec2-windows-drivers-downloads/AWSPV/$aws_pv_ver/AWSPVDriver.zip ;; # win7 sha1 + *) echo "$(get_aws_repo)/AWSPV/$aws_pv_ver/AWSPVDriver.zip" ;; + esac + ) + + download "$url" $drv/AWSPVDriver.zip unzip -o -d $drv $drv/AWSPVDriver.zip mkdir -p $drv/xen/ From 103ef84f92bd051af0078517cfb58176e932f284 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Mon, 5 May 2025 21:37:44 +0800 Subject: [PATCH 057/127] =?UTF-8?q?windows:=20=E6=94=AF=E6=8C=81=204Kn=20?= =?UTF-8?q?=E7=A1=AC=E7=9B=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- trans.sh | 10 ++++++++++ windows-setup.bat | 10 +++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/trans.sh b/trans.sh index 7e6782a..50cbfff 100644 --- a/trans.sh +++ b/trans.sh @@ -2328,6 +2328,10 @@ get_disk_logic_sector_size() { blockdev --getss "$1" } +is_4kn() { + [ "$(blockdev --getss "$1")" = 4096 ] +} + is_xda_gt_2t() { disk_size=$(get_disk_size /dev/$xda) disk_2t=$((2 * 1024 * 1024 * 1024 * 1024)) @@ -6527,6 +6531,12 @@ EOF sed -i 's/EnableEMS=0/EnableEMS=1/i' $startnet_cmd fi + # 4kn EFI 分区最少要 260M + # https://learn.microsoft.com/windows-hardware/manufacture/desktop/hard-drives-and-partitions + if is_4kn /dev/$xda; then + sed -i 's/is4kn=0/is4kn=1/i' $startnet_cmd + fi + # Windows Thin PC 有 Windows\System32\winpeshl.ini # [LaunchApps] # %SYSTEMDRIVE%\windows\system32\drvload.exe, %SYSTEMDRIVE%\windows\inf\sdbus.inf diff --git a/windows-setup.bat b/windows-setup.bat index 1789490..a71e8a0 100644 --- a/windows-setup.bat +++ b/windows-setup.bat @@ -93,6 +93,14 @@ for /f "tokens=3" %%a in (X:\disk.txt) do ( ) del X:\disk.txt +rem 这个变量会被 trans.sh 修改 +set is4kn=0 +if "%is4kn%"=="1" ( + set EFISize=260 +) else ( + set EFISize=100 +) + rem 重新分区/格式化 (if "%BootType%"=="efi" ( echo select disk %DiskIndex% @@ -104,7 +112,7 @@ rem 重新分区/格式化 echo select part 3 echo delete part override - echo create part efi size=100 + echo create part efi size=%EFISize% echo format fs=fat32 quick echo create part msr size=16 From 89a8efa123c6c9c1c2cf62d2013a24b92729b3ef Mon Sep 17 00:00:00 2001 From: MrZhiin Date: Tue, 6 May 2025 11:03:12 +0800 Subject: [PATCH 058/127] =?UTF-8?q?fix(reinstall.sh):=20=E4=BF=AE=E6=AD=A3?= =?UTF-8?q?SSH=E5=AF=86=E9=92=A5=E9=AA=8C=E8=AF=81=E6=AD=A3=E5=88=99?= =?UTF-8?q?=E8=A1=A8=E8=BE=BE=E5=BC=8F=E4=B8=AD=E7=9A=84ecdsa=E7=AE=97?= =?UTF-8?q?=E6=B3=95=E5=90=8D=E7=A7=B0=20(#334)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- reinstall.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reinstall.sh b/reinstall.sh index 7981218..6aa122f 100644 --- a/reinstall.sh +++ b/reinstall.sh @@ -3810,7 +3810,7 @@ EOF # https://manpages.debian.org/testing/openssh-server/authorized_keys.5.en.html#AUTHORIZED_KEYS_FILE_FORMAT is_valid_ssh_key() { - grep -qE '^(ecdsa-sha-nistp(256|384|512)|ssh-(ed25519|rsa)) ' <<<"$1" + grep -qE '^(ecdsa-sha2-nistp(256|384|512)|ssh-(ed25519|rsa)) ' <<<"$1" } [ -n "$2" ] || ssh_key_error_and_exit "Need value for $1" From 8b7647ddf1aaa8de600be2cb5d4e2d93b62ec780 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Tue, 6 May 2025 21:40:54 +0800 Subject: [PATCH 059/127] =?UTF-8?q?windows:=20=E4=B8=8B=E8=BD=BD=20intel?= =?UTF-8?q?=20=E9=A9=B1=E5=8A=A8=E6=97=B6=E4=BD=BF=E7=94=A8=20wget=20?= =?UTF-8?q?=E7=9A=84=20User-Agent?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- trans.sh | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/trans.sh b/trans.sh index 50cbfff..e62993f 100644 --- a/trans.sh +++ b/trans.sh @@ -194,12 +194,19 @@ download() { url=$torrent fi + # intel 禁止了 aria2 下载 + opt_user_agent= + if [[ "$url" =~ downloadmirror.intel.com ]]; then + opt_user_agent="-U Wget/1.25.0" + fi + # -o 设置 http 下载文件名 # -O 设置 bt 首个文件的文件名 aria2c "$url" \ -d "$(dirname "$path")" \ -o "$(basename "$path")" \ - -O "1=$(basename "$path")" + -O "1=$(basename "$path")" \ + $opt_user_agent # opensuse 官方镜像支持 metalink # aira2 无法重命名用 metalink 下载的文件 @@ -5790,13 +5797,15 @@ install_windows() { '8') echo 21642/eng/prowin${arch_intel}.exe ;; '8.1') echo 764813/Wired_driver_27.8_${arch_intel}.zip ;; '2012' | '2012 r2') echo 785805/Wired_driver_28.2_${arch_intel}.zip ;; - *) echo 845886/Wired_driver_30.0_${arch_intel}.zip ;; + *) case "${arch_intel}" in + 32) echo 845886/Wired_driver_30.0_${arch_intel}.zip ;; + x64) echo 854162/Wired_driver_30.1_${arch_intel}.zip ;; + esac ;; esac ) - # intel 禁止了 aria2 下载 - # download https://downloadmirror.intel.com/$file $drv/intel.zip - wget https://downloadmirror.intel.com/$file -O $drv/intel.zip + # 注意 intel 禁止了 aria2 下载 + download https://downloadmirror.intel.com/$file $drv/intel.zip # inf 可能是 UTF-16 LE?因此用 rg 搜索 # 用 busybox unzip 解压 win10 驱动时,路径和文件名会粘在一起 @@ -6372,6 +6381,7 @@ EOF elif [ "$build_ver" -ge 15063 ]; then url=https://downloadmirror.intel.com/849934/SetupRST.exe # RST v19 fi + # 注意 intel 禁止了 aria2 下载 download $url $drv/SetupRST.exe 7z x $drv/SetupRST.exe -o$drv/SetupRST -i!.text 7z x $drv/SetupRST/.text -o$drv/vmd From 139db3449fac08085c2803b5f67159c9618d305a Mon Sep 17 00:00:00 2001 From: bin456789 Date: Tue, 6 May 2025 23:53:52 +0800 Subject: [PATCH 060/127] =?UTF-8?q?windows:=2011=20=E4=BB=A3=E9=85=B7?= =?UTF-8?q?=E7=9D=BF=20vmd=20=E9=A9=B1=E5=8A=A8=E5=9C=A8=20RST=20v19=20?= =?UTF-8?q?=E9=87=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- trans.sh | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/trans.sh b/trans.sh index e62993f..7bc1183 100644 --- a/trans.sh +++ b/trans.sh @@ -6375,16 +6375,31 @@ EOF } add_driver_vmd() { - apk add 7zip - if [ "$build_ver" -ge 19041 ]; then + # RST v20 不支持 11代 PCI\VEN_8086&DEV_9A0B + is_gen11=false + for d in /sys/bus/pci/devices/*; do + vendor=$(cat "$d/vendor" 2>/dev/null) + device=$(cat "$d/device" 2>/dev/null) + if [ "$vendor" = "0x8086" ] && [ "$device" = "0x9a0b" ]; then + is_gen11=true + break + fi + done + + if ! $is_gen11 && [ "$build_ver" -ge 19041 ]; then url=https://downloadmirror.intel.com/849939/SetupRST.exe # RST v20 elif [ "$build_ver" -ge 15063 ]; then url=https://downloadmirror.intel.com/849934/SetupRST.exe # RST v19 + else + error_and_exit "can't find suitable vmd driver" fi + # 注意 intel 禁止了 aria2 下载 download $url $drv/SetupRST.exe + apk add 7zip 7z x $drv/SetupRST.exe -o$drv/SetupRST -i!.text 7z x $drv/SetupRST/.text -o$drv/vmd + apk del 7zip cp_drivers $drv/vmd } From 82f538c96498f767c16ae1ced12eb345d32e9ff8 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Wed, 7 May 2025 21:52:42 +0800 Subject: [PATCH 061/127] =?UTF-8?q?windows:=20=E6=9B=B4=E6=96=B0=E9=98=BF?= =?UTF-8?q?=E9=87=8C=E4=BA=91=20win7=20sha1=20=E9=A9=B1=E5=8A=A8=E9=93=BE?= =?UTF-8?q?=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- trans.sh | 56 ++++++++++++++++++++++---------------------------------- 1 file changed, 22 insertions(+), 34 deletions(-) diff --git a/trans.sh b/trans.sh index 7bc1183..43ded38 100644 --- a/trans.sh +++ b/trans.sh @@ -6232,42 +6232,30 @@ EOF add_driver_aliyun_virtio() { info "Add drivers: Aliyun virtio" - # win7 sha1 旧驱动 + aliyun_sys=$( + case "$nt_ver" in + 6.1) echo 2008R2 ;; + 6.2 | 6.3) echo 2012R2 ;; # 实际上是 2012 的驱动 + *) echo 2016 ;; + esac + ) + + subdir= if [ "$nt_ver" = 6.1 ] && ! $support_sha256; then - filename=210408.1454.1459_bin.zip # sha1 - # filename=220915.0953.0953_bin.zip # sha256 - # filename=new_virtio.zip # sha256 - - if is_in_china; then - region=cn-beijing - else - region=us-west-1 - fi - - download https://windows-driver-$region.oss-$region.aliyuncs.com/virtio/$filename $drv/aliyun.zip - unzip -o -d $drv/aliyun/ $drv/aliyun.zip - cp_drivers $drv/aliyun -ipath "*/win7/${arch}/*" - else - # 新驱动 - aliyun_sys=$( - case "$nt_ver" in - 6.1) echo 2008R2 ;; # sha256 - 6.2 | 6.3) echo 2012R2 ;; # 实际上是 2012 的驱动 - *) echo 2016 ;; - esac - ) - - region=cn-hangzhou - - download https://windows-driver-$region.oss-$region.aliyuncs.com/virtio/AliyunVirtio_WIN$aliyun_sys.zip $drv/AliyunVirtio.zip - unzip -o -d $drv $drv/AliyunVirtio.zip - - apk add innoextract - innoextract -d $drv/aliyun/ $drv/AliyunVirtio_*_WIN${aliyun_sys}_$arch_xdd.exe - apk del innoextract - - cp_drivers $drv/aliyun -ipath "*/C$/Program Files/AliyunVirtio/*/drivers/*" + subdir=58017/ # sha1 fi + + region=cn-hangzhou + + download https://windows-driver-$region.oss-$region.aliyuncs.com/virtio/${subdir}AliyunVirtio_WIN$aliyun_sys.zip \ + $drv/AliyunVirtio.zip + unzip -o -d $drv $drv/AliyunVirtio.zip + + apk add innoextract + innoextract -d $drv/aliyun/ $drv/AliyunVirtio_*_WIN${aliyun_sys}_$arch_xdd.exe + apk del innoextract + + cp_drivers $drv/aliyun -ipath "*/C$/Program Files/AliyunVirtio/*/drivers/*" } # gcp virtio win7 x64 sha1 From 0af60c269963fcc29cc5dc4eace2857b07389c4a Mon Sep 17 00:00:00 2001 From: bin456789 Date: Thu, 8 May 2025 22:47:55 +0800 Subject: [PATCH 062/127] =?UTF-8?q?dd:=20=E5=B0=9D=E8=AF=95=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=20NTFS=20=E8=84=8F=E5=8D=B7=E5=B9=B6=E5=BC=BA?= =?UTF-8?q?=E5=88=B6=E6=8C=82=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #273 --- trans.sh | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/trans.sh b/trans.sh index 43ded38..a324061 100644 --- a/trans.sh +++ b/trans.sh @@ -3697,10 +3697,20 @@ modify_os_on_disk() { is_windows() { true; } # 重新挂载为读写、忽略大小写 umount /os - mount -t ntfs3 -o nocase /dev/$part /os - # 有休眠文件时无法挂载成读写,提醒用户并退出脚本 - if mount | grep ' /os ' | grep -wq ro; then - error_and_exit "Can't mount windows partition /dev/$part as rw." + if ! { mount -t ntfs3 -o nocase,rw /dev/$part /os && + mount | grep -w 'on /os type' | grep -wq rw; }; then + # 显示警告 + warn "Can't normally mount windows partition /dev/$part as rw." + dmesg | grep -F "ntfs3($part):" || true + # 有可能 fallback 挂载成 ro, 因此先取消挂载 + if mount | grep -wq 'on /os type'; then + umount /os + fi + # 尝试修复并强制挂载 + apk add ntfs-3g-progs + ntfsfix /dev/$part + apk del ntfs-3g-progs + mount -t ntfs3 -o nocase,rw,force /dev/$part /os fi # 获取版本号,其他地方会用到 get_windows_version_from_dll "$ntoskrnl_exe" From 2b9c82e97da1528d355d162771ecf342f9c7a3dd Mon Sep 17 00:00:00 2001 From: bin456789 Date: Tue, 13 May 2025 12:31:12 +0800 Subject: [PATCH 063/127] =?UTF-8?q?core:=20DHCP=20=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E7=9A=84=20IP=20=E4=B8=8D=E6=98=AF=E9=87=8D=E8=A3=85=E5=89=8D?= =?UTF-8?q?=E7=9A=84=20IP=20=E6=97=B6=EF=BC=8C=E4=B8=80=E5=B9=B6=E5=88=A0?= =?UTF-8?q?=E9=99=A4=20DHCP=20=E8=8E=B7=E5=8F=96=E7=9A=84=20DNS=EF=BC=8C?= =?UTF-8?q?=E4=BB=A5=E9=98=B2=20DNS=20=E6=97=A0=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- initrd-network.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/initrd-network.sh b/initrd-network.sh index a5918c7..f812645 100644 --- a/initrd-network.sh +++ b/initrd-network.sh @@ -258,6 +258,8 @@ test_internet() { flush_ipv4_config() { ip -4 addr flush scope global dev "$ethx" ip -4 route flush dev "$ethx" + # DHCP 获取的 IP 不是重装前的 IP 时,一并删除 DHCP 获取的 DNS,以防 DNS 无效 + sed -i "/\./d" /etc/resolv.conf } should_disable_accept_ra=false @@ -272,6 +274,8 @@ flush_ipv6_config() { fi ip -6 addr flush scope global dev "$ethx" ip -6 route flush dev "$ethx" + # DHCP 获取的 IP 不是重装前的 IP 时,一并删除 DHCP 获取的 DNS,以防 DNS 无效 + sed -i "/:/d" /etc/resolv.conf } for i in $(seq 20); do From 19198a61463061474bab5fa4c86a5d0c11552095 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Fri, 16 May 2025 19:06:07 +0800 Subject: [PATCH 064/127] =?UTF-8?q?windows:=20=E6=8F=90=E7=A4=BA=E7=94=A8?= =?UTF-8?q?=E6=88=B7=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 From 6a57249015beebcd31584cc9098fad2952109222 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Fri, 16 May 2025 19:06:08 +0800 Subject: [PATCH 065/127] =?UTF-8?q?windows:=20vista=20=E4=BB=8E=E9=95=9C?= =?UTF-8?q?=E5=83=8F=E8=8E=B7=E5=8F=96=E9=BB=98=E8=AE=A4=E5=AF=86=E9=92=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- trans.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/trans.sh b/trans.sh index a324061..e588682 100644 --- a/trans.sh +++ b/trans.sh @@ -6449,14 +6449,14 @@ EOF # key if [ "$product_ver" = vista ]; then - # vista 需密钥,密钥可与 edition 不一致 - # TODO: 改成从网页获取? + # vista 无人值守安装需要密钥,密钥可与 edition 不一致 # https://learn.microsoft.com/en-us/windows-server/get-started/kms-client-activation-keys - key=VKK3X-68KWM-X2YGT-QR4M6-4BWMV + # 从镜像获取默认密钥 + setup_cfg=$(get_path_in_correct_case /os/installer/sources/inf/setup.cfg) + key=$(del_cr <"$setup_cfg" | grep -Eix 'Value=([A-Z0-9]{5}-){4}[A-Z0-9]{5}' | cut -d= -f2 | grep .) sed -i "s/%key%/$key/" /tmp/autounattend.xml else - # shellcheck disable=SC2010 - if ls -d /os/installer/sources/* | grep -iq ei.cfg; then + if [ -f "$(get_path_in_correct_case /os/installer/sources/ei.cfg)" ]; then # 镜像有 ei.cfg,删除 key 字段 sed -i "/%key%/d" /tmp/autounattend.xml else From 14ef2c82694cbf09e4a35a1c3b2becb7b497192c Mon Sep 17 00:00:00 2001 From: bin456789 Date: Fri, 16 May 2025 19:06:08 +0800 Subject: [PATCH 066/127] =?UTF-8?q?windows:=20vista=20=E7=A6=81=E7=94=A8?= =?UTF-8?q?=E6=B0=94=E7=90=83=E9=A9=B1=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- trans.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/trans.sh b/trans.sh index e588682..36636d3 100644 --- a/trans.sh +++ b/trans.sh @@ -6069,8 +6069,6 @@ EOF # 可改成直接从 github commit 下载 win7 173(sha1) 176(sha256) 全家桶? # 国内可使用 jsdelivr 加速 github - # 2008 安装的气球驱动不能用,需要到硬件管理器重新安装设备才能用,无需更新驱动 - # 2k12 # https://github.com/virtio-win/virtio-win-pkg-scripts/issues/61 # 217 ~ 271 2k12 证书有问题,红帽的 virtio-win-1.9.45 没问题 @@ -6118,8 +6116,13 @@ EOF mkdir -p $drv/virtio mount -o ro $drv/virtio.iso $drv/virtio - # -not -ipath "*/balloon/*" - cp_drivers $drv/virtio -ipath "*/$virtio_sys/$arch/*" "$@" + # vista 如果安装气动驱动,会报错 windows could not configure one or more system components + # 2008 安装的气球驱动不能用,需要到硬件管理器重新安装设备才能用,无需更新驱动 + if [ "$product_ver" = vista ]; then + cp_drivers $drv/virtio -ipath "*/$virtio_sys/$arch/*" "$@" -not -ipath "*/balloon/*" + else + cp_drivers $drv/virtio -ipath "*/$virtio_sys/$arch/*" "$@" + fi else # coreutils 的 cp mv rm 才有 -v 参数 apk add 7zip file coreutils From e3ed8703ab6ee96122f4089f25673ecbbb8e69e8 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Fri, 16 May 2025 19:06:09 +0800 Subject: [PATCH 067/127] =?UTF-8?q?redhat:=20=E4=B8=8D=E9=9C=80=E8=A6=81?= =?UTF-8?q?=E8=BE=93=E5=85=A5=E7=89=88=E6=9C=AC=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.en.md | 2 +- README.md | 2 +- reinstall.sh | 14 ++++++-------- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/README.en.md b/README.en.md index a0086b4..0c47ff5 100644 --- a/README.en.md +++ b/README.en.md @@ -128,7 +128,6 @@ certutil -urlcache -f -split https://cnb.cool/bin456789/reinstall/-/git/raw/main bash reinstall.sh anolis 7|8|23 opencloudos 8|9|23 rocky 8|9 - redhat 8|9 --img="http://xxx.com/xxx.qcow2" oracle 8|9 almalinux 8|9 centos 9|10 @@ -144,6 +143,7 @@ bash reinstall.sh anolis 7|8|23 gentoo aosc fnos + redhat --img="http://access.cdn.redhat.com/xxx.qcow2" ``` #### Optional Parameters diff --git a/README.md b/README.md index d326d5a..204b340 100644 --- a/README.md +++ b/README.md @@ -128,7 +128,6 @@ certutil -urlcache -f -split https://cnb.cool/bin456789/reinstall/-/git/raw/main bash reinstall.sh anolis 7|8|23 opencloudos 8|9|23 rocky 8|9 - redhat 8|9 --img="http://xxx.com/xxx.qcow2" oracle 8|9 almalinux 8|9 centos 9|10 @@ -144,6 +143,7 @@ bash reinstall.sh anolis 7|8|23 gentoo aosc fnos + redhat --img="http://access.cdn.redhat.com/xxx.qcow2" ``` #### 可选参数 diff --git a/reinstall.sh b/reinstall.sh index b6ee519..4f358ea 100644 --- a/reinstall.sh +++ b/reinstall.sh @@ -48,7 +48,6 @@ usage_and_exit() { Usage: $reinstall_____ anolis 7|8|23 opencloudos 8|9|23 rocky 8|9 - redhat 8|9 --img="http://xxx.com/xxx.qcow2" oracle 8|9 almalinux 8|9 centos 9|10 @@ -64,6 +63,7 @@ Usage: $reinstall_____ anolis 7|8|23 gentoo aosc fnos + redhat --img="http://access.cdn.redhat.com/xxx.qcow2" dd --img="http://xxx.com/yyy.zzz" (raw image stores in raw/vhd/tar/gz/xz/zst) windows --image-name="windows xxx yyy" --lang=xx-yy windows --image-name="windows xxx yyy" --iso="http://xxx.com/xxx.iso" @@ -1677,13 +1677,11 @@ Continue with DD? } setos_redhat() { - # el 10 需要 x86-64-v3 - if [ "$basearch" = x86_64 ] && [ "$releasever" -ge 10 ]; then - assert_cpu_supports_x86_64_v3 - fi - if is_use_cloud_image; then - # ci + # el 10 需要 x86-64-v3 + if [ "$basearch" = x86_64 ] && [[ "$img" = *rhel-10* ]]; then + assert_cpu_supports_x86_64_v3 + fi eval "${step}_img='$img'" else : @@ -1798,7 +1796,6 @@ verify_os_name() { 'opencloudos 8|9|23' \ 'almalinux 8|9' \ 'rocky 8|9' \ - 'redhat 8|9' \ 'oracle 8|9' \ 'fedora 41|42' \ 'nixos 24.11' \ @@ -1807,6 +1804,7 @@ verify_os_name() { 'alpine 3.18|3.19|3.20|3.21' \ 'openeuler 20.03|22.03|24.03|25.03' \ 'ubuntu 16.04|18.04|20.04|22.04|24.04|25.04' \ + 'redhat' \ 'kali' \ 'arch' \ 'gentoo' \ From 4f5eaa70b67995956e26fbced69bfe25833f4c9e Mon Sep 17 00:00:00 2001 From: bin456789 Date: Fri, 16 May 2025 20:49:02 +0800 Subject: [PATCH 068/127] =?UTF-8?q?windows:=20=E6=9B=B4=E6=96=B0=20iso=20?= =?UTF-8?q?=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- reinstall.sh | 70 +++++++++++++++++++++++++++++++++------------------- 1 file changed, 44 insertions(+), 26 deletions(-) diff --git a/reinstall.sh b/reinstall.sh index 4f358ea..52ed93e 100644 --- a/reinstall.sh +++ b/reinstall.sh @@ -844,11 +844,10 @@ find_windows_iso() { aarch64) arch_win=arm64 ;; esac - get_windows_iso_links get_windows_iso_link } -get_windows_iso_links() { +get_windows_iso_link() { get_label_msdn() { if [ -n "$server" ]; then case "$version" in @@ -878,7 +877,6 @@ get_windows_iso_links() { esac ;; homebasic | homepremium | business | ultimate) echo _ ;; - enterprise) echo enterprise ;; esac ;; 7) @@ -888,18 +886,10 @@ get_windows_iso_links() { x86) echo ultimate ;; esac ;; - professional) echo professional ;; - homebasic | homepremium | ultimate) echo ultimate ;; - enterprise) echo enterprise ;; - esac - ;; - 8.1) - case "$edition" in - '') ;; # massgrave 不提供 windows 8.1 家庭版链接 - pro) echo pro ;; - enterprise) echo enterprise ;; + homebasic | homepremium | professional | ultimate) echo ultimate ;; esac ;; + # 8.1 需到 msdl.gravesoft.dev 下载 10) case "$edition" in home | 'home single language') echo consumer ;; @@ -951,6 +941,25 @@ get_windows_iso_links() { esac } + get_label_msdl() { + case "$version" in + 8.1) + case "$edition" in + '' | pro) echo _ ;; + esac + ;; + 11) + case "$edition" in + home | 'home single language' | pro | education | 'pro education' | 'pro for workstations') + case "$arch_win" in + arm64) echo _ ;; + esac + ;; + esac + ;; + esac + } + get_page() { if [ "$arch_win" = arm64 ]; then echo arm @@ -973,6 +982,7 @@ get_windows_iso_links() { # 部分 bash 不支持 $() 里面嵌套case,所以定义成函数 label_msdn=$(get_label_msdn) + label_msdl=$(get_label_msdl) label_vlsc=$(get_label_vlsc) page=$(get_page) @@ -982,25 +992,32 @@ get_windows_iso_links() { echo "Version: $version" echo "Edition: $edition" echo "Label msdn: $label_msdn" + echo "Label msdl: $label_msdl" echo "Label vlsc: $label_vlsc" echo "List: $page_url" echo - if [ -z "$page" ] || { [ -z "$label_msdn" ] && [ -z "$label_vlsc" ]; }; then + if [ -z "$page" ] || { [ -z "$label_msdn" ] && [ -z "$label_msdl" ] && [ -z "$label_vlsc" ]; }; then error_and_exit "Not support find this iso. Check if --image-name is wrong. If not, set --iso manually." fi - curl -L "$page_url" | grep -ioP 'https://.*?.(iso|img)' >$tmp/win.list - - # 如果不是 ltsc ,应该先去除 ltsc 链接,否则最终链接有 ltsc 的 - # 例如查找 windows 10 iot enterprise,会得到 - # en-us_windows_10_iot_enterprise_ltsc_2021_arm64_dvd_e8d4fc46.iso - # en-us_windows_10_iot_enterprise_version_22h2_arm64_dvd_39566b6b.iso - # sed -Ei 和 sed -iE 是不同的 - if is_ltsc; then - sed -Ei '/ltsc|ltsb/!d' $tmp/win.list + if [ -n "$label_msdl" ]; then + iso=$(curl -L "$page_url" | grep -ioP 'https://.*?#[0-9]+' | head -1 | grep .) else - sed -Ei '/ltsc|ltsb/d' $tmp/win.list + curl -L "$page_url" | grep -ioP 'https://.*?.(iso|img)' >$tmp/win.list + + # 如果不是 ltsc ,应该先去除 ltsc 链接,否则最终链接有 ltsc 的 + # 例如查找 windows 10 iot enterprise,会得到 + # en-us_windows_10_iot_enterprise_ltsc_2021_arm64_dvd_e8d4fc46.iso + # en-us_windows_10_iot_enterprise_version_22h2_arm64_dvd_39566b6b.iso + # sed -Ei 和 sed -iE 是不同的 + if is_ltsc; then + sed -Ei '/ltsc|ltsb/!d' $tmp/win.list + else + sed -Ei '/ltsc|ltsb/d' $tmp/win.list + fi + + get_windows_iso_link_inner fi } @@ -1009,7 +1026,7 @@ get_shortest_line() { awk '(NR == 1 || length($0) < length(shortest)) { shortest = $0 } END { print shortest }' } -get_windows_iso_link() { +get_windows_iso_link_inner() { regexs=() # msdn @@ -1430,7 +1447,8 @@ Continue? : # 不测试磁力链接 else # 需要用户输入 massgrave.dev 直链 - if grep -Eiq '\.massgrave\.dev/.*\.(iso|img)$' <<<"$iso"; then + if grep -Eiq '\.massgrave\.dev/.*\.(iso|img)$' <<<"$iso" || + grep -Eiq '\.gravesoft\.dev/#[0-9]+$' <<<"$iso"; then info "Set Direct link" # MobaXterm 不支持 # printf '\e]8;;http://example.com\e\\This is a link\e]8;;\e\\\n' From 13740248e48e3fde472f27cf50150844364004ef Mon Sep 17 00:00:00 2001 From: bin456789 Date: Sat, 17 May 2025 22:52:03 +0800 Subject: [PATCH 069/127] =?UTF-8?q?windows:=20=E4=BF=AE=E5=A4=8D=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E4=B8=8B=E8=BD=BD=E8=85=BE=E8=AE=AF=E4=BA=91=20virtio?= =?UTF-8?q?=20=E9=A9=B1=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fixes #346 --- trans.sh | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/trans.sh b/trans.sh index 36636d3..6580352 100644 --- a/trans.sh +++ b/trans.sh @@ -195,10 +195,7 @@ download() { fi # intel 禁止了 aria2 下载 - opt_user_agent= - if [[ "$url" =~ downloadmirror.intel.com ]]; then - opt_user_agent="-U Wget/1.25.0" - fi + # 腾讯云 virtio 驱动也禁止了 aria2 下载 # -o 设置 http 下载文件名 # -O 设置 bt 首个文件的文件名 @@ -206,7 +203,7 @@ download() { -d "$(dirname "$path")" \ -o "$(basename "$path")" \ -O "1=$(basename "$path")" \ - $opt_user_agent + -U Wget/1.25.0 # opensuse 官方镜像支持 metalink # aira2 无法重命名用 metalink 下载的文件 From 8a3ef0c875d7b9813d1f0187f105f90e0120af88 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Tue, 20 May 2025 00:14:24 +0800 Subject: [PATCH 070/127] =?UTF-8?q?net:=20=E6=94=B9=E8=BF=9B=E7=BD=91?= =?UTF-8?q?=E7=BB=9C=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 防止删除 IPv6 后再次通过 SLAAC 获得 - 如果 IP 不能联网,在最终系统后则也不使用该 IP - 如果 IP 不能联网,且 IP 是从 SLAAC 获得的,则禁用 SLAAC --- initrd-network.sh | 44 ++++++++++++++++++------------------- trans.sh | 56 ++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 70 insertions(+), 30 deletions(-) diff --git a/initrd-network.sh b/initrd-network.sh index f812645..2c295a8 100644 --- a/initrd-network.sh +++ b/initrd-network.sh @@ -262,6 +262,7 @@ flush_ipv4_config() { sed -i "/\./d" /etc/resolv.conf } +should_disable_dhcpv4=false should_disable_accept_ra=false should_disable_autoconf=false @@ -386,12 +387,7 @@ done # 由于还没设置静态ip,所以有条目表示有动态地址 is_have_ipv4_addr && dhcpv4=true || dhcpv4=false is_have_ipv6_addr && dhcpv6_or_slaac=true || dhcpv6_or_slaac=false -if is_have_ipv6_gateway; then - ra_has_gateway=true - ipv6_gateway_from_ra=$(get_ipv6_gateway) -else - ra_has_gateway=false -fi +is_have_ipv6_gateway && ra_has_gateway=true || ra_has_gateway=false # 如果自动获取的 IP 不是重装前的,则改成静态,使用之前的 IP # 只比较 IP,不比较掩码/网关,因为 @@ -400,13 +396,12 @@ fi if $dhcpv4 && [ -n "$ipv4_addr" ] && [ -n "$ipv4_gateway" ] && ! [ "$(echo "$ipv4_addr" | cut -d/ -f1)" = "$(get_first_ipv4_addr | cut -d/ -f1)" ]; then echo "IPv4 address obtained from DHCP is different from old system." - dhcpv4=false + should_disable_dhcpv4=true flush_ipv4_config fi if $dhcpv6_or_slaac && [ -n "$ipv6_addr" ] && [ -n "$ipv6_gateway" ] && ! [ "$(echo "$ipv6_addr" | cut -d/ -f1)" = "$(get_first_ipv6_addr | cut -d/ -f1)" ]; then echo "IPv6 address obtained from SLAAC/DHCPv6 is different from old system." - dhcpv6_or_slaac=false should_disable_accept_ra=true should_disable_autoconf=true flush_ipv6_config @@ -428,7 +423,7 @@ if ! $ipv4_has_internet && $dhcpv4 && [ -n "$ipv4_addr" ] && [ -n "$ipv4_gateway" ] && ! { [ "$ipv4_addr" = "$(get_first_ipv4_addr)" ] && [ "$ipv4_gateway" = "$(get_first_ipv4_gateway)" ]; }; then echo "IPv4 netmask/gateway obtained from DHCP is different from old system." - dhcpv4=false + should_disable_dhcpv4=true flush_ipv4_config add_missing_ipv4_config test_internet @@ -439,7 +434,6 @@ if ! $ipv6_has_internet && [ -n "$ipv6_addr" ] && [ -n "$ipv6_gateway" ] && ! { [ "$ipv6_addr" = "$(get_first_ipv6_addr)" ] && [ "$ipv6_gateway" = "$(get_first_ipv6_gateway)" ]; }; then echo "IPv6 netmask/gateway obtained from SLAAC/DHCPv6 is different from old system." - dhcpv6_or_slaac=false should_disable_accept_ra=true should_disable_autoconf=true flush_ipv6_config @@ -447,24 +441,29 @@ if ! $ipv6_has_internet && test_internet fi -# 如果是静态地址(包括动态无法上网而改成静态的),但是 RA 有网关且和正确的网关不同,要关闭 RA,避免自动设置网关 -# TODO: 测试 RA 给的网关和静态设置的网关的优先级 -if $ipv6_has_internet && ! $dhcpv6_or_slaac && $ra_has_gateway && - ! [ "$(get_first_ipv6_gateway)" = "$ipv6_gateway_from_ra" ]; then - echo "Ignore IPv6 gateway from RA." - should_disable_accept_ra=true -fi - # 要删除不联网协议的ip,因为 # 1 甲骨文云管理面板添加ipv6地址然后取消 # 依然会分配ipv6地址,但ipv6没网络 # 此时alpine只会用ipv6下载apk,而不用会ipv4下载 -# 2 有ipv4地址但没有ipv4网关的情况(vultr),aria2会用ipv4下载 -if $ipv4_has_internet && ! $ipv6_has_internet; then - flush_ipv6_config -elif ! $ipv4_has_internet && $ipv6_has_internet; then +# 2 有ipv4地址但没有ipv4网关的情况(vultr $2.5 ipv6 only),aria2会用ipv4下载 + +# 假设 ipv4 ipv6 在不同网卡,ipv4 能上网但 ipv6 不能上网,这时也要删除 ipv6 +# 不能用 ipv4_has_internet && ! ipv6_has_internet 判断,因为它判断的是同一个网卡 +if ! $ipv4_has_internet; then + if $dhcpv4; then + should_disable_dhcpv4=true + fi flush_ipv4_config fi +if ! $ipv6_has_internet; then + # 防止删除 IPv6 后再次通过 SLAAC 获得 + # 不用判断 || $ra_has_gateway ,因为没有 IPv6 地址但有 IPv6 网关时,不会出现下载问题 + if $dhcpv6_or_slaac; then + should_disable_accept_ra=true + should_disable_autoconf=true + fi + flush_ipv6_config +fi # 如果联网了,但没获取到默认 DNS,则添加我们的 DNS if $ipv4_has_internet && ! { [ -e /etc/resolv.conf ] && is_have_ipv4_dns; }; then @@ -481,6 +480,7 @@ netconf="/dev/netconf/$ethx" mkdir -p "$netconf" $dhcpv4 && echo 1 >"$netconf/dhcpv4" || echo 0 >"$netconf/dhcpv4" $dhcpv6_or_slaac && echo 1 >"$netconf/dhcpv6_or_slaac" || echo 0 >"$netconf/dhcpv6_or_slaac" +$should_disable_dhcpv4 && echo 1 >"$netconf/should_disable_dhcpv4" || echo 0 >"$netconf/should_disable_dhcpv4" $should_disable_accept_ra && echo 1 >"$netconf/should_disable_accept_ra" || echo 0 >"$netconf/should_disable_accept_ra" $should_disable_autoconf && echo 1 >"$netconf/should_disable_autoconf" || echo 0 >"$netconf/should_disable_autoconf" $is_in_china && echo 1 >"$netconf/is_in_china" || echo 0 >"$netconf/is_in_china" diff --git a/trans.sh b/trans.sh index 6580352..80afd76 100644 --- a/trans.sh +++ b/trans.sh @@ -605,7 +605,7 @@ get_netconf_to() { eval "$1='$res'" } -is_ipv4_has_internet() { +is_any_ipv4_has_internet() { grep -q 1 /dev/netconf/*/ipv4_has_internet } @@ -616,12 +616,20 @@ is_in_china() { # 有 dhcpv4 不等于有网关,例如 vultr 纯 ipv6 # 没有 dhcpv4 不等于是静态ip,可能是没有 ip is_dhcpv4() { + if ! is_ipv4_has_internet || should_disable_dhcpv4; then + return 1 + fi + get_netconf_to dhcpv4 # shellcheck disable=SC2154 [ "$dhcpv4" = 1 ] } is_staticv4() { + if ! is_ipv4_has_internet; then + return 1 + fi + if ! is_dhcpv4; then get_netconf_to ipv4_addr get_netconf_to ipv4_gateway @@ -633,6 +641,10 @@ is_staticv4() { } is_staticv6() { + if ! is_ipv6_has_internet; then + return 1 + fi + if ! is_slaac && ! is_dhcpv6; then get_netconf_to ipv6_addr get_netconf_to ipv6_gateway @@ -649,6 +661,24 @@ is_dhcpv6_or_slaac() { [ "$dhcpv6_or_slaac" = 1 ] } +is_ipv4_has_internet() { + get_netconf_to ipv4_has_internet + # shellcheck disable=SC2154 + [ "$ipv4_has_internet" = 1 ] +} + +is_ipv6_has_internet() { + get_netconf_to ipv6_has_internet + # shellcheck disable=SC2154 + [ "$ipv6_has_internet" = 1 ] +} + +should_disable_dhcpv4() { + get_netconf_to should_disable_dhcpv4 + # shellcheck disable=SC2154 + [ "$should_disable_dhcpv4" = 1 ] +} + should_disable_accept_ra() { get_netconf_to should_disable_accept_ra # shellcheck disable=SC2154 @@ -664,7 +694,12 @@ should_disable_autoconf() { is_slaac() { # 如果是静态(包括自动获取到 IP 但无法联网而切换成静态)直接返回 1,不考虑 ra # 防止部分机器slaac/dhcpv6获取的ip/网关无法上网 - if ! is_dhcpv6_or_slaac; then + + # 有可能 ra 的 dhcpv6/slaac 是打开的,但实测无法获取到 ipv6 地址 + # is_dhcpv6_or_slaac 是实测结果,因此如果实测不通过,也返回 1 + + # 不要判断 is_staticv6,因为这会导致死循环 + if ! is_ipv6_has_internet || ! is_dhcpv6_or_slaac || should_disable_accept_ra || should_disable_autoconf; then return 1 fi get_netconf_to slaac @@ -675,7 +710,12 @@ is_slaac() { is_dhcpv6() { # 如果是静态(包括自动获取到 IP 但无法联网而切换成静态)直接返回 1,不考虑 ra # 防止部分机器slaac/dhcpv6获取的ip/网关无法上网 - if ! is_dhcpv6_or_slaac; then + + # 有可能 ra 的 dhcpv6/slaac 是打开的,但实测无法获取到 ipv6 地址 + # is_dhcpv6_or_slaac 是实测结果,因此如果实测不通过,也返回 1 + + # 不要判断 is_staticv6,因为这会导致死循环 + if ! is_ipv6_has_internet || ! is_dhcpv6_or_slaac || should_disable_accept_ra || should_disable_autoconf; then return 1 fi get_netconf_to dhcpv6 @@ -2017,7 +2057,7 @@ EOF git_uri=https://mirror.nju.edu.cn/git/gentoo-portage.git else # github 不支持 ipv6 - is_ipv4_has_internet && git_uri=https://github.com/gentoo-mirror/gentoo.git || + is_any_ipv4_has_internet && git_uri=https://github.com/gentoo-mirror/gentoo.git || git_uri=https://anongit.gentoo.org/git/repo/gentoo.git fi @@ -2758,10 +2798,10 @@ create_cloud_init_network_config() { \"address\": \"$ipv6_addr\", \"gateway\": \"$ipv6_gateway\" } " $ci_file - # 无法设置 autoconf = false ? - if should_disable_accept_ra; then - yq -i ".network.config[$config_id].accept-ra = false" $ci_file - fi + fi + # 无法设置 autoconf = false ? + if should_disable_accept_ra; then + yq -i ".network.config[$config_id].accept-ra = false" $ci_file fi # 有 ipv6 但需设置 dns 的情况 From 8895d230829efc351b73ed7502b99224ef4459a0 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Tue, 20 May 2025 11:12:58 +0800 Subject: [PATCH 071/127] =?UTF-8?q?net:=20=E4=BF=AE=E5=A4=8D=E7=89=B9?= =?UTF-8?q?=E6=AE=8A=E6=83=85=E5=86=B5=E4=B8=8B=20dns=20=E5=86=99=E5=85=A5?= =?UTF-8?q?=E5=90=8E=E5=8F=88=E8=A2=AB=E6=B8=85=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- initrd-network.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/initrd-network.sh b/initrd-network.sh index 2c295a8..d6c0e20 100644 --- a/initrd-network.sh +++ b/initrd-network.sh @@ -466,11 +466,16 @@ if ! $ipv6_has_internet; then fi # 如果联网了,但没获取到默认 DNS,则添加我们的 DNS -if $ipv4_has_internet && ! { [ -e /etc/resolv.conf ] && is_have_ipv4_dns; }; then + +# 有一种情况是,多网卡,且能上网的网卡先完成了这个脚本,不能上网的网卡后完成 +# 无法上网的网卡通过 flush_ipv4_config 删除了不能上网的 IP 和 dns +# (原计划是删除无法上网的网卡 dhcp4 获取的 dns,但实际上无法区分) +# 因此这里直接添加 dns,不判断是否联网 +if ! is_have_ipv4_dns; then echo "nameserver $ipv4_dns1" >>/etc/resolv.conf echo "nameserver $ipv4_dns2" >>/etc/resolv.conf fi -if $ipv6_has_internet && ! { [ -e /etc/resolv.conf ] && is_have_ipv6_dns; }; then +if ! is_have_ipv6_dns; then echo "nameserver $ipv6_dns1" >>/etc/resolv.conf echo "nameserver $ipv6_dns2" >>/etc/resolv.conf fi From b879df8e9bc4549a69f6b3eed783de9dc1bb2663 Mon Sep 17 00:00:00 2001 From: Illustar0 Date: Wed, 28 May 2025 22:07:12 +0800 Subject: [PATCH 072/127] feat: implement secondary DNS fallback for connectivity tests (#354) * feat: implement secondary DNS fallback for connectivity tests * refactor: optimize address retrieval in connectivity test --- initrd-network.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/initrd-network.sh b/initrd-network.sh index d6c0e20..70c5b4b 100644 --- a/initrd-network.sh +++ b/initrd-network.sh @@ -240,11 +240,11 @@ test_connect() { test_internet() { for i in $(seq 5); do echo "Testing Internet Connection. Test $i... " - if is_need_test_ipv4 && test_connect "$(get_first_ipv4_addr | remove_netmask)" "$ipv4_dns1" >/dev/null 2>&1; then + if is_need_test_ipv4 && { local current_ipv4_addr; current_ipv4_addr="$(get_first_ipv4_addr | remove_netmask)"; test_connect "$current_ipv4_addr" "$ipv4_dns1" >/dev/null 2>&1 || test_connect "$current_ipv4_addr" "$ipv4_dns2" >/dev/null 2>&1; }; then echo "IPv4 has internet." ipv4_has_internet=true fi - if is_need_test_ipv6 && test_connect "$(get_first_ipv6_addr | remove_netmask)" "$ipv6_dns1" >/dev/null 2>&1; then + if is_need_test_ipv6 && { local current_ipv6_addr; current_ipv6_addr="$(get_first_ipv6_addr | remove_netmask)"; test_connect "$current_ipv6_addr" "$ipv6_dns1" >/dev/null 2>&1 || test_connect "$current_ipv6_addr" "$ipv6_dns2" >/dev/null 2>&1; }; then echo "IPv6 has internet." ipv6_has_internet=true fi From 1a156e9741a42436fc7344cb6d1a9817f0891e43 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Thu, 29 May 2025 20:48:30 +0800 Subject: [PATCH 073/127] =?UTF-8?q?core:=20=E6=B7=BB=E5=8A=A0=20almalinux?= =?UTF-8?q?=2010,=20nixos=2025.05?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.en.md | 10 ++++----- README.md | 10 ++++----- reinstall.sh | 61 +++++++++++++++++++++++++++++++--------------------- trans.sh | 1 + 4 files changed, 47 insertions(+), 35 deletions(-) diff --git a/README.en.md b/README.en.md index 0c47ff5..9fa2401 100644 --- a/README.en.md +++ b/README.en.md @@ -36,13 +36,13 @@ The system requirements for the target system are as follows: | Kali | Rolling | 256 MB | 1 ~ 1.5 GB ^ | | Ubuntu | 16.04 LTS - 24.04 LTS, 25.04 | 512 MB \* | 2 GB | | Anolis | 7, 8, 23 | 512 MB \* | 5 GB | -| RHEL   AlmaLinux   Rocky   Oracle | 8, 9 | 512 MB \* | 5 GB | +| RHEL   AlmaLinux   Rocky   Oracle | 8, 9, 10 (if released) | 512 MB \* | 5 GB | | OpenCloudOS | 8, 9, Stream 23 | 512 MB \* | 5 GB | | CentOS Stream | 9, 10 | 512 MB \* | 5 GB | | Fedora | 41, 42 | 512 MB \* | 5 GB | | openEuler | 20.03 LTS - 24.03 LTS, 25.03 | 512 MB \* | 5 GB | | openSUSE | Leap 15.6, Tumbleweed (Rolling) | 512 MB \* | 5 GB | -| NixOS | 24.11 | 512 MB | 5 GB | +| NixOS | 25.05 | 512 MB | 5 GB | | Arch | Rolling | 512 MB | 5 GB | | Gentoo | Rolling | 512 MB | 5 GB | | AOSC OS | Rolling | 512 MB | 5 GB | @@ -126,13 +126,13 @@ certutil -urlcache -f -split https://cnb.cool/bin456789/reinstall/-/git/raw/main ```bash bash reinstall.sh anolis 7|8|23 - opencloudos 8|9|23 rocky 8|9 oracle 8|9 - almalinux 8|9 + almalinux 8|9|10 + opencloudos 8|9|23 centos 9|10 fedora 41|42 - nixos 24.11 + nixos 25.05 debian 9|10|11|12 opensuse 15.6|tumbleweed alpine 3.18|3.19|3.20|3.21 diff --git a/README.md b/README.md index 204b340..452a943 100644 --- a/README.md +++ b/README.md @@ -36,13 +36,13 @@ | Kali | 滚动 | 256 MB | 1 ~ 1.5 GB ^ | | Ubuntu | 16.04 LTS - 24.04 LTS, 25.04 | 512 MB \* | 2 GB | | Anolis | 7, 8, 23 | 512 MB \* | 5 GB | -| RHEL   AlmaLinux   Rocky   Oracle | 8, 9 | 512 MB \* | 5 GB | +| RHEL   AlmaLinux   Rocky   Oracle | 8, 9, 10 (如果有) | 512 MB \* | 5 GB | | OpenCloudOS | 8, 9, Stream 23 | 512 MB \* | 5 GB | | CentOS Stream | 9, 10 | 512 MB \* | 5 GB | | Fedora | 41, 42 | 512 MB \* | 5 GB | | openEuler | 20.03 LTS - 24.03 LTS, 25.03 | 512 MB \* | 5 GB | | openSUSE | Leap 15.6, Tumbleweed (滚动) | 512 MB \* | 5 GB | -| NixOS | 24.11 | 512 MB | 5 GB | +| NixOS | 25.05 | 512 MB | 5 GB | | Arch | 滚动 | 512 MB | 5 GB | | Gentoo | 滚动 | 512 MB | 5 GB | | 安同 OS | 滚动 | 512 MB | 5 GB | @@ -126,13 +126,13 @@ certutil -urlcache -f -split https://cnb.cool/bin456789/reinstall/-/git/raw/main ```bash bash reinstall.sh anolis 7|8|23 - opencloudos 8|9|23 rocky 8|9 oracle 8|9 - almalinux 8|9 + almalinux 8|9|10 + opencloudos 8|9|23 centos 9|10 fedora 41|42 - nixos 24.11 + nixos 25.05 debian 9|10|11|12 opensuse 15.6|tumbleweed alpine 3.18|3.19|3.20|3.21 diff --git a/reinstall.sh b/reinstall.sh index 52ed93e..c37e5c2 100644 --- a/reinstall.sh +++ b/reinstall.sh @@ -49,10 +49,10 @@ Usage: $reinstall_____ anolis 7|8|23 opencloudos 8|9|23 rocky 8|9 oracle 8|9 - almalinux 8|9 + almalinux 8|9|10 centos 9|10 fedora 41|42 - nixos 24.11 + nixos 25.05 debian 9|10|11|12 opensuse 15.6|tumbleweed alpine 3.18|3.19|3.20|3.21 @@ -649,7 +649,7 @@ is_absolute_path() { [[ "$1" = /* ]] } -assert_cpu_supports_x86_64_v3() { +is_cpu_supports_x86_64_v3() { # 用 ld.so/cpuid/coreinfo.exe 更准确 # centos 7 /usr/lib64/ld-linux-x86-64.so.2 没有 --help # alpine gcompat /lib/ld-linux-x86-64.so.2 没有 --help @@ -666,11 +666,17 @@ assert_cpu_supports_x86_64_v3() { for flag in $need_flags; do if ! grep -qw $flag <<<"$had_flags"; then - error_and_exit "Could not install $distro $releasever because the CPU does not support x86-64-v3." + return 1 fi done } +assert_cpu_supports_x86_64_v3() { + if ! is_cpu_supports_x86_64_v3; then + error_and_exit "Could not install $distro $releasever because the CPU does not support x86-64-v3." + fi +} + # sr-latn-rs 到 sr-latn en_us() { echo "$lang" | awk -F- '{print $1"-"$2}' @@ -1581,28 +1587,33 @@ Continue with DD? } setos_centos_almalinux_rocky_fedora() { - # el 10 需要 x86-64-v3 + # el 10 需要 x86-64-v3,除了 almalinux if [ "$basearch" = x86_64 ] && - { [ "$distro" = centos ] || [ "$distro" = almalinux ] || [ "$distro" = rocky ]; } && + { [ "$distro" = centos ] || [ "$distro" = rocky ]; } && [ "$releasever" -ge 10 ]; then assert_cpu_supports_x86_64_v3 fi + elarch=$basearch + if [ "$distro" = almalinux ] && [ "$basearch" = x86_64 ] && ! is_cpu_supports_x86_64_v3; then + elarch=x86_64_v2 + fi + if is_use_cloud_image; then # ci if is_in_china; then case $distro in centos) ci_mirror="https://mirror.nju.edu.cn/centos-cloud/centos" ;; - almalinux) ci_mirror="https://mirror.nju.edu.cn/almalinux/$releasever/cloud/$basearch/images" ;; - rocky) ci_mirror="https://mirror.nju.edu.cn/rocky/$releasever/images/$basearch" ;; - fedora) ci_mirror="https://mirror.nju.edu.cn/fedora/releases/$releasever/Cloud/$basearch/images" ;; + almalinux) ci_mirror="https://mirror.nju.edu.cn/almalinux/$releasever/cloud/$elarch/images" ;; + rocky) ci_mirror="https://mirror.nju.edu.cn/rocky/$releasever/images/$elarch" ;; + fedora) ci_mirror="https://mirror.nju.edu.cn/fedora/releases/$releasever/Cloud/$elarch/images" ;; esac else case $distro in centos) ci_mirror="https://cloud.centos.org/centos" ;; - almalinux) ci_mirror="https://repo.almalinux.org/almalinux/$releasever/cloud/$basearch/images" ;; - rocky) ci_mirror="https://download.rockylinux.org/pub/rocky/$releasever/images/$basearch" ;; - fedora) ci_mirror="https://d2lzkl7pfhq30w.cloudfront.net/pub/fedora/linux/releases/$releasever/Cloud/$basearch/images" ;; + almalinux) ci_mirror="https://repo.almalinux.org/almalinux/$releasever/cloud/$elarch/images" ;; + rocky) ci_mirror="https://download.rockylinux.org/pub/rocky/$releasever/images/$elarch" ;; + fedora) ci_mirror="https://d2lzkl7pfhq30w.cloudfront.net/pub/fedora/linux/releases/$releasever/Cloud/$elarch/images" ;; esac fi case $distro in @@ -1611,20 +1622,20 @@ Continue with DD? 7) # CentOS-7-aarch64-GenericCloud.qcow2c 是旧版本 ver=-2211 - ci_image=$ci_mirror/$releasever/images/CentOS-$releasever-$basearch-GenericCloud$ver.qcow2c + ci_image=$ci_mirror/$releasever/images/CentOS-$releasever-$elarch-GenericCloud$ver.qcow2c ;; *) # 有 bios 和 efi 镜像 # https://cloud.centos.org/centos/10-stream/x86_64/images/CentOS-Stream-GenericCloud-10-latest.x86_64.qcow2 # https://cloud.centos.org/centos/10-stream/x86_64/images/CentOS-Stream-GenericCloud-x86_64-10-latest.x86_64.qcow2 - [ "$basearch" = x86_64 ] && - ci_image=$ci_mirror/$releasever-stream/$basearch/images/CentOS-Stream-GenericCloud-x86_64-$releasever-latest.$basearch.qcow2 || - ci_image=$ci_mirror/$releasever-stream/$basearch/images/CentOS-Stream-GenericCloud-$releasever-latest.$basearch.qcow2 + [ "$elarch" = x86_64 ] && + ci_image=$ci_mirror/$releasever-stream/$elarch/images/CentOS-Stream-GenericCloud-x86_64-$releasever-latest.$elarch.qcow2 || + ci_image=$ci_mirror/$releasever-stream/$elarch/images/CentOS-Stream-GenericCloud-$releasever-latest.$elarch.qcow2 ;; esac ;; - almalinux) ci_image=$ci_mirror/AlmaLinux-$releasever-GenericCloud-latest.$basearch.qcow2 ;; - rocky) ci_image=$ci_mirror/Rocky-$releasever-GenericCloud-Base.latest.$basearch.qcow2 ;; + almalinux) ci_image=$ci_mirror/AlmaLinux-$releasever-GenericCloud-latest.$elarch.qcow2 ;; + rocky) ci_image=$ci_mirror/Rocky-$releasever-GenericCloud-Base.latest.$elarch.qcow2 ;; fedora) # 不加 / 会跳转到 https://dl.fedoraproject.org,纯 ipv6 无法访问 # curl -L -6 https://d2lzkl7pfhq30w.cloudfront.net/pub/fedora/linux/releases/42/Cloud/x86_64/images @@ -1639,14 +1650,14 @@ Continue with DD? else # 传统安装 case $distro in - centos) mirrorlist="https://mirrors.centos.org/mirrorlist?repo=centos-baseos-$releasever-stream&arch=$basearch" ;; + centos) mirrorlist="https://mirrors.centos.org/mirrorlist?repo=centos-baseos-$releasever-stream&arch=$elarch" ;; almalinux) mirrorlist="https://mirrors.almalinux.org/mirrorlist/$releasever/baseos" ;; - rocky) mirrorlist="https://mirrors.rockylinux.org/mirrorlist?arch=$basearch&repo=BaseOS-$releasever" ;; - fedora) mirrorlist="https://mirrors.fedoraproject.org/mirrorlist?arch=$basearch&repo=fedora-$releasever" ;; + rocky) mirrorlist="https://mirrors.rockylinux.org/mirrorlist?arch=$elarch&repo=BaseOS-$releasever" ;; + fedora) mirrorlist="https://mirrors.fedoraproject.org/mirrorlist?arch=$elarch&repo=fedora-$releasever" ;; esac - # rocky/centos9 需要删除第一行注释, almalinux 需要替换$basearch - for cur_mirror in $(curl -L $mirrorlist | sed "/^#/d" | sed "s,\$basearch,$basearch,"); do + # rocky/centos9 需要删除第一行注释, almalinux 需要替换链接里面的 $basearch + for cur_mirror in $(curl -L $mirrorlist | sed "/^#/d" | sed "s,\$basearch,$elarch,"); do host=$(get_host_by_url $cur_mirror) if is_host_has_ipv4_and_ipv6 $host && test_url_grace ${cur_mirror}images/pxeboot/vmlinuz; then @@ -1812,11 +1823,11 @@ verify_os_name() { 'centos 7|9|10' \ 'anolis 7|8|23' \ 'opencloudos 8|9|23' \ - 'almalinux 8|9' \ + 'almalinux 8|9|10' \ 'rocky 8|9' \ 'oracle 8|9' \ 'fedora 41|42' \ - 'nixos 24.11' \ + 'nixos 25.05' \ 'debian 9|10|11|12' \ 'opensuse 15.6|16.0|tumbleweed' \ 'alpine 3.18|3.19|3.20|3.21' \ diff --git a/trans.sh b/trans.sh index 80afd76..15b450b 100644 --- a/trans.sh +++ b/trans.sh @@ -3207,6 +3207,7 @@ remove_cloud_init() { case $pkg_mgr in dnf | yum) chroot $os_dir $pkg_mgr remove -y cloud-init + rm -f $os_dir/etc/cloud/cloud.cfg.rpmsave ;; zypper) # 加上 -u 才会删除依赖 From b58e09952efd6d4d9528d94a676ec0c94a8dfa37 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Fri, 30 May 2025 23:53:16 +0800 Subject: [PATCH 074/127] =?UTF-8?q?alpine:=20=E6=B7=BB=E5=8A=A0=203.22?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.en.md | 4 ++-- README.md | 4 ++-- reinstall.sh | 4 ++-- trans.sh | 23 +++++++++++++++-------- 4 files changed, 21 insertions(+), 14 deletions(-) diff --git a/README.en.md b/README.en.md index 9fa2401..95539df 100644 --- a/README.en.md +++ b/README.en.md @@ -31,7 +31,7 @@ The system requirements for the target system are as follows: | System | Version | Memory | Disk | | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------- | --------- | ---------------- | -| Alpine | 3.18, 3.19, 3.20, 3.21 | 256 MB | 1 GB | +| Alpine | 3.19, 3.20, 3.21, 3.22 | 256 MB | 1 GB | | Debian | 9, 10, 11, 12 | 256 MB | 1 ~ 1.5 GB ^ | | Kali | Rolling | 256 MB | 1 ~ 1.5 GB ^ | | Ubuntu | 16.04 LTS - 24.04 LTS, 25.04 | 512 MB \* | 2 GB | @@ -135,7 +135,7 @@ bash reinstall.sh anolis 7|8|23 nixos 25.05 debian 9|10|11|12 opensuse 15.6|tumbleweed - alpine 3.18|3.19|3.20|3.21 + alpine 3.19|3.20|3.21|3.22 openeuler 20.03|22.03|24.03|25.03 ubuntu 16.04|18.04|20.04|22.04|24.04|25.04 [--minimal] kali diff --git a/README.md b/README.md index 452a943..9758d70 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ | 系统 | 版本 | 内存 | 硬盘 | | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------- | --------- | ------------ | -| Alpine | 3.18, 3.19, 3.20, 3.21 | 256 MB | 1 GB | +| Alpine | 3.19, 3.20, 3.21, 3.22 | 256 MB | 1 GB | | Debian | 9, 10, 11, 12 | 256 MB | 1 ~ 1.5 GB ^ | | Kali | 滚动 | 256 MB | 1 ~ 1.5 GB ^ | | Ubuntu | 16.04 LTS - 24.04 LTS, 25.04 | 512 MB \* | 2 GB | @@ -135,7 +135,7 @@ bash reinstall.sh anolis 7|8|23 nixos 25.05 debian 9|10|11|12 opensuse 15.6|tumbleweed - alpine 3.18|3.19|3.20|3.21 + alpine 3.19|3.20|3.21|3.22 openeuler 20.03|22.03|24.03|25.03 ubuntu 16.04|18.04|20.04|22.04|24.04|25.04 [--minimal] kali diff --git a/reinstall.sh b/reinstall.sh index c37e5c2..fd22700 100644 --- a/reinstall.sh +++ b/reinstall.sh @@ -55,7 +55,7 @@ Usage: $reinstall_____ anolis 7|8|23 nixos 25.05 debian 9|10|11|12 opensuse 15.6|tumbleweed - alpine 3.18|3.19|3.20|3.21 + alpine 3.19|3.20|3.21|3.22 openeuler 20.03|22.03|24.03|25.03 ubuntu 16.04|18.04|20.04|22.04|24.04|25.04 [--minimal] kali @@ -1830,7 +1830,7 @@ verify_os_name() { 'nixos 25.05' \ 'debian 9|10|11|12' \ 'opensuse 15.6|16.0|tumbleweed' \ - 'alpine 3.18|3.19|3.20|3.21' \ + 'alpine 3.19|3.20|3.21|3.22' \ 'openeuler 20.03|22.03|24.03|25.03' \ 'ubuntu 16.04|18.04|20.04|22.04|24.04|25.04' \ 'redhat' \ diff --git a/trans.sh b/trans.sh index 15b450b..fce2207 100644 --- a/trans.sh +++ b/trans.sh @@ -1403,6 +1403,18 @@ install_alpine() { # 删除 setup-disk 时自动安装的包 apk del e2fsprogs dosfstools efibootmgr grub* + # 如果没有挂载 /proc + + # 1. chroot /os setup-keymap us us 会报错 + # grep: /proc/filesystems: No such file or directory + + # 2. 安装固件微码会触发 grub-probe,如果没挂载会报错 + # Executing grub-2.12-r5.trigger + # /usr/sbin/grub-probe: error: failed to get canonical path of `/dev/vda1'. + # ERROR: grub-2.12-r5.trigger: script exited with error 1 + + mount_pseudo_fs /os + # 安装到硬盘后才安装各种应用 # 避免占用 Live OS 内存 @@ -1432,7 +1444,9 @@ install_alpine() { # 安装其他部件 chroot /os setup-keymap us us chroot /os setup-timezone -i Asia/Shanghai - chroot /os setup-ntp chrony || true + # 3.21 默认是 chrony + # 3.22 默认是 busybox ntp + printf '\n' | chroot /os setup-ntp || true # 设置公钥 if is_need_set_ssh_keys; then @@ -1454,13 +1468,6 @@ install_alpine() { cp /configs/frpc.toml /os/etc/frp/frpc.toml fi - # 安装固件微码会触发 grub-probe - # 如果没挂载会报错 - # Executing grub-2.12-r5.trigger - # /usr/sbin/grub-probe: error: failed to get canonical path of `/dev/vda1'. - # ERROR: grub-2.12-r5.trigger: script exited with error 1 - mount_pseudo_fs /os - # setup-disk 会自动选择固件,但不包括微码? # https://github.com/alpinelinux/alpine-conf/blob/3.18.1/setup-disk.in#L421 if fw_pkgs="$fw_pkgs $(get_ucode_firmware_pkgs)" && [ -n "$fw_pkgs" ]; then From 7631f9f2b9871383c7373909668e57c147b38f81 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Fri, 6 Jun 2025 12:13:16 +0800 Subject: [PATCH 075/127] =?UTF-8?q?core:=20=E5=88=87=E6=8D=A2=E6=88=90=20f?= =?UTF-8?q?edora=20grub=20efi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fixes #361 --- reinstall.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reinstall.sh b/reinstall.sh index fd22700..a151532 100644 --- a/reinstall.sh +++ b/reinstall.sh @@ -2720,7 +2720,7 @@ install_grub_linux_efi() { info 'download grub efi' # fedora 39 的 efi 无法识别 opensuse tumbleweed 的 xfs - efi_distro=opensuse + efi_distro=fedora grub_efi=$(get_grub_efi_filename) # 不要用 download.opensuse.org 和 download.fedoraproject.org From 02ae82128f96702a4c0caade2414e8457434fe1d Mon Sep 17 00:00:00 2001 From: bin456789 Date: Fri, 13 Jun 2025 21:41:24 +0800 Subject: [PATCH 076/127] =?UTF-8?q?el:=20=E6=B7=BB=E5=8A=A0=20rocky=2010?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.en.md | 2 +- README.md | 2 +- reinstall.sh | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.en.md b/README.en.md index 95539df..91f0b82 100644 --- a/README.en.md +++ b/README.en.md @@ -126,7 +126,7 @@ certutil -urlcache -f -split https://cnb.cool/bin456789/reinstall/-/git/raw/main ```bash bash reinstall.sh anolis 7|8|23 - rocky 8|9 + rocky 8|9|10 oracle 8|9 almalinux 8|9|10 opencloudos 8|9|23 diff --git a/README.md b/README.md index 9758d70..b8f5fd2 100644 --- a/README.md +++ b/README.md @@ -126,7 +126,7 @@ certutil -urlcache -f -split https://cnb.cool/bin456789/reinstall/-/git/raw/main ```bash bash reinstall.sh anolis 7|8|23 - rocky 8|9 + rocky 8|9|10 oracle 8|9 almalinux 8|9|10 opencloudos 8|9|23 diff --git a/reinstall.sh b/reinstall.sh index a151532..85dd1d3 100644 --- a/reinstall.sh +++ b/reinstall.sh @@ -47,7 +47,7 @@ usage_and_exit() { cat < Date: Sun, 13 Jul 2025 21:46:40 +0800 Subject: [PATCH 077/127] =?UTF-8?q?windows:=20=E6=9B=B4=E6=96=B0=20intel?= =?UTF-8?q?=20=E7=BD=91=E5=8D=A1=E9=A9=B1=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.en.md | 2 +- README.md | 2 +- trans.sh | 12 +++++++++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/README.en.md b/README.en.md index 91f0b82..062f448 100644 --- a/README.en.md +++ b/README.en.md @@ -417,7 +417,7 @@ bash reinstall.sh windows \ [azure-mana]: https://learn.microsoft.com/azure/virtual-network/accelerated-networking-mana-windows [intel-vmd]: https://www.intel.com/content/www/us/en/download/849936/intel-rapid-storage-technology-driver-installation-software-with-intel-optane-memory-12th-to-15th-gen-platforms.html [intel-nic-7]: https://www.intel.com/content/www/us/en/download/15590/intel-network-adapter-driver-for-windows-7-final-release.html -[intel-nic-8]: https://www.intel.com/content/www/us/en/download/16765/intel-network-adapter-driver-for-windows-8-final-release.html +[intel-nic-8]: https://web.archive.org/web/20250501043104/https://www.intel.com/content/www/us/en/download/16765/intel-network-adapter-driver-for-windows-8-final-release.html [intel-nic-8.1]: https://www.intel.com/content/www/us/en/download/17479/intel-network-adapter-driver-for-windows-8-1.html [intel-nic-10]: https://www.intel.com/content/www/us/en/download/18293/intel-network-adapter-driver-for-windows-10.html [intel-nic-11]: https://www.intel.com/content/www/us/en/download/727998/intel-network-adapter-driver-for-microsoft-windows-11.html diff --git a/README.md b/README.md index b8f5fd2..7413c12 100644 --- a/README.md +++ b/README.md @@ -417,7 +417,7 @@ bash reinstall.sh windows \ [azure-mana]: https://learn.microsoft.com/azure/virtual-network/accelerated-networking-mana-windows [intel-vmd]: https://www.intel.com/content/www/us/en/download/849936/intel-rapid-storage-technology-driver-installation-software-with-intel-optane-memory-12th-to-15th-gen-platforms.html [intel-nic-7]: https://www.intel.com/content/www/us/en/download/15590/intel-network-adapter-driver-for-windows-7-final-release.html -[intel-nic-8]: https://www.intel.com/content/www/us/en/download/16765/intel-network-adapter-driver-for-windows-8-final-release.html +[intel-nic-8]: https://web.archive.org/web/20250501043104/https://www.intel.com/content/www/us/en/download/16765/intel-network-adapter-driver-for-windows-8-final-release.html [intel-nic-8.1]: https://www.intel.com/content/www/us/en/download/17479/intel-network-adapter-driver-for-windows-8-1.html [intel-nic-10]: https://www.intel.com/content/www/us/en/download/18293/intel-network-adapter-driver-for-windows-10.html [intel-nic-11]: https://www.intel.com/content/www/us/en/download/727998/intel-network-adapter-driver-for-microsoft-windows-11.html diff --git a/trans.sh b/trans.sh index fce2207..b276e05 100644 --- a/trans.sh +++ b/trans.sh @@ -5853,14 +5853,20 @@ install_windows() { '8.1') echo 764813/Wired_driver_27.8_${arch_intel}.zip ;; '2012' | '2012 r2') echo 785805/Wired_driver_28.2_${arch_intel}.zip ;; *) case "${arch_intel}" in - 32) echo 845886/Wired_driver_30.0_${arch_intel}.zip ;; - x64) echo 854162/Wired_driver_30.1_${arch_intel}.zip ;; + 32) echo 849483/Wired_driver_30.0.1_${arch_intel}.zip ;; + x64) echo 860229/Wired_driver_30.2_${arch_intel}.zip ;; esac ;; esac ) + web_archive=$( + case "$product_ver" in + '8') echo https://web.archive.org/web/20250501043104/ ;; + esac + ) + # 注意 intel 禁止了 aria2 下载 - download https://downloadmirror.intel.com/$file $drv/intel.zip + download ${web_archive}https://downloadmirror.intel.com/$file $drv/intel.zip # inf 可能是 UTF-16 LE?因此用 rg 搜索 # 用 busybox unzip 解压 win10 驱动时,路径和文件名会粘在一起 From 953d77d9461ddefb321de3ae744763579e0be086 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Tue, 15 Jul 2025 21:10:41 +0800 Subject: [PATCH 078/127] =?UTF-8?q?windows:=20=E7=94=A8=E6=88=B7=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E5=90=8E=E6=89=8D=E5=B0=86=20frpc=20=E6=94=B9?= =?UTF-8?q?=E6=88=90=E7=94=A8=20LocalService=20=E8=BF=90=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- windows-frpc.bat | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/windows-frpc.bat b/windows-frpc.bat index 0f6efa8..c0b66ec 100644 --- a/windows-frpc.bat +++ b/windows-frpc.bat @@ -12,7 +12,7 @@ schtasks /Create /TN "frpc" /XML "%SystemDrive%\frpc\frpc.xml" schtasks /Run /TN "frpc" del "%SystemDrive%\frpc\frpc.xml" -rem win10+ 在首次登录后计划任务才生效 +rem win10+ 在用户首次登录后,用 LocalService 用户运行的计划任务才会生效 rem 即使手动重启,计划任务也没有运行 rem 如果 10 秒内有 frpc 进程,则代表计划任务已经生效,不需要首次登录 @@ -24,10 +24,15 @@ for /L %%i in (1,1,10) do ( ) ) -rem 临时改用 SYSTEM 用户运行计划任务,运行后再改回 Local Service 用户 -schtasks /Change /TN "frpc" /RU "S-1-5-18" -schtasks /Run /TN "frpc" -schtasks /Change /TN "frpc" /RU "S-1-5-19" +rem 临时改用 SYSTEM 用户运行计划任务 +schtasks /Change /TN frpc /RU S-1-5-18 +schtasks /Run /TN frpc + +rem 用户登录后改回用 LocalService 运行 +reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce" /f ^ + /v FrpcRunAsLocalService ^ + /t REG_SZ ^ + /d "schtasks /Change /TN frpc /RU S-1-5-19" :end rem 删除此脚本 From d3edcb5559e9cff27edcc2ff86d203808a161a44 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Mon, 21 Jul 2025 20:47:22 +0800 Subject: [PATCH 079/127] =?UTF-8?q?core:=20=E4=BF=AE=E5=A4=8D=20reconnecti?= =?UTF-8?q?ng-websocket.min.js=20404?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- logviewer.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/logviewer.html b/logviewer.html index 05c1cea..0bab04c 100644 --- a/logviewer.html +++ b/logviewer.html @@ -58,7 +58,7 @@ From 3263ea3875564c36e8affaa5f58d9a2a6992c054 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Tue, 4 Nov 2025 21:54:21 +0800 Subject: [PATCH 118/127] =?UTF-8?q?core:=20=E6=94=B9=E6=88=90=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=20/dev/urandom=20=E4=BB=A5=E4=BF=AE=E5=A4=8D=E7=94=9F?= =?UTF-8?q?=E6=88=90=E9=9A=8F=E6=9C=BA=E5=AF=86=E7=A0=81=E6=97=B6=E9=98=BB?= =?UTF-8?q?=E5=A1=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fixes #469 fixes #471 --- reinstall.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/reinstall.sh b/reinstall.sh index a937749..5c63188 100644 --- a/reinstall.sh +++ b/reinstall.sh @@ -2343,10 +2343,6 @@ prompt_password() { warn false "Leave blank to use a random password." warn false "不填写则使用随机密码" while true; do - # 特殊字符列表 - # https://learn.microsoft.com/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/hh994562(v=ws.11) - chars=\''A-Za-z0-9~!@#$%^&*_=+`|(){}[]:;"<>,.?/-' - random_password=$(tr -dc "$chars" ,.?/-' + password=$(tr -dc "$chars" Date: Tue, 4 Nov 2025 22:15:18 +0800 Subject: [PATCH 119/127] =?UTF-8?q?windows:=20=E4=BB=8E=E7=BD=91=E9=A1=B5?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=20intel=20vmd=20=E9=A9=B1=E5=8A=A8=E6=9C=80?= =?UTF-8?q?=E6=96=B0=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- trans.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/trans.sh b/trans.sh index 8703704..c5baf9f 100644 --- a/trans.sh +++ b/trans.sh @@ -6615,12 +6615,17 @@ EOF done if ! $is_gen11 && [ "$build_ver" -ge 19041 ]; then - url=https://downloadmirror.intel.com/865363/SetupRST.exe # RST v20 + # RST v20 + local page=https://www.intel.com/content/www/us/en/download/849936.html elif [ "$build_ver" -ge 15063 ]; then - url=https://downloadmirror.intel.com/849934/SetupRST.exe # RST v19 + # RST v19 + local page=https://www.intel.com/content/www/us/en/download/849933.html else error_and_exit "can't find suitable vmd driver" fi + local url + url=$(wget -U curl/7.54.1 "$page" -O- | + grep -Eio -m1 "\"https://.+/SetupRST\.exe\"" | tr -d '"' | grep .) # 注意 intel 禁止了 aria2 下载 download $url $drv/SetupRST.exe From 78ba0690f98be76a60ba4f494630ab2ec2902c2b Mon Sep 17 00:00:00 2001 From: bin456789 Date: Tue, 4 Nov 2025 22:17:11 +0800 Subject: [PATCH 120/127] =?UTF-8?q?windows:=20=E6=B7=BB=E5=8A=A0=20win8=20?= =?UTF-8?q?=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- reinstall.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/reinstall.sh b/reinstall.sh index 5c63188..57eb6f2 100644 --- a/reinstall.sh +++ b/reinstall.sh @@ -859,7 +859,7 @@ is_have_arm_version() { find_windows_iso() { parse_windows_image_name || error_and_exit "--image-name wrong: $image_name" - if ! [ "$version" = 8.1 ] && [ -z "$edition" ]; then + if ! { [ "$version" = 8 ] || [ "$version" = 8.1 ]; } && [ -z "$edition" ]; then error_and_exit "Edition is not set." fi @@ -908,7 +908,8 @@ get_windows_iso_link() { x86) echo _ ;; esac ;; - homebasic | homepremium | business | ultimate) echo _ ;; + homebasic | homepremium | ultimate) echo _ ;; + business | enterprise) "$edition" ;; esac ;; 7) @@ -927,10 +928,9 @@ get_windows_iso_link() { professional | enterprise | ultimate) echo "$edition" ;; esac ;; - # massgrave 不提供 windows 8 下载 - 8.1) + 8 | 8.1) case "$edition" in - '') echo _ ;; # windows 8.1 core + '') echo _ ;; # windows 8.x core pro | enterprise) echo "$edition" ;; esac ;; @@ -1025,7 +1025,7 @@ get_windows_iso_link() { echo server else case "$version" in - vista | 7 | 8.1 | 10 | 11) + vista | 7 | 8 | 8.1 | 10 | 11) echo "$version" ;; esac From bd5e1185702ee044b1c4cf7eb352787f11cd0ed8 Mon Sep 17 00:00:00 2001 From: JieXu Date: Mon, 10 Nov 2025 19:37:18 +0800 Subject: [PATCH 121/127] =?UTF-8?q?core:=20=E4=BF=AE=E5=A4=8D=20ECDSA-P521?= =?UTF-8?q?=20=E8=AE=BE=E7=BD=AE=E6=8A=A5=E9=94=99=20(#480)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fixes #479 --- reinstall.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reinstall.sh b/reinstall.sh index 57eb6f2..3edb7e1 100644 --- a/reinstall.sh +++ b/reinstall.sh @@ -4004,7 +4004,7 @@ EOF # https://manpages.debian.org/testing/openssh-server/authorized_keys.5.en.html#AUTHORIZED_KEYS_FILE_FORMAT is_valid_ssh_key() { - grep -qE '^(ecdsa-sha2-nistp(256|384|512)|ssh-(ed25519|rsa)) ' <<<"$1" + grep -qE '^(ecdsa-sha2-nistp(256|384|521)|ssh-(ed25519|rsa)) ' <<<"$1" } [ -n "$2" ] || ssh_key_error_and_exit "Need value for $1" From c94f3346632b038fe65176dcb9c61994e436c203 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Thu, 4 Dec 2025 19:43:52 +0800 Subject: [PATCH 122/127] =?UTF-8?q?core:=20=E7=94=A8=20sh=20=E8=BF=90?= =?UTF-8?q?=E8=A1=8C=E6=97=B6=E8=87=AA=E5=8A=A8=E5=88=87=E6=8D=A2=E6=88=90?= =?UTF-8?q?=20bash?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- reinstall.sh | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/reinstall.sh b/reinstall.sh index 3edb7e1..7ea47a9 100644 --- a/reinstall.sh +++ b/reinstall.sh @@ -22,6 +22,22 @@ export LC_ALL=C # 不要漏了最后的 $PATH,否则会找不到 windows 系统程序例如 diskpart export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH +# 如果不是 bash 的话,继续执行会有语法错误,因此在这里判断是否 bash +if [ -z "$BASH" ]; then + if [ -f /etc/alpine-release ]; then + if ! apk add bash; then + echo "Error while install bash." >&2 + exit 1 + fi + fi + if command -v bash >/dev/null; then + exec bash "$0" "$@" + else + echo "Please run this script with bash." >&2 + exit 1 + fi +fi + # 记录日志,过滤含有 password 的行 exec > >(tee >(grep -iv password >>/reinstall.log)) 2>&1 THIS_SCRIPT=$(readlink -f "$0") @@ -35,11 +51,6 @@ trap_err() { sed -n "$line_no"p "$THIS_SCRIPT" } -if ! { [ -n "$BASH" ] && [ -n "$BASH_VERSION" ]; }; then - echo "Please run this script with bash." >&2 - exit 1 -fi - usage_and_exit() { if is_in_windows; then reinstall_____='.\reinstall.bat' From 586eb5dee1a41899f62464de1eaea31e41761ce6 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Thu, 4 Dec 2025 19:43:53 +0800 Subject: [PATCH 123/127] =?UTF-8?q?opensuse:=2016.0=20=E9=87=8D=E6=96=B0?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=20cloud=20=E9=95=9C=E5=83=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- reinstall.sh | 4 ++-- trans.sh | 31 +++++++++++++++++++++---------- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/reinstall.sh b/reinstall.sh index 7ea47a9..bd46ad4 100644 --- a/reinstall.sh +++ b/reinstall.sh @@ -1498,8 +1498,8 @@ Continue? dir=distribution/leap/$releasever/appliances case "$releasever" in 15.6) file=openSUSE-Leap-$releasever-Minimal-VM.$basearch-Cloud.qcow2 ;; - # 16.0) file=Leap-$releasever-Minimal-VM.$basearch-Cloud.qcow2 ;; # 缺少 openSUSE-repos-Leap 包,导致没有源 - 16.0) file=Leap-$releasever-Minimal-VM.$basearch-kvm$(if [ "$basearch" = x86_64 ]; then echo '-and-xen'; fi).qcow2 ;; + 16.0) file=Leap-$releasever-Minimal-VM.$basearch-Cloud.qcow2 ;; + # 16.0) file=Leap-$releasever-Minimal-VM.$basearch-kvm$(if [ "$basearch" = x86_64 ]; then echo '-and-xen'; fi).qcow2 ;; esac # https://src.opensuse.org/openSUSE/Leap-Images/src/branch/leap-16.0/kiwi-templates-Minimal/Minimal.kiwi diff --git a/trans.sh b/trans.sh index c5baf9f..1cfda61 100644 --- a/trans.sh +++ b/trans.sh @@ -3252,7 +3252,7 @@ remove_cloud_init() { # disable 会出现一堆提示信息,也无法 disable for unit in $( chroot $os_dir systemctl list-unit-files | - grep -E '^(cloud-init-.*|cloud-config|cloud-final)\.(service|socket)' | grep enabled | awk '{print $1}' + grep -E '^(cloud-init|cloud-init-.*|cloud-config|cloud-final)\.(service|socket)' | grep enabled | awk '{print $1}' ); do # 服务不存在时会报错 if chroot $os_dir systemctl -q is-enabled "$unit"; then @@ -3269,7 +3269,7 @@ remove_cloud_init() { ;; zypper) # 加上 -u 才会删除依赖 - chroot $os_dir zypper remove -y -u cloud-init + chroot $os_dir zypper remove -y -u cloud-init cloud-init-config-suse ;; apt-get) # ubuntu 25.04 开始有 cloud-init-base @@ -3658,24 +3658,35 @@ EOF fi # rpm -qi 不支持通配符 - installed_kernel=$(chroot $os_dir rpm -qa 'kernel-*' --qf '%{NAME}\n' | grep -v firmware) - if ! [ "$(echo "$installed_kernel" | wc -l)" -eq 1 ]; then - error_and_exit "Unexpected kernel installed: $installed_kernel" + origin_kernel=$(chroot $os_dir rpm -qa 'kernel-*' --qf '%{NAME}\n' | grep -v firmware) + if ! [ "$(echo "$origin_kernel" | wc -l)" -eq 1 ]; then + error_and_exit "Unexpected kernel installed: $origin_kernel" fi - # 不能同时装 kernel-default-base 和 kernel-default + # 16.0 能同时装 kernel-default-base 和 kernel-default + # tw 不能同时装 kernel-default-base 和 kernel-default # 因此需要添加 --force-resolution 自动删除 kernel-default-base - if ! [ "$installed_kernel" = "$target_kernel" ]; then + if ! [ "$origin_kernel" = "$target_kernel" ]; then # x86 必须设置一个密码,否则报错,arm 没有这个问题 # Failed to get root password hash # Failed to import /etc/uefi/certs/76B6A6A0.crt # warning: %post(kernel-default-5.14.21-150500.55.83.1.x86_64) scriptlet failed, exit status 255 + need_password_workaround=false if grep -q '^root:[:!*]' $os_dir/etc/shadow; then + need_password_workaround=true + fi + + if $need_password_workaround; then echo "root:$(mkpasswd '')" | chroot $os_dir chpasswd -e - chroot $os_dir zypper install -y --force-resolution $target_kernel + fi + # 安装新内核 + chroot $os_dir zypper install -y --force-resolution $target_kernel + # 删除旧内核 + if chroot $os_dir rpm -q $origin_kernel; then + chroot $os_dir zypper remove -y --force-resolution $origin_kernel + fi + if $need_password_workaround; then chroot $os_dir passwd -d root - else - chroot $os_dir zypper install -y --force-resolution $target_kernel fi fi From 2a561f0d8c40f797e9ac2cdf0e86031e3fcd6724 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Thu, 4 Dec 2025 19:43:54 +0800 Subject: [PATCH 124/127] =?UTF-8?q?core:=20=E6=B7=BB=E5=8A=A0=20alpine=203?= =?UTF-8?q?.23,=20nixos=2025.11?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.en.md | 12 ++++++------ README.md | 12 ++++++------ reinstall.sh | 14 +++++++------- trans.sh | 18 +++++------------- 4 files changed, 24 insertions(+), 32 deletions(-) diff --git a/README.en.md b/README.en.md index 2fcaf14..62f990f 100644 --- a/README.en.md +++ b/README.en.md @@ -46,7 +46,7 @@ The system requirements for the target system are as follows: | System | Version | Memory | Disk | | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------- | --------- | ---------------- | -| Alpine | 3.19, 3.20, 3.21, 3.22 | 256 MB | 1 GB | +| Alpine | 3.20, 3.21, 3.22, 3.23 | 256 MB | 1 GB | | Debian | 9, 10, 11, 12, 13 | 256 MB | 1 ~ 1.5 GB ^ | | Kali | Rolling | 256 MB | 1 ~ 1.5 GB ^ | | Ubuntu | 16.04 LTS - 24.04 LTS, 25.10 | 512 MB \* | 2 GB | @@ -57,11 +57,11 @@ The system requirements for the target system are as follows: | Fedora | 42, 43 | 512 MB \* | 5 GB | | openEuler | 20.03 LTS - 24.03 LTS, 25.09 | 512 MB \* | 5 GB | | openSUSE | Leap 15.6, 16.0, Tumbleweed (Rolling) | 512 MB \* | 5 GB | -| NixOS | 25.05 | 512 MB | 5 GB | +| NixOS | 25.11 | 512 MB | 5 GB | | Arch | Rolling | 512 MB | 5 GB | | Gentoo | Rolling | 512 MB | 5 GB | | AOSC OS | Rolling | 512 MB | 5 GB | -| fnOS | Beta | 512 MB | 8 GB | +| fnOS | 1 | 512 MB | 8 GB | | Windows (DD) | Any | 512 MB | Depends on image | | Windows (ISO) | Vista, 7, 8.x (Server 2008 - 2012 R2) | 512 MB | 25 GB | | Windows (ISO) | 10, 11 (Server 2016 - 2025) | 1 GB | 25 GB | @@ -159,10 +159,11 @@ bash reinstall.sh anolis 7|8|23 almalinux 8|9|10 opencloudos 8|9|23 centos 9|10 + fnos 1 + nixos 25.11 fedora 42|43 - nixos 25.05 debian 9|10|11|12|13 - alpine 3.19|3.20|3.21|3.22 + alpine 3.20|3.21|3.22|3.23 opensuse 15.6|16.0|tumbleweed openeuler 20.03|22.03|24.03|25.09 ubuntu 16.04|18.04|20.04|22.04|24.04|25.10 [--minimal] @@ -170,7 +171,6 @@ bash reinstall.sh anolis 7|8|23 arch gentoo aosc - fnos redhat --img="http://access.cdn.redhat.com/xxx.qcow2" ``` diff --git a/README.md b/README.md index ed64b68..436e5cd 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ | 系统 | 版本 | 内存 | 硬盘 | | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------- | --------- | ------------ | -| Alpine | 3.19, 3.20, 3.21, 3.22 | 256 MB | 1 GB | +| Alpine | 3.20, 3.21, 3.22, 3.23 | 256 MB | 1 GB | | Debian | 9, 10, 11, 12, 13 | 256 MB | 1 ~ 1.5 GB ^ | | Kali | 滚动 | 256 MB | 1 ~ 1.5 GB ^ | | Ubuntu | 16.04 LTS - 24.04 LTS, 25.10 | 512 MB \* | 2 GB | @@ -57,11 +57,11 @@ | Fedora | 42, 43 | 512 MB \* | 5 GB | | openEuler | 20.03 LTS - 24.03 LTS, 25.09 | 512 MB \* | 5 GB | | openSUSE | Leap 15.6, 16.0, Tumbleweed (滚动) | 512 MB \* | 5 GB | -| NixOS | 25.05 | 512 MB | 5 GB | +| NixOS | 25.11 | 512 MB | 5 GB | | Arch | 滚动 | 512 MB | 5 GB | | Gentoo | 滚动 | 512 MB | 5 GB | | 安同 OS | 滚动 | 512 MB | 5 GB | -| 飞牛 fnOS | 公测 | 512 MB | 8 GB | +| 飞牛 fnOS | 1 | 512 MB | 8 GB | | Windows (DD) | 任何 | 512 MB | 取决于镜像 | | Windows (ISO) | Vista, 7, 8.x (Server 2008 - 2012 R2) | 512 MB | 25 GB | | Windows (ISO) | 10, 11 (Server 2016 - 2025) | 1 GB | 25 GB | @@ -159,10 +159,11 @@ bash reinstall.sh anolis 7|8|23 almalinux 8|9|10 opencloudos 8|9|23 centos 9|10 + fnos 1 + nixos 25.11 fedora 42|43 - nixos 25.05 debian 9|10|11|12|13 - alpine 3.19|3.20|3.21|3.22 + alpine 3.20|3.21|3.22|3.23 opensuse 15.6|16.0|tumbleweed openeuler 20.03|22.03|24.03|25.09 ubuntu 16.04|18.04|20.04|22.04|24.04|25.10 [--minimal] @@ -170,7 +171,6 @@ bash reinstall.sh anolis 7|8|23 arch gentoo aosc - fnos redhat --img="http://access.cdn.redhat.com/xxx.qcow2" ``` diff --git a/reinstall.sh b/reinstall.sh index bd46ad4..5f3243a 100644 --- a/reinstall.sh +++ b/reinstall.sh @@ -64,10 +64,11 @@ Usage: $reinstall_____ anolis 7|8|23 oracle 8|9|10 almalinux 8|9|10 centos 9|10 + fnos 1 + nixos 25.11 fedora 42|43 - nixos 25.05 debian 9|10|11|12|13 - alpine 3.19|3.20|3.21|3.22 + alpine 3.20|3.21|3.22|3.23 opensuse 15.6|16.0|tumbleweed openeuler 20.03|22.03|24.03|25.09 ubuntu 16.04|18.04|20.04|22.04|24.04|25.10 [--minimal] @@ -75,7 +76,6 @@ Usage: $reinstall_____ anolis 7|8|23 arch gentoo aosc - fnos redhat --img="http://access.cdn.redhat.com/xxx.qcow2" dd --img="http://xxx.com/yyy.zzz" (raw image stores in raw/vhd/tar/gz/xz/zst) windows --image-name="windows xxx yyy" --lang=xx-yy @@ -920,7 +920,7 @@ get_windows_iso_link() { esac ;; homebasic | homepremium | ultimate) echo _ ;; - business | enterprise) "$edition" ;; + business | enterprise) echo "$edition" ;; esac ;; 7) @@ -1918,11 +1918,12 @@ verify_os_name() { 'almalinux 8|9|10' \ 'rocky 8|9|10' \ 'oracle 8|9|10' \ + 'fnos 1' \ 'fedora 42|43' \ - 'nixos 25.05' \ + 'nixos 25.11' \ 'debian 9|10|11|12|13' \ 'opensuse 15.6|16.0|tumbleweed' \ - 'alpine 3.19|3.20|3.21|3.22' \ + 'alpine 3.20|3.21|3.22|3.23' \ 'openeuler 20.03|22.03|24.03|25.09' \ 'ubuntu 16.04|18.04|20.04|22.04|24.04|25.10' \ 'redhat' \ @@ -1930,7 +1931,6 @@ verify_os_name() { 'arch' \ 'gentoo' \ 'aosc' \ - 'fnos' \ 'windows' \ 'dd' \ 'netboot.xyz'; do diff --git a/trans.sh b/trans.sh index 1cfda61..fdd088b 100644 --- a/trans.sh +++ b/trans.sh @@ -1630,9 +1630,9 @@ install_nixos() { fi # 备用方案 - # 1. 从 https://mirror.nju.edu.cn/nix-channels/nixos-25.05/nixexprs.tar.xz 获取 - # https://github.com/NixOS/nixpkgs/blob/nixos-25.05/pkgs/tools/package-management/nix/default.nix - # https://github.com/NixOS/nixpkgs/blob/nixos-25.05/nixos/modules/installer/tools/nix-fallback-paths.nix + # 1. 从 https://mirror.nju.edu.cn/nix-channels/nixos-25.11/nixexprs.tar.xz 获取 + # https://github.com/NixOS/nixpkgs/blob/nixos-25.11/pkgs/tools/package-management/nix/default.nix + # https://github.com/NixOS/nixpkgs/blob/nixos-25.11/nixos/modules/installer/tools/nix-fallback-paths.nix # 2. 安装最新版 nix,添加 nixos channel 后获取 # nix eval -f '' --raw 'nixVersions.stable.version' --extra-experimental-features nix-command @@ -2756,14 +2756,6 @@ mount_pseudo_fs() { fi } -get_yq_name() { - if grep -q '3\.1[6789]' /etc/alpine-release; then - echo yq - else - echo yq-go - fi -} - create_cloud_init_network_config() { ci_file=$1 recognize_static6=${2:-true} @@ -2775,7 +2767,7 @@ create_cloud_init_network_config() { mkdir -p "$(dirname "$ci_file")" touch "$ci_file" - apk add "$(get_yq_name)" + apk add yq-go need_set_dns4=false need_set_dns6=false @@ -2889,7 +2881,7 @@ create_cloud_init_network_config() { yq -i "del(.network.config[$config_id] | select(has(\"address\") | not))" $ci_file fi - apk del "$(get_yq_name)" + apk del yq-go # 查看文件 info "Cloud-init network config" From e60a8d0de2e97f2d5a5c5d752d962f317c8cfb88 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Thu, 4 Dec 2025 22:56:16 +0800 Subject: [PATCH 125/127] =?UTF-8?q?core:=20=E4=BF=AE=E5=A4=8D=20azure=20?= =?UTF-8?q?=E5=BC=80=E5=90=AF=E5=8A=A0=E9=80=9F=E7=BD=91=E7=BB=9C=E6=97=B6?= =?UTF-8?q?=20NetworkManager=20=E6=97=A0=E6=B3=95=E8=8E=B7=E5=8F=96=20IP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fixes #499 --- fix-eth-name.sh | 50 ++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 7 deletions(-) diff --git a/fix-eth-name.sh b/fix-eth-name.sh index db32213..959579b 100644 --- a/fix-eth-name.sh +++ b/fix-eth-name.sh @@ -48,20 +48,39 @@ retry() { # 用 systemd-analyze plot >a.svg 发现 sys-subsystem-net-devices-enp3s0.device 也是出现在 NetworkManager 之后 # 因此需要等待网卡出现 get_ethx_by_mac() { - mac=$(echo "$1" | to_lower) - retry 10 _get_ethx_by_mac "$mac" + retry 10 _get_ethx_by_mac "$@" } _get_ethx_by_mac() { + mac=$(echo "$1" | to_lower) + + flag=$2 + if [ -z "$flag" ]; then + flag=master + fi + if true; then - # 过滤 azure vf (带 master ethx) - ip -o link | grep -i "$mac" | grep -v master | awk '{print $2}' | cut -d: -f1 | grep . - return + if [ "$flag" = master ]; then + # master + # 过滤 azure vf (带 master ethx) + ip -o link | grep -i "$mac" | grep -v master | awk '{print $2}' | cut -d: -f1 | grep . + else + # slave + # 带 master ethx + ip -o link | grep -i "$mac" | grep -w master | awk '{print $2}' | cut -d: -f1 | grep . + fi else for i in $(cd /sys/class/net && echo *); do if [ "$(cat "/sys/class/net/$i/address")" = "$mac" ]; then - echo "$i" - return + if [ $(($(cat "/sys/class/net/$i/flags") & 0x800)) -ne 0 ]; then + fact_flag=slave + else + fact_flag=master + fi + if [ "$flag" = "$fact_flag" ]; then + echo "$i" + return + fi fi done return 1 @@ -138,6 +157,23 @@ fix_network_manager() { # 更改文件名 mv "$file" "$proper_file" + + # NM 不会自动忽略 Azure 的 slave 网卡,需手动设置 + # azure 文档中的方法不够通用,只适合 azure + # https://learn.microsoft.com/zh-cn/azure/virtual-network/accelerated-networking-overview + + # 我们采用红帽的方法 + # https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/8/html/configuring_and_managing_networking/configuring-networkmanager-to-ignore-certain-devices_configuring-and-managing-networking + if slave_ethx=$(get_ethx_by_mac "$mac" slave); then + cat >"/etc/NetworkManager/conf.d/99-$slave_ethx-unmanaged.conf" < Date: Thu, 25 Dec 2025 00:14:38 +0800 Subject: [PATCH 126/127] =?UTF-8?q?ubuntu:=20=E5=8F=AA=E7=A6=81=E7=94=A8?= =?UTF-8?q?=20cloud-init=20=E8=80=8C=E4=B8=8D=E6=98=AF=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fixes #516 --- trans.sh | 90 ++++++++++++++++++++++++++++++-------------------------- 1 file changed, 49 insertions(+), 41 deletions(-) diff --git a/trans.sh b/trans.sh index fdd088b..a001c67 100644 --- a/trans.sh +++ b/trans.sh @@ -3226,52 +3226,60 @@ chroot_systemctl_disable() { done } -remove_cloud_init() { +remove_or_disable_cloud_init() { os_dir=$1 if ! is_have_cmd_on_disk $os_dir cloud-init; then return fi - info "Remove Cloud-Init" + info "Remove or Disable Cloud-Init" - # 两种方法都可以 - if false && [ -d $os_dir/etc/cloud ]; then + # ubuntu-server-minimal ubuntu-cloud-minimal 都包含 cloud-init + # 用 iso 安装的 ubuntu 也有 cloud-init + # 因此不删除 ubuntu 的 cloud-init,而是禁用它 + + # iso 安装首次启动是通过 /etc/cloud/cloud.cfg.d/99-installer.cfg 初始化系统,包括: + # 1. 创建普通用户和密码,添加 ssh 登录公钥 + # 2. 创建 /etc/cloud/cloud-init.disabled + + if grep -iq ubuntu $os_dir/etc/os-release; then + # 模仿 iso 安装的 ubuntu,只创建 cloud-init.disabled,不禁用服务 touch $os_dir/etc/cloud/cloud-init.disabled + else + # systemctl is-enabled cloud-init-hotplugd.service 状态是 static + # disable 会出现一堆提示信息,也无法 disable + for unit in $( + chroot $os_dir systemctl list-unit-files | + grep -E '^(cloud-init|cloud-init-.*|cloud-config|cloud-final)\.(service|socket)' | grep enabled | awk '{print $1}' + ); do + # 服务不存在时会报错 + if chroot $os_dir systemctl -q is-enabled "$unit"; then + chroot $os_dir systemctl disable "$unit" + fi + done + + for pkg_mgr in dnf yum zypper apt-get; do + if is_have_cmd_on_disk $os_dir $pkg_mgr; then + case $pkg_mgr in + dnf | yum) + chroot $os_dir $pkg_mgr remove -y cloud-init + rm -f $os_dir/etc/cloud/cloud.cfg.rpmsave + ;; + zypper) + # 加上 -u 才会删除依赖 + chroot $os_dir zypper remove -y -u cloud-init cloud-init-config-suse + ;; + apt-get) + # ubuntu 25.04 开始有 cloud-init-base + chroot_apt_remove $os_dir cloud-init cloud-init-base + chroot_apt_autoremove $os_dir + ;; + esac + break + fi + done fi - - # systemctl is-enabled cloud-init-hotplugd.service 状态是 static - # disable 会出现一堆提示信息,也无法 disable - for unit in $( - chroot $os_dir systemctl list-unit-files | - grep -E '^(cloud-init|cloud-init-.*|cloud-config|cloud-final)\.(service|socket)' | grep enabled | awk '{print $1}' - ); do - # 服务不存在时会报错 - if chroot $os_dir systemctl -q is-enabled "$unit"; then - chroot $os_dir systemctl disable "$unit" - fi - done - - for pkg_mgr in dnf yum zypper apt-get; do - if is_have_cmd_on_disk $os_dir $pkg_mgr; then - case $pkg_mgr in - dnf | yum) - chroot $os_dir $pkg_mgr remove -y cloud-init - rm -f $os_dir/etc/cloud/cloud.cfg.rpmsave - ;; - zypper) - # 加上 -u 才会删除依赖 - chroot $os_dir zypper remove -y -u cloud-init cloud-init-config-suse - ;; - apt-get) - # ubuntu 25.04 开始有 cloud-init-base - chroot_apt_remove $os_dir cloud-init cloud-init-base - chroot_apt_autoremove $os_dir - ;; - esac - break - fi - done } disable_jeos_firstboot() { @@ -3387,7 +3395,7 @@ EOF if [ "$distro" = fedora ] && [ "$releasever" = 43 ]; then chroot $os_dir dnf mark user netcat -y fi - remove_cloud_init $os_dir + remove_or_disable_cloud_init $os_dir disable_selinux $os_dir disable_kdump $os_dir @@ -3414,7 +3422,7 @@ EOF find_and_mount /boot find_and_mount /boot/efi - remove_cloud_init $os_dir + remove_or_disable_cloud_init $os_dir # 获取当前开启的 Components, 后面要用 if [ -f $os_dir/etc/apt/sources.list.d/debian.sources ]; then @@ -3689,7 +3697,7 @@ EOF # 最后才删除 cloud-init # 因为生成 sysconfig 网络配置要用目标系统的 cloud-init - remove_cloud_init $os_dir + remove_or_disable_cloud_init $os_dir restore_resolv_conf $os_dir fi @@ -5082,7 +5090,7 @@ EOF # 最后才删除 cloud-init # 因为生成 netplan/sysconfig 网络配置要用目标系统的 cloud-init - remove_cloud_init /os + remove_or_disable_cloud_init /os # 删除 swapfile swapoff -a From 1a3d8b4f3bff649f6eab6e83092c5025f709f997 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Tue, 30 Dec 2025 00:18:04 +0800 Subject: [PATCH 127/127] =?UTF-8?q?windows:=20=E5=9B=BD=E5=86=85=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=20daocloud=20=E5=8A=A0=E9=80=9F=E4=B8=8B=E8=BD=BD=20w?= =?UTF-8?q?in7=20=E7=9A=84=20frpc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- get-frpc-url.sh | 3 ++- reinstall.bat | 9 ++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/get-frpc-url.sh b/get-frpc-url.sh index 33f736b..77dce3f 100644 --- a/get-frpc-url.sh +++ b/get-frpc-url.sh @@ -60,6 +60,7 @@ get_frpc_url() { mirror=$( # nju 没有 win7 用的旧版 # github 不支持 ipv6 + # daocloud 加速不支持 ipv6 # jsdelivr 不支持 github releases 文件 if is_ipv6_only; then if is_need_old_version; then @@ -71,7 +72,7 @@ get_frpc_url() { else if is_in_china; then if is_need_old_version; then - echo https://github.com/fatedier/frp/releases/download + echo https://files.m.daocloud.io/github.com/fatedier/frp/releases/download else echo https://mirrors.nju.edu.cn/github-release/fatedier/frp fi diff --git a/reinstall.bat b/reinstall.bat index 919b81e..aa69843 100644 --- a/reinstall.bat +++ b/reinstall.bat @@ -131,6 +131,13 @@ call :check_cygwin_installed || ( set dir=/sourceware/cygwin ) + rem daocloud 加速有 90 天缓存,且不支持 IPv6 + rem https://github.com/DaoCloud/public-binary-files-mirror + rem 无法用查询字符串强制刷新缓存 + rem https://files.m.daocloud.io/www.cloudflare.com/cdn-cgi/trace?a=1 + rem https://files.m.daocloud.io/www.cloudflare.com/cdn-cgi/trace?b=2 + rem 也就无法用 https://www.cygwin.com/setup-x86_64.exe?xxx=20250101 强制每天刷新缓存 + rem 下载 Cygwin if not exist setup-!CygwinArch!.exe ( call :download http://www.cygwin.com/setup-!CygwinArch!.exe %~dp0setup-!CygwinArch!.exe || goto :download_failed @@ -195,7 +202,7 @@ rem bitsadmin /transfer "%~3" /priority foreground %~1 %~2 :download rem certutil 会被 windows Defender 报毒 rem windows server 2019 要用第二条 certutil 命令 -echo Download: %~1 %~2 +echo Downloading: %~1 %~2 del /q "%~2" 2>nul if exist "%~2" (echo Cannot delete %~2 & exit /b 1)