diff --git a/README.en.md b/README.en.md
index 3fc4a81..e08b965 100644
--- a/README.en.md
+++ b/README.en.md
@@ -149,10 +149,35 @@ bash reinstall.sh centos 9
> When installing other systems, can monitor the progress through various methods (SSH, HTTP 80 port, VNC in the background, serial console).
> Even if errors occur during the installation process, you can still install Alpine via SSH.
+
+
+Experimental Features
+
+Install Debian using a cloud image, suitable for machines with slower CPUs
+
+```bash
+bash reinstall.sh debian --ci
+```
+
+Install CentOS, Alma, Rocky, Fedora using ISO, only supports machines with more than 2G of memory and dynamic IP
+
+```bash
+bash reinstall.sh centos --installer
+```
+
+Install Ubuntu using ISO, only supports machines with more than 1G of memory and dynamic IP
+
+```bash
+bash reinstall.sh ubuntu --installer
+```
+
+
+
### Feature 2: DD
-- Supports `raw`, `vhd`, `gzip` and `xz` formatted images
-- When using DD with a Windows image, the script will automatically expand the system partition. For static IP machines, the IP will be configured automatically, and it may take a few minutes to take effect on first boot
+- Supports `raw`, `vhd` images or those compressed with `xz` or `gzip`.
+- When deploy a Windows image, the system disk will be expanded, and machines with static IPs will have their IPs configured. However, it may take a few minutes after the first boot for the configuration to take effect.
+- When deploy a Linux image, the system disk **will not** be expanded, and machines with static IPs **will not** have their IPs configured.
```bash
bash reinstall.sh dd --img https://example.com/xxx.xz
diff --git a/README.md b/README.md
index d389807..4c640fc 100644
--- a/README.md
+++ b/README.md
@@ -149,10 +149,35 @@ bash reinstall.sh centos 9
> 安装其它系统时,可通过多种方式(SSH、HTTP 80 端口、后台 VNC、串行控制台)查看安装进度。
> 即使安装过程出错,也能通过 SSH 安装到 Alpine。
+
+
+实验性功能
+
+用云镜像安装 Debian,适合于 CPU 较慢的机器
+
+```bash
+bash reinstall.sh debian --ci
+```
+
+用 ISO 安装 CentOS, Alma, Rocky, Fedora ,仅支持内存大于 2G 且为动态 IP 的机器
+
+```bash
+bash reinstall.sh centos --installer
+```
+
+用 ISO 安装 Ubuntu ,仅支持内存大于 1G 且为动态 IP 的机器
+
+```bash
+bash reinstall.sh ubuntu --installer
+```
+
+
+
### 功能 2: DD
-- 支持 `raw`、`vhd`、`gzip`、`xz` 格式的镜像
-- DD Windows 镜像时,会自动扩展系统盘。静态的机器会自动配置好 IP,可能首次开机几分钟后才生效
+- 支持 `raw` `vhd` 或者经过 `xz` `gzip` 压缩的镜像
+- DD Windows 镜像时,会扩展系统盘,静态 IP 的机器会配置好 IP,可能首次开机几分钟后才生效
+- DD Linux 镜像时,**不会**扩展系统盘,静态 IP 的机器**不会**配置好 IP
```bash
bash reinstall.sh dd --img https://example.com/xxx.xz
diff --git a/alpine-network.sh b/alpine-network.sh
index 45ab090..74ed983 100644
--- a/alpine-network.sh
+++ b/alpine-network.sh
@@ -129,7 +129,7 @@ test_internet() {
echo 'Testing Internet Connection...'
# debian 没有 nslookup,因此用 ping
- for i in $(seq 5); do
+ for i in $(seq 10); do
if is_need_test_ipv4 && ping -c1 -W5 -I "$ethx" "$ipv4_dns1" >/dev/null 2>&1; then
echo "IPv4 has internet."
ipv4_has_internet=true
diff --git a/reinstall.sh b/reinstall.sh
index 54dbcd1..b6f71a4 100644
--- a/reinstall.sh
+++ b/reinstall.sh
@@ -844,6 +844,19 @@ setos() {
directory=extended-lts
initrd_mirror=archive.debian.org
fi
+ if is_in_china; then
+ warn "
+Due to the lack of Debian Freexian ELTS instaler mirrors in China, the installation time may be longer.
+Continue?
+
+由于没有 Debian Freexian ELTS 国内安装源,安装时间可能会比较长。
+继续安装?
+"
+ read -r -p '[y/N]: '
+ if ! [[ "$REPLY" = [Yy] ]]; then
+ exit
+ fi
+ fi
else
if is_in_china; then
# ftp.cn.debian.org 不在国内还严重丢包
@@ -1089,7 +1102,7 @@ setos() {
if [ -z "$iso" ]; then
# 查找时将 windows longhorn serverdatacenter 改成 windows server 2008 serverdatacenter
image_name=${image_name/windows longhorn server/windows server 2008 server}
- echo "iso url is not set. Try to find it."
+ echo "iso url is not set. Attempting to find it automatically."
find_windows_iso
fi
@@ -1424,7 +1437,7 @@ install_pkg() {
# https://github.com/chef/os_release
case "$id" in
fedora | centos | rhel) is_have_cmd dnf && pkg_mgr=dnf || pkg_mgr=yum ;;
- debian | ubuntu) pkg_mgr=apt ;;
+ debian | ubuntu) pkg_mgr=apt-get ;;
opensuse | suse) pkg_mgr=zypper ;;
alpine) pkg_mgr=apk ;;
arch) pkg_mgr=pacman ;;
@@ -1437,7 +1450,7 @@ install_pkg() {
fi
# 查找方法 2
- for mgr in dnf yum apt pacman zypper emerge apk opkg nix-env; do
+ for mgr in dnf yum apt-get pacman zypper emerge apk opkg nix-env; do
is_have_cmd $mgr && pkg_mgr=$mgr && return
done
@@ -1454,7 +1467,7 @@ install_pkg() {
;;
xz)
case "$pkg_mgr" in
- apt) pkg="xz-utils" ;;
+ apt-get) pkg="xz-utils" ;;
*) pkg="xz" ;;
esac
;;
@@ -1472,14 +1485,14 @@ install_pkg() {
;;
fdisk)
case "$pkg_mgr" in
- apt) pkg="fdisk" ;;
+ apt-get) pkg="fdisk" ;;
apk) pkg="util-linux-misc" ;;
*) pkg="util-linux" ;;
esac
;;
hexdump)
case "$pkg_mgr" in
- apt) pkg="bsdmainutils" ;;
+ apt-get) pkg="bsdmainutils" ;;
*) pkg="util-linux" ;;
esac
;;
@@ -1492,7 +1505,7 @@ install_pkg() {
;;
nslookup | dig)
case "$pkg_mgr" in
- apt) pkg="dnsutils" ;;
+ apt-get) pkg="dnsutils" ;;
pacman) pkg="bind" ;;
apk | emerge) pkg="bind-tools" ;;
yum | dnf | zypper) pkg="bind-utils" ;;
@@ -1559,9 +1572,9 @@ install_pkg() {
add_community_repo_for_alpine
apk add $pkg
;;
- apt)
- [ -z "$apt_updated" ] && apt update && apt_updated=1
- DEBIAN_FRONTEND=noninteractive apt install -y $pkg
+ apt-get)
+ [ -z "$apt_updated" ] && apt-get update && apt_updated=1
+ DEBIAN_FRONTEND=noninteractive apt-get install -y $pkg
;;
opkg)
[ -z "$opkg_updated" ] && opkg update && opkg_updated=1
@@ -1605,7 +1618,7 @@ install_pkg() {
cmd_to_pkg
install_pkg_real
fi
- done
+ done >&2
}
check_ram() {
diff --git a/trans.sh b/trans.sh
index dc1411b..28c4c08 100644
--- a/trans.sh
+++ b/trans.sh
@@ -59,13 +59,21 @@ add_community_repo() {
# 有时网络问题下载失败,导致脚本中断
# 因此需要重试
apk() {
- retry 5 command apk "$@"
+ retry 5 command apk "$@" >&2
}
-# busybox 的 wget 没有重试功能
+# 在没有设置 set +o pipefail 的情况下,限制下载大小:
+# retry 5 command wget | head -c 1048576 会触发 retry,下载 5 次
+# command wget "$@" --tries=5 | head -c 1048576 不会触发 wget 自带的 retry,只下载 1 次
wget() {
echo "$@" | grep -o 'http[^ ]*' >&2
- retry 5 command wget "$@"
+ if command wget 2>&1 | grep -q BusyBox; then
+ # busybox wget 没有重试功能
+ retry 5 command wget "$@"
+ else
+ # 原版 wget 自带重试功能
+ command wget --tries=5 --progress=bar:force "$@"
+ fi
}
is_have_cmd() {
@@ -396,6 +404,9 @@ is_dmi_contains() {
cache_dmi_and_virt
echo "$_dmi" | grep -Eiwq "$1"
}
+
+show_netconf() {
+ grep -r . /dev/netconf/
}
get_ra_to() {
@@ -413,6 +424,8 @@ get_ra_to() {
echo
ip addr | cat -n
echo
+ show_netconf | cat -n
+ echo
fi
eval "$1='$_ra'"
}
@@ -1189,6 +1202,7 @@ install_nixos() {
# 2. 用 nix 安装 nixos-install-tools (nixos-xxx)
# 3. 运行 nixos-generate-config 生成配置 + 编辑
# 4. 运行 nixos-install
+ # https://nixos.org/manual/nixos/stable/index.html#sec-installing-from-other-distro
# nix 安装方式 分支 版本
# apk add nix 3.20 2.22.0 # nix 本体跟 alpine 正常的软件一样,不在 /nix/store 里面
@@ -2296,8 +2310,8 @@ EOF
! sh /can_use_cloud_kernel.sh "$xda" $eths; then
cp_resolv_conf $os_dir
- chroot $os_dir apt update
- DEBIAN_FRONTEND=noninteractive chroot $os_dir apt install -y linux-image-$axx64
+ chroot $os_dir apt-get update
+ DEBIAN_FRONTEND=noninteractive chroot $os_dir apt-get install -y linux-image-$axx64
# 标记云内核包
# apt-mark showmanual 结果为空,返回值也是 0
@@ -2312,12 +2326,12 @@ EOF
if [ "$releasever" -le 11 ]; then
cp_resolv_conf $os_dir
- chroot $os_dir apt update
+ chroot $os_dir apt-get update
if true; then
# 将 debian 11 设置为 12 一样的网络管理器
# 可解决 ifupdown dhcp 不支持 24位掩码+不规则网关的问题
- DEBIAN_FRONTEND=noninteractive chroot $os_dir apt install -y netplan.io
+ DEBIAN_FRONTEND=noninteractive chroot $os_dir apt-get install -y netplan.io
chroot $os_dir systemctl disable networking resolvconf
chroot $os_dir systemctl enable systemd-networkd systemd-resolved
rm_resolv_conf $os_dir
@@ -2331,7 +2345,7 @@ EOF
else
# debian 11 默认不支持 rdnss,要安装 rdnssd 或者 nm
- DEBIAN_FRONTEND=noninteractive chroot $os_dir apt install -y rdnssd
+ DEBIAN_FRONTEND=noninteractive chroot $os_dir apt-get install -y rdnssd
# 不会自动建立链接,因此不能删除
restore_resolv_conf $os_dir
fi
@@ -2666,7 +2680,7 @@ chroot_apt_autoremove() {
}
change_confs change
- DEBIAN_FRONTEND=noninteractive chroot $os_dir apt autoremove --purge -y
+ DEBIAN_FRONTEND=noninteractive chroot $os_dir apt-get autoremove --purge -y
change_confs restore
}
@@ -3010,8 +3024,8 @@ EOF
# 安装最佳内核
flavor=$(get_ubuntu_kernel_flavor)
echo "Use kernel flavor: $flavor"
- chroot $os_dir apt update
- DEBIAN_FRONTEND=noninteractive chroot $os_dir apt install -y "linux-image-$flavor"
+ chroot $os_dir apt-get update
+ DEBIAN_FRONTEND=noninteractive chroot $os_dir apt-get install -y "linux-image-$flavor"
# 自带内核:
# 常规版本 generic
@@ -3032,7 +3046,7 @@ EOF
# 16.04 镜像用 ifupdown/networking 管理网络
# 要安装 resolveconf,不然 /etc/resolv.conf 为空
if [ "$releasever" = 16.04 ]; then
- chroot $os_dir apt install -y resolvconf
+ chroot $os_dir apt-get install -y resolvconf
ln -sf /run/resolvconf/resolv.conf $os_dir/etc/resolv.conf.orig
fi