mirror of
https://github.com/bin456789/reinstall.git
synced 2025-07-06 19:19:52 +00:00
Compare commits
No commits in common. "0da940b2a79aeb41bd4b9f4cb8110228a4bae25b" and "f3d86945672f4cebf37f64902e880b5dec739abf" have entirely different histories.
0da940b2a7
...
f3d8694567
@ -342,7 +342,7 @@ zh-tw
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
bash reinstall.sh windows \
|
bash reinstall.sh windows \
|
||||||
--image-name "Windows 11 Enterprise LTSC 2024 Evaluation" \
|
--image-name "Windows 11 Enterprise LTSC 2024" \
|
||||||
--iso "https://go.microsoft.com/fwlink/?linkid=2289029"
|
--iso "https://go.microsoft.com/fwlink/?linkid=2289029"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -342,7 +342,7 @@ zh-tw
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
bash reinstall.sh windows \
|
bash reinstall.sh windows \
|
||||||
--image-name "Windows 11 Enterprise LTSC 2024 Evaluation" \
|
--image-name "Windows 11 Enterprise LTSC 2024" \
|
||||||
--iso "https://go.microsoft.com/fwlink/?linkid=2289029"
|
--iso "https://go.microsoft.com/fwlink/?linkid=2289029"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
47
trans.sh
47
trans.sh
@ -46,8 +46,6 @@ warn() {
|
|||||||
|
|
||||||
error_and_exit() {
|
error_and_exit() {
|
||||||
error "$@"
|
error "$@"
|
||||||
echo "Run '/trans.sh' to retry." >&2
|
|
||||||
echo "Run '/trans.sh alpine' to install Alpine Linux instead." >&2
|
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,12 +53,10 @@ trap_err() {
|
|||||||
line_no=$1
|
line_no=$1
|
||||||
ret_no=$2
|
ret_no=$2
|
||||||
|
|
||||||
error_and_exit "$(
|
error "Line $line_no return $ret_no"
|
||||||
echo "Line $line_no return $ret_no"
|
|
||||||
if [ -f "/trans.sh" ]; then
|
if [ -f "/trans.sh" ]; then
|
||||||
sed -n "$line_no"p /trans.sh
|
sed -n "$line_no"p /trans.sh
|
||||||
fi
|
fi
|
||||||
)"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
is_run_from_locald() {
|
is_run_from_locald() {
|
||||||
@ -3888,17 +3884,15 @@ chroot_apt_remove() {
|
|||||||
|
|
||||||
# 不能用 apt remove --purge -y xxx yyy
|
# 不能用 apt remove --purge -y xxx yyy
|
||||||
# 因为如果索引里没有其中一个,会报错,另一个也不会删除
|
# 因为如果索引里没有其中一个,会报错,另一个也不会删除
|
||||||
local pkgs=
|
# 因此需要分开删除
|
||||||
for pkg in "$@"; do
|
for package in "$@"; do
|
||||||
# apt list 会提示 WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
|
# apt list 会提示 WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
|
||||||
# 但又不能用 apt-get list
|
# 但又不能用 apt-get list
|
||||||
if chroot $os_dir apt list --installed "$pkg" | grep -q installed; then
|
if chroot $os_dir apt list --installed "$package" | grep -q installed; then
|
||||||
pkgs="$pkgs $pkg"
|
# 删除 resolvconf 时会弹出建议重启,因此添加 noninteractive
|
||||||
|
DEBIAN_FRONTEND=noninteractive chroot $os_dir apt-get remove --purge -y "$package"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# 删除 resolvconf 时会弹出建议重启,因此添加 noninteractive
|
|
||||||
DEBIAN_FRONTEND=noninteractive chroot $os_dir apt-get remove --purge --allow-remove-essential -y $pkgs
|
|
||||||
}
|
}
|
||||||
|
|
||||||
chroot_apt_autoremove() {
|
chroot_apt_autoremove() {
|
||||||
@ -4243,12 +4237,8 @@ EOF
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# 主 grub.cfg
|
# 主 grub.cfg
|
||||||
if ls /os/boot/loader/entries/*.conf >/dev/null 2>&1 &&
|
# --update-bls-cmdline
|
||||||
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"
|
chroot /os/ grub2-mkconfig -o "$grub_o_cfg"
|
||||||
fi
|
|
||||||
|
|
||||||
# 网络配置
|
# 网络配置
|
||||||
# el7/8 sysconfig
|
# el7/8 sysconfig
|
||||||
@ -4370,24 +4360,6 @@ configfile \$prefix/grub.cfg
|
|||||||
EOF
|
EOF
|
||||||
fi
|
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
|
# 常规版本 generic
|
||||||
# minimal 20.04/22.04 kvm # 后台 vnc 无显示
|
# minimal 20.04/22.04 kvm # 后台 vnc 无显示
|
||||||
@ -4470,6 +4442,11 @@ EOF
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# 安装 bios 引导
|
||||||
|
if ! is_efi; then
|
||||||
|
chroot $os_dir grub-install /dev/$xda
|
||||||
|
fi
|
||||||
|
|
||||||
# 更改 efi 目录的 grub.cfg 写死的 fsuuid
|
# 更改 efi 目录的 grub.cfg 写死的 fsuuid
|
||||||
# 因为 24.04 fsuuid 对应 boot 分区
|
# 因为 24.04 fsuuid 对应 boot 分区
|
||||||
efi_grub_cfg=$os_dir/boot/efi/EFI/ubuntu/grub.cfg
|
efi_grub_cfg=$os_dir/boot/efi/EFI/ubuntu/grub.cfg
|
||||||
|
Loading…
x
Reference in New Issue
Block a user