kali: 支持安装 kali

This commit is contained in:
bin456789 2024-05-03 21:37:07 +08:00
parent 4861872518
commit 1979233c02
No known key found for this signature in database
GPG Key ID: EE301B386DE6C11B
7 changed files with 198 additions and 133 deletions

View File

@ -28,6 +28,7 @@ jobs:
${{ matrix.command }} fedora
${{ matrix.command }} ubuntu
${{ matrix.command }} debian
${{ matrix.command }} kali
${{ matrix.command }} alpine
${{ matrix.command }} opensuse
${{ matrix.command }} arch

View File

@ -10,18 +10,35 @@ One-click reinstallation script
## Highlights
- Installing using official cloud images (Cloud Image) allows bypassing the [memory requirements](https://access.redhat.com/articles/rhel-limits#minimum-required-memory-3) of traditional network installations, resulting in faster installation speed.
- Compatible with 512M + 5G small servers and supports installing Alpine or Debain on 256M small servers.
- Compatible with all network conditions, including dynamic/static IPv4/IPv6 and pure IPv4/IPv6.
- Support arbitrary conversion between the following systems (including Windows to Linux).
- Compatible low-spec servers and automatically select the appropriate official slimmed-down kernel.
- Supports installing Windows using the official ISO.
- Supports reinstalling Windows as Linux or Windows itself.
- Supports BIOS, EFI, ARM.
- The original system partition supports LVM, Btrfs.
- Supports installing Alpine, Arch, openSUSE, Gentoo, and can also install these systems from them.
- Progress of DD and cloud image installation can be viewed through SSH, browser, serial console, and web panel VNC.
- The script does not include third-party links or homemade packages; all resources are obtained in real-time from the source site.
- Automatically detect dynamic/static IPv4/IPv6, eliminating the need to fill in IP/mask/gateway (even for DD/ISO installation of Windows).
- Supports BIOS, EFI, ARM. The original system partition supports LVM, Btrfs.
- Progress of DD and cloud image installation can be viewed through SSH, HTTP port 80, serial console, and vendor backend VNC.
- The script does not include third-party homemade packages; all resources are obtained in real-time from the source site.
- Includes many comments.
## System Requirements
| Target System | Memory | Disk |
| -------------------------------------------------------- | --------- | ---------------------- |
| Alpine | 256 MB | 1 GB |
| Debian / Kali | 256 MB | 1~1.5 GB ^ |
| Ubuntu | 512 MB \* | 2 GB |
| CentOS / Alma / Rocky | 512 MB \* | 5 GB |
| Fedora | 512 MB \* | 5 GB |
| openSUSE | 512 MB \* | 5 GB |
| Arch | 512 MB | 5 GB |
| Gentoo | 512 MB | 5 GB |
| DD | 512 MB | Depending on the image |
| Windows 8.1 (Server 2012 R2) or below (ISO installation) | 512 MB | 20~25 GB |
| Windows 10 (Server 2016) or above (ISO installation) | 1G | 20~25 GB |
(\*) Indicates installation using cloud images
(^) indicates requiring either 256 MB memory + 1.5 GB disk, or 512 MB memory + 1 GB disk
## Download (Current system is Linux)
For users outside China:
@ -75,6 +92,7 @@ bash reinstall.sh centos 7|8|9 (8|9 for the stream version)
opensuse 15.5|tumbleweed
ubuntu 20.04|22.04|24.04
alpine 3.16|3.17|3.18|3.19
kali
arch
gentoo
```
@ -99,7 +117,7 @@ bash reinstall.sh alpine --hold=1
### Feature 4: Reboot to netboot.xyz
- Can install [more systems](https://github.com/netbootxyz/netboot.xyz?tab=readme-ov-file#what-operating-systems-are-currently-available-on-netbootxyz) using web panel VNC.
- Can install [more systems](https://github.com/netbootxyz/netboot.xyz?tab=readme-ov-file#what-operating-systems-are-currently-available-on-netbootxyz) using vendor backend VNC.
- If the disk content is not modified, rebooting again will return to the original system.
```bash
@ -111,16 +129,7 @@ bash reinstall.sh netboot.xyz
### Feature 5: Install Windows ISO
- Pay attention to the quotation marks around the parameters
```bash
bash reinstall.sh windows \
--image-name 'Windows 10 Enterprise LTSC 2021' \
--iso 'https://drive.massgrave.dev/en-us_windows_10_enterprise_ltsc_2021_x64_dvd_d289cf96.iso'
```
- Now supports automatically searching for Windows (including LTSC) and Windows Server ISO links.
- Need to set the language using `--lang`, default `en-us`.
- Search Source: <https://massgrave.dev/genuine-installation-media.html>
- Supports automatically searching for some ISO links. Need to set the language using `--lang`, default is `en-us`.
```bash
bash reinstall.sh windows \
@ -128,6 +137,14 @@ bash reinstall.sh windows \
--lang zh-cn
```
- You can also specify an ISO link.
```bash
bash reinstall.sh windows \
--image-name 'Windows 10 Enterprise LTSC 2021' \
--iso 'https://drive.massgrave.dev/en-us_windows_10_enterprise_ltsc_2021_x64_dvd_d289cf96.iso'
```
![Installing Windows](https://github.com/bin456789/reinstall/assets/7548515/07c1aea2-1ce3-4967-904f-aaf9d6eec3f7)
Parameters Description:
@ -179,21 +196,6 @@ Use `Dism++` File menu > Open Image File, select the iso to be installed to get
<https://www.microsoft.com/software-download/windows11>
## Memory Requirements
| System | Traditional Installation | Cloud Image |
| ------------------------------------- | ------------------------ | ----------- |
| CentOS / Alma / Rocky | - | 512M |
| Fedora | - | 512M |
| openSUSE | - | 512M |
| Ubuntu | - | 512M |
| Debian | 256M | |
| Alpine | 256M | - |
| Arch | 512M | - |
| Gentoo | 512M | - |
| Windows 8.1 (Server 2012 R2) or below | 512M | - |
| Windows 10 (Server 2016) or above | 1G | - |
## Virtualization Requirements
Not supported on OpenVZ, LXC virtual machines.

View File

@ -10,18 +10,35 @@
## 亮点
- 使用官方云镜像 (Cloud Image) 安装,可绕过传统网络安装的 [内存要求](https://access.redhat.com/articles/rhel-limits#minimum-required-memory-3),且安装速度更快
- 支持 512M + 5G 小鸡,也支持 256M 小鸡安装 Alpine、Debian
- 支持所有网络情况,包括动静态 IPv4/IPv6纯 IPv4/IPv6
- 支持以下系统任意转换(包括 Windows 转 Linux
- 适配低配小鸡,并自动选择合适的官方精简内核
- 支持用官方 iso 安装 Windows
- 支持 Windows 重装成 Linux也支持重装 Windows
- 支持 BIOS、EFI、ARM
- 原系统分区支持 LVM、Btrfs
- 支持安装 Alpine、Arch、openSUSE、Gentoo也可从这些系统安装
- 可通过 SSH、浏览器、串行控制台、后台 VNC 查看 DD、云镜像安装进度
- 不含第三方链接和自制包,所有资源均实时从源站点获得
- 自动判断动静态 IPv4 / IPv6无需填写 IP / 掩码 / 网关(即使是 DD / ISO 安装 Windows
- 支持 BIOS、EFI、ARM原系统分区支持 lvm、btrfs
- 可通过 SSH、HTTP 80 端口、串行控制台、商家后台 VNC 查看 DD、云镜像安装进度
- 不含第三方自制包,所有资源均实时从源站点获得
- 有很多注释
## 配置要求
| 目标系统 | 内存 | 硬盘 |
| ---------------------------------------------- | --------- | ---------- |
| Alpine | 256 MB | 1 GB |
| Debian / Kali | 256 MB | 1~1.5 GB ^ |
| Ubuntu | 512 MB \* | 2 GB |
| CentOS / Alma / Rocky | 512 MB \* | 5 GB |
| Fedora | 512 MB \* | 5 GB |
| openSUSE | 512 MB \* | 5 GB |
| Arch | 512 MB | 5 GB |
| Gentoo | 512 MB | 5 GB |
| DD | 512 MB | 取决于镜像 |
| Windows 8.1 (Server 2012 R2) 或以下 (ISO 安装) | 512 MB | 20~25 GB |
| Windows 10 (Server 2016) 或以上 (ISO 安装) | 1024 MB | 20~25 GB |
(\*) 表示使用云镜像安装
(^) 需要 256 MB 内存 + 1.5 GB 硬盘,或 512 MB 内存 + 1 GB 硬盘
## 下载(当前系统是 Linux
国外:
@ -75,6 +92,7 @@ bash reinstall.sh centos 7|8|9 (8|9 为 stream 版本)
opensuse 15.5|tumbleweed
ubuntu 20.04|22.04|24.04
alpine 3.16|3.17|3.18|3.19
kali
arch
gentoo
```
@ -99,7 +117,7 @@ bash reinstall.sh alpine --hold=1
### 功能 4: 重启到 netboot.xyz
- 可使用后台 VNC 安装 [更多系统](https://github.com/netbootxyz/netboot.xyz?tab=readme-ov-file#what-operating-systems-are-currently-available-on-netbootxyz)
- 可使用商家后台 VNC 安装 [更多系统](https://github.com/netbootxyz/netboot.xyz?tab=readme-ov-file#what-operating-systems-are-currently-available-on-netbootxyz)
- 如果没有修改硬盘内容,再次重启将回到原系统
```bash
@ -111,16 +129,7 @@ bash reinstall.sh netboot.xyz
### 功能 5: 安装 Windows ISO
- 注意参数两边的引号
```bash
bash reinstall.sh windows \
--image-name 'Windows 10 Enterprise LTSC 2021' \
--iso 'https://drive.massgrave.dev/en-us_windows_10_enterprise_ltsc_2021_x64_dvd_d289cf96.iso'
```
- 现在脚本支持自动查找 Windows (含 LTSC) 和 Windows Server iso 链接
- 需设置语言 `--lang`,默认 `en-us`
- 查找源:<https://massgrave.dev/genuine-installation-media.html>
- 支持自动查找部分 iso 链接,需设置语言 `--lang`,默认 `en-us`
```bash
bash reinstall.sh windows \
@ -128,6 +137,14 @@ bash reinstall.sh windows \
--lang zh-cn
```
- 也可以指定 iso 链接
```bash
bash reinstall.sh windows \
--image-name 'Windows 10 Enterprise LTSC 2021' \
--iso 'https://drive.massgrave.dev/en-us_windows_10_enterprise_ltsc_2021_x64_dvd_d289cf96.iso'
```
![Installing Windows](https://github.com/bin456789/reinstall/assets/7548515/07c1aea2-1ce3-4967-904f-aaf9d6eec3f7)
参数说明:
@ -179,21 +196,6 @@ Windows Server 2022 SERVERDATACENTER
<https://www.microsoft.com/software-download/windows11>
## 内存要求
| 系统 | 传统安装 | 云镜像 |
| ----------------------------------- | -------- | ------ |
| CentOS / Alma / Rocky | - | 512M |
| Fedora | - | 512M |
| openSUSE | - | 512M |
| Ubuntu | - | 512M |
| Debian | 256M | - |
| Alpine | 256M | - |
| Arch | 512M | - |
| Gentoo | 512M | - |
| Windows 8.1 (Server 2012 R2) 或以下 | 512M | - |
| Windows 10 (Server 2016) 或以上 | 1G | - |
## 虚拟化要求
不支持 OpenVZ、LXC 虚拟机

View File

@ -32,7 +32,8 @@ else
fi
get_first_ipv4_addr() {
# debian 11 initrd 没有 awk
# debian 11 initrd 没有 xargs awk
# debian 12 initrd 没有 xargs
if false; then
ip -4 -o addr show scope global dev "$ethx" | head -1 | awk '{print $4}'
else

View File

@ -19,13 +19,14 @@ d-i netcfg/hostname string localhost
# B.4.4. 镜像设置
d-i mirror/country string manual
d-i mirror/http/hostname string deb.debian.org
d-i mirror/http/directory string /debian/
# d-i mirror/http/hostname string deb.debian.org
# B.4.5. 帐号设置
d-i passwd/make-user boolean false
d-i passwd/root-password password 123@@@
d-i passwd/root-password-again password 123@@@
# kali 需要下面这行,否则会提示输入用户名
d-i passwd/root-login boolean true
# B.4.6. 时钟与时区设置
d-i time/zone string Asia/Shanghai
@ -58,7 +59,6 @@ d-i partman-efi/non_efi_system boolean true
# 选择 true 就一直死循环
d-i partman-basicfilesystems/no_swap boolean false
# 最小值 膨胀权重 最大值
# https://salsa.debian.org/installer-team/partman-auto/-/blob/master/recipes/atomic?ref_type=heads
# https://salsa.debian.org/installer-team/partman-auto/-/blob/master/recipes-amd64-efi/atomic?ref_type=heads
@ -81,8 +81,8 @@ d-i apt-setup/non-free boolean true
d-i apt-setup/non-free-firmware boolean true
d-i apt-setup/contrib boolean true
d-i apt-setup/enable-source-repositories boolean false
d-i apt-setup/services-select multiselect security, updates
d-i apt-setup/security_host string security.debian.org
# kali 不要设置
# d-i apt-setup/security_host string security.debian.org
# B.4.10. 选择软件包
tasksel tasksel/first multiselect ssh-server
@ -97,24 +97,29 @@ d-i finish-install/reboot_in_progress note
# B.4.13. 预置其他的软件包
# 其他设置
# d-i anna/standard_modules boolean false
# d-i anna/choose_modules string network-console
# d-i network-console/password password 123@@@
# d-i network-console/password-again password 123@@@
# B.5.1. 安装过程中运行用户命令
d-i preseed/early_command string \
hostname="$(grep -o 'extra\.deb_hostname=[^ ]*' /proc/cmdline | cut -d= -f2)"; \
debconf-set mirror/http/hostname "$hostname"
# d-i preseed/early_command string
# debian 11 initrd 没有 xargs awk
# debian 12 initrd 没有 xargs
d-i partman/early_command string \
confhome="$(grep -o 'extra\.confhome=[^ ]*' /proc/cmdline | cut -d= -f2)"; \
swapfile=/target/swapfile; \
postinst=/var/lib/dpkg/info/bootstrap-base.postinst; \
cp $postinst $postinst.orig; \
mem=$(grep ^MemTotal: /proc/meminfo | { read x y z; echo $y; }); \
mem=$((mem / 1024)); \
swap_size=$((512 - mem)); \
[ $swap_size -gt 0 ] && echo "fallocate -l ${swap_size}M $swapfile; mkswap $swapfile; swapon $swapfile; $postinst.orig" >$postinst; \
echo "swapoff -a; rm -f $swapfile" >/usr/lib/finish-install.d/95swapoff; \
chmod a+x /usr/lib/finish-install.d/95swapoff; \
@ -126,9 +131,7 @@ d-i partman/early_command string \
ttys=$(wget --tries=5 $confhome/ttys.sh -O- | sh -s console=); \
debconf-set debian-installer/add-kernel-opts "$ttys"; \
kernel="$(grep -o 'extra\.kernel=[^ ]*' /proc/cmdline | cut -d= -f2)"; \
. /can_use_cloud_kernel.sh || kernel=$(echo "$kernel" | sed 's/-cloud//'); \
debconf-set base-installer/kernel/image "$kernel"; \
. /can_use_cloud_kernel.sh || debconf-set base-installer/kernel/image $(debconf-get base-installer/kernel/image | sed 's/-cloud//'); \
[ -d /sys/firmware/efi ] && debconf-set partman-auto/expert_recipe "$(debconf-get partman-auto/expert_recipe_efi)"; \
[ -d /sys/firmware/efi ] || debconf-set partman-auto/expert_recipe "$(debconf-get partman-auto/expert_recipe_bios)"; \
@ -138,6 +141,8 @@ d-i partman/early_command string \
# os-prober 卡太久,因此跳过
# debian 10 没有 /target/etc/ssh/sshd_config.d/ 文件夹
# kali ssh 默认关闭
d-i preseed/late_command string \
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

View File

@ -34,6 +34,7 @@ Usage: $reinstall____ centos 7|8|9
ubuntu 20.04|22.04|24.04
alpine 3.16|3.17|3.18|3.19
opensuse 15.5|tumbleweed
kali
arch
gentoo
dd --img='http://xxx'
@ -162,6 +163,10 @@ is_have_initrd() {
! is_netboot_xyz
}
is_use_firmware() {
[ "$distro" = debian ] && ! is_virt
}
get_host_by_url() {
cut -d/ -f3 <<<$1
}
@ -738,18 +743,18 @@ setos() {
12) codename=bookworm ;;
esac
if is_in_china; then
cdimage_mirror=https://mirrors.ustc.edu.cn/debian-cdimage
else
cdimage_mirror=https://cdimage.debian.org/images
fi
if is_use_cloud_image; then
# cloud image
if is_in_china; then
ci_mirror=https://mirror.nju.edu.cn/debian-cdimage
else
ci_mirror=https://cdimage.debian.org/images
fi
is_virt && ci_type=genericcloud || ci_type=generic
# 甲骨文 debian 10 amd64 genericcloud vnc 没有显示
[ "$releasever" -eq 10 ] && [ "$basearch_alt" = amd64 ] && ci_type=generic
eval ${step}_img=$ci_mirror/cloud/$codename/latest/debian-$releasever-$ci_type-$basearch_alt.qcow2
eval ${step}_img=$cdimage_mirror/cloud/$codename/latest/debian-$releasever-$ci_type-$basearch_alt.qcow2
else
# 传统安装
if is_in_china; then
@ -758,17 +763,44 @@ setos() {
else
deb_hostname=deb.debian.org
fi
mirror=http://$deb_hostname/debian/dists/$codename/main/installer-$basearch_alt/current/images/netboot/debian-installer/$basearch_alt
eval ${step}_vmlinuz=$mirror/linux
eval ${step}_initrd=$mirror/initrd.gz
eval ${step}_ks=$confhome/debian.cfg
is_virt && flavour=-cloud || flavour=
# 甲骨文 debian 10 amd64 cloud 内核 vnc 没有显示
[ "$releasever" -eq 10 ] && [ "$basearch_alt" = amd64 ] && flavour=
# shellcheck disable=SC2034
kernel=linux-image$flavour-$basearch_alt
eval ${step}_vmlinuz=$mirror/linux
eval ${step}_initrd=$mirror/initrd.gz
eval ${step}_ks=$confhome/debian.cfg
eval ${step}_firmware=$cdimage_mirror/firmware/$codename/current/firmware.cpio.gz
eval ${step}_deb_hostname=$deb_hostname
eval ${step}_codename=$codename
eval ${step}_kernel=linux-image$flavour-$basearch_alt
fi
}
setos_kali() {
if is_use_cloud_image; then
:
else
# 传统安装
if is_in_china; then
deb_hostname=mirrors.tuna.tsinghua.edu.cn
else
deb_hostname=kali.download
fi
codename=kali-rolling
mirror=http://$deb_hostname/kali/dists/$codename/main/installer-$basearch_alt/current/images/netboot/debian-installer/$basearch_alt
is_virt && flavour=-cloud || flavour=
eval ${step}_vmlinuz=$mirror/linux
eval ${step}_initrd=$mirror/initrd.gz
eval ${step}_ks=$confhome/debian.cfg
eval ${step}_deb_hostname=$deb_hostname
eval ${step}_codename=$codename
eval ${step}_kernel=linux-image$flavour-$basearch_alt
# 缺少 firmware 下载
fi
}
@ -1035,7 +1067,11 @@ setos() {
}
is_distro_like_redhat() {
[ "$1" = centos ] || [ "$1" = alma ] || [ "$1" = rocky ] || [ "$1" = fedora ]
[ "$distro" = centos ] || [ "$distro" = alma ] || [ "$distro" = rocky ] || [ "$distro" = fedora ]
}
is_distro_like_debian() {
[ "$distro" = debian ] || [ "$distro" = kali ]
}
# 检查是否为正确的系统名
@ -1053,6 +1089,7 @@ verify_os_name() {
'ubuntu 20.04|22.04|24.04' \
'alpine 3.16|3.17|3.18|3.19' \
'opensuse 15.5|tumbleweed' \
'kali' \
'arch' \
'gentoo' \
'windows' \
@ -1253,7 +1290,7 @@ check_ram() {
ram_standard=$(
case "$distro" in
netboot.xyz) echo 0 ;;
alpine | debian | dd) echo 256 ;;
alpine | debian | kali | dd) echo 256 ;;
arch | gentoo | windows) echo 512 ;;
centos | alma | rocky | fedora | ubuntu) echo 1024 ;;
opensuse) echo -1 ;; # 没有安装模式
@ -1271,7 +1308,7 @@ check_ram() {
has_cloud_image=$(
case "$distro" in
centos | alma | rocky | fedora | debian | ubuntu | opensuse) echo true ;;
netboot.xyz | alpine | dd | arch | gentoo | windows) echo false ;;
netboot.xyz | alpine | dd | arch | gentoo | kali | windows) echo false ;;
esac
)
@ -1773,7 +1810,7 @@ build_finalos_cmdline() {
}
build_extra_cmdline() {
for key in confhome hold cloud_image kernel deb_hostname main_disk; do
for key in confhome hold cloud_image main_disk; do
value=${!key}
if [ -n "$value" ]; then
extra_cmdline+=" extra.$key='$value'"
@ -1804,14 +1841,22 @@ get_entry_name() {
build_nextos_cmdline() {
if [ $nextos_distro = alpine ]; then
nextos_cmdline="alpine_repo=$nextos_repo modloop=$nextos_modloop"
elif [ $nextos_distro = debian ]; then
nextos_cmdline="lowmem/low=1 auto=true priority=critical url=$nextos_ks"
else
elif is_distro_like_debian; then
nextos_cmdline="lowmem/low=1 auto=true priority=critical"
nextos_cmdline+=" url=$nextos_ks"
nextos_cmdline+=" mirror/http/hostname=$nextos_deb_hostname"
nextos_cmdline+=" mirror/http/directory=/$nextos_distro"
nextos_cmdline+=" base-installer/kernel/image=$nextos_kernel"
# kali 安装好后网卡是 eth0 这种格式,但安装时不是
if [ "$nextos_distro" = kali ]; then
nextos_cmdline+=" net.ifnames=0"
fi
elif is_distro_like_redhat; then
# redhat
nextos_cmdline="root=live:$nextos_squashfs inst.ks=$nextos_ks"
fi
if [ $nextos_distro = debian ]; then
if is_distro_like_debian; then
if [ "$basearch" = "x86_64" ]; then
# debian 安装界面不遵循最后一个 tty 为主 tty 的规则
# 设置ttyS0,tty0,安装界面还是显示在ttyS0
@ -1826,6 +1871,7 @@ build_nextos_cmdline() {
nextos_cmdline+=" console=ttyS0,115200 console=ttyAMA0,115200 console=tty0"
fi
# nextos_cmdline+=" mem=256M"
# nextos_cmdline+=" lowmem=+1"
}
build_cmdline() {
@ -1931,25 +1977,22 @@ EOF
# shellcheck disable=SC2317
expand_packages() {
expand_packages_real "$@" | while read -r k_ v; do
# shellcheck disable=SC2001
case $(echo "$k_" | sed 's/://') in
Package)
package="$v"
expand_packages_real "$@" | while IFS= read -r line; do
key_=$(echo "$line" | cut -d' ' -f1)
value=$(echo "$line" | cut -d' ' -f2-)
case "$key_" in
Package:)
package="$value"
;;
Priority)
Priority:)
# shellcheck disable=SC2154
if [ "$v" = standard ] && echo "$disabled_list" | grep -qx "$package"; then
v=optional
if [ "$value" = standard ] && echo "$disabled_list" | grep -qx "$package"; then
line="Priority: optional"
fi
;;
esac
if [ -z "$k_" ]; then
echo
else
echo "$k_ $v"
fi
echo "$line"
done
}
@ -2013,12 +2056,13 @@ EOF
# 获取 udeb 列表
udeb_list=$tmp/udeb_list
if ! [ -f $udeb_list ]; then
curl -L http://$deb_hostname/debian/dists/$codename/main/debian-installer/binary-$basearch_alt/Packages.gz |
# shellcheck disable=SC2154
curl -L http://$nextos_deb_hostname/$distro/dists/$nextos_codename/main/debian-installer/binary-$basearch_alt/Packages.gz |
zcat | grep 'Filename:' | awk '{print $2}' >$udeb_list
fi
# 下载 udeb
curl -Lo $tmp/tmp.udeb http://$deb_hostname/debian/"$(grep /$package $udeb_list)"
curl -Lo $tmp/tmp.udeb http://$nextos_deb_hostname/$distro/"$(grep /$package $udeb_list)"
if false; then
# 使用 dpkg
@ -2089,7 +2133,7 @@ EOF
# xen 是 vbd
nvme | virtio_blk | virtio_scsi | vbd | hv_storvsc | vmw_pvscsi) extra_drivers+=" $driver" ;;
pata_legacy) sed -i '/^pata-modules/d' $net_retriever ;;
pata_* | sata_* | ahci) error_and_exit "Debian cloud kernel does not support this driver: $driver" ;;
pata_* | sata_* | ahci) error_and_exit "Cloud kernel does not support this driver: $driver" ;;
esac
done
@ -2136,7 +2180,7 @@ EOF
# 修改 trans.sh
# 1. 直接调用 create_ifupdown_config
insert_into_file $tmp_dir/trans.sh after ': main' <<EOF
distro=debian
distro=$nextos_distro
create_ifupdown_config /etc/network/interfaces
exit
EOF
@ -2289,7 +2333,11 @@ mod_initrd() {
curl -Lo $tmp_dir/trans.sh $confhome/trans.sh
curl -Lo $tmp_dir/alpine-network.sh $confhome/alpine-network.sh
mod_initrd_$nextos_distro
if is_distro_like_debian; then
mod_initrd_debian
else
mod_initrd_$nextos_distro
fi
# 显示精简前的大小
du -sh .
@ -2452,11 +2500,11 @@ install_pkg curl grep
# /tmp 挂载在内存的话,可能不够空间
tmp=/reinstall-tmp
mkdir -p "$tmp"
mkdir_clear "$tmp"
# 强制忽略/强制添加 --ci 参数
case "$distro" in
dd | windows | netboot.xyz | debian | alpine | arch | gentoo)
dd | windows | netboot.xyz | debian | kali | alpine | arch | gentoo)
if is_use_cloud_image; then
echo "ignored --ci"
cloud_image=0
@ -2514,10 +2562,10 @@ fi
# el8/9/fedora 任何架构 >=2g
if is_netboot_xyz ||
{ ! is_use_cloud_image && {
[ "$distro" = "alpine" ] || [ "$distro" = "debian" ] ||
{ is_distro_like_redhat "$distro" && [ $releasever -eq 7 ] && [ $ram_size -ge 1024 ] && [ $basearch = "x86_64" ]; } ||
{ is_distro_like_redhat "$distro" && [ $releasever -eq 7 ] && [ $ram_size -ge 1536 ] && [ $basearch = "aarch64" ]; } ||
{ is_distro_like_redhat "$distro" && [ $releasever -ge 8 ] && [ $ram_size -ge 2048 ]; }
[ "$distro" = "alpine" ] || is_distro_like_debian ||
{ is_distro_like_redhat && [ $releasever -eq 7 ] && [ $ram_size -ge 1024 ] && [ $basearch = "x86_64" ]; } ||
{ is_distro_like_redhat && [ $releasever -eq 7 ] && [ $ram_size -ge 1536 ] && [ $basearch = "aarch64" ]; } ||
{ is_distro_like_redhat && [ $releasever -ge 8 ] && [ $ram_size -ge 2048 ]; }
}; }; then
setos nextos $distro $releasever
else
@ -2572,10 +2620,13 @@ else
info download vmlnuz and initrd
curl -Lo /reinstall-vmlinuz $nextos_vmlinuz
curl -Lo /reinstall-initrd $nextos_initrd
if is_use_firmware; then
curl -Lo /reinstall-firmware $nextos_firmware
fi
fi
# 修改 alpine debian initrd
if [ "$nextos_distro" = alpine ] || [ "$nextos_distro" = debian ]; then
# 修改 alpine debian kali initrd
if [ "$nextos_distro" = alpine ] || is_distro_like_debian; then
mod_initrd
fi
@ -2697,6 +2748,7 @@ if is_use_grub; then
vmlinuz=${dir}reinstall-vmlinuz
initrd=${dir}reinstall-initrd
firmware=${dir}reinstall-firmware
# 生成 linux initrd 命令
if is_netboot_xyz; then
@ -2706,6 +2758,9 @@ if is_use_grub; then
build_cmdline
linux_cmd="linux$efi $vmlinuz $cmdline"
initrd_cmd="initrd$efi $initrd"
if is_use_firmware; then
initrd_cmd+=" $firmware"
fi
fi
# 生成 grub 配置

View File

@ -637,8 +637,7 @@ create_ifupdown_config() {
rm -f $conf_file
# shellcheck disable=SC2154
if [ "$distro" = debian ]; then
if [ "$distro" = debian ] || [ "$distro" = kali ]; then
cat <<EOF >>$conf_file
source /etc/network/interfaces.d/*