mirror of
https://github.com/bin456789/reinstall.git
synced 2025-07-10 21:29:56 +00:00
Compare commits
5 Commits
2e1702e5e0
...
48b4dd5a0b
Author | SHA1 | Date | |
---|---|---|---|
![]() |
48b4dd5a0b | ||
![]() |
7b777df830 | ||
![]() |
24b6e7f922 | ||
![]() |
ad89a69f6a | ||
![]() |
4afbd5a2fe |
@ -164,8 +164,9 @@ d-i partman/early_command string true; \
|
|||||||
# 另一种方法处理 cloudcone
|
# 另一种方法处理 cloudcone
|
||||||
# if [ "$link_grub_dir" = 1 ]; then mkdir /target/boot/grub2; echo 'chainloader (hd0)+1' >/target/boot/grub2/grub.cfg; fi; \
|
# if [ "$link_grub_dir" = 1 ]; then mkdir /target/boot/grub2; echo 'chainloader (hd0)+1' >/target/boot/grub2/grub.cfg; fi; \
|
||||||
d-i preseed/late_command string true; \
|
d-i preseed/late_command string true; \
|
||||||
eval "$(grep -o 'extra_link_grub_dir=[^ ]*' /proc/cmdline | sed 's/^extra_//')"; \
|
for str in $(grep -wo "extra_[^ ]*" /proc/cmdline | sed 's/^extra_//'); do eval "$str"; done; \
|
||||||
eval "$(grep -o 'extra_ssh_port=[^ ]*' /proc/cmdline | sed 's/^extra_//')"; \
|
|
||||||
|
if [ "$elts" = 1 ]; then sed -i "s|deb\.freexian\.com/extended-lts|$deb_mirror|" /target/etc/apt/sources.list; fi; \
|
||||||
|
|
||||||
if [ "$link_grub_dir" = 1 ]; then ln -s grub /target/boot/grub2; fi; \
|
if [ "$link_grub_dir" = 1 ]; then ln -s grub /target/boot/grub2; fi; \
|
||||||
|
|
||||||
|
@ -134,6 +134,8 @@ fix_network_manager() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# debian 9 IPV6 onlink 路由需要 post-up
|
||||||
|
|
||||||
# auto lo
|
# auto lo
|
||||||
# iface lo inet loopback
|
# iface lo inet loopback
|
||||||
|
|
||||||
@ -147,6 +149,8 @@ fix_network_manager() {
|
|||||||
# iface eth0 inet6 static
|
# iface eth0 inet6 static
|
||||||
# address 2602:1:0:80::100/64
|
# address 2602:1:0:80::100/64
|
||||||
# gateway 2602:1:0:80::1
|
# gateway 2602:1:0:80::1
|
||||||
|
# post-up ip route add 2602:1:0:80::1 dev eth0
|
||||||
|
# post-up ip route add default via 2602:1:0:80::1 dev eth0
|
||||||
# dns-nameserver 2606:4700:4700::1111
|
# dns-nameserver 2606:4700:4700::1111
|
||||||
# dns-nameserver 2001:4860:4860::8888
|
# dns-nameserver 2001:4860:4860::8888
|
||||||
|
|
||||||
@ -171,6 +175,11 @@ fix_ifupdown() {
|
|||||||
if [ -n "$ethx" ]; then
|
if [ -n "$ethx" ]; then
|
||||||
line=$(echo "$line" | awk "{\$2=\"$ethx\"; print \$0}")
|
line=$(echo "$line" | awk "{\$2=\"$ethx\"; print \$0}")
|
||||||
fi
|
fi
|
||||||
|
elif [[ "$line" = *" dev e"* ]]; then
|
||||||
|
if [ -n "$ethx" ]; then
|
||||||
|
# awk 会去除前面的空格
|
||||||
|
line=$(echo "$line" | sed -E "s/[^ ]*$/$ethx/")
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
if ! $del_this_line; then
|
if ! $del_this_line; then
|
||||||
echo "$line" >>"$tmp_file"
|
echo "$line" >>"$tmp_file"
|
||||||
|
151
reinstall.sh
151
reinstall.sh
@ -11,7 +11,7 @@ confhome_cn=https://gitlab.com/bin456789/reinstall/-/raw/main
|
|||||||
DEFAULT_PASSWORD=123@@@
|
DEFAULT_PASSWORD=123@@@
|
||||||
|
|
||||||
# 用于判断 reinstall.sh 和 trans.sh 是否兼容
|
# 用于判断 reinstall.sh 和 trans.sh 是否兼容
|
||||||
SCRIPT_VERSION=4BACD833-A585-23BA-6CBB-9AA4E08E0002
|
SCRIPT_VERSION=4BACD833-A585-23BA-6CBB-9AA4E08E0003
|
||||||
|
|
||||||
# 记录要用到的 windows 程序,运行时输出删除 \r
|
# 记录要用到的 windows 程序,运行时输出删除 \r
|
||||||
WINDOWS_EXES='cmd powershell wmic reg diskpart netsh bcdedit mountvol'
|
WINDOWS_EXES='cmd powershell wmic reg diskpart netsh bcdedit mountvol'
|
||||||
@ -124,6 +124,8 @@ curl() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
is_in_china() {
|
is_in_china() {
|
||||||
|
[ "$force_cn" = 1 ] && return 0
|
||||||
|
|
||||||
if [ -z "$_loc" ]; then
|
if [ -z "$_loc" ]; then
|
||||||
# 部分地区 www.cloudflare.com 被墙
|
# 部分地区 www.cloudflare.com 被墙
|
||||||
_loc=$(curl -L http://dash.cloudflare.com/cdn-cgi/trace | grep '^loc=' | cut -d= -f2)
|
_loc=$(curl -L http://dash.cloudflare.com/cdn-cgi/trace | grep '^loc=' | cut -d= -f2)
|
||||||
@ -1034,6 +1036,10 @@ setos() {
|
|||||||
[ "$releasever" -le 10 ]
|
[ "$releasever" -le 10 ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# 用此标记要是否 elts, 用于安装后修改 elts/etls-cn 源
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
is_debian_elts && elts=1 || elts=0
|
||||||
|
|
||||||
case "$releasever" in
|
case "$releasever" in
|
||||||
9) codename=stretch ;;
|
9) codename=stretch ;;
|
||||||
10) codename=buster ;;
|
10) codename=buster ;;
|
||||||
@ -1041,6 +1047,49 @@ setos() {
|
|||||||
12) codename=bookworm ;;
|
12) codename=bookworm ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
if ! is_use_cloud_image && is_debian_elts && 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
|
||||||
|
|
||||||
|
# udeb_mirror 安装时的源
|
||||||
|
# deb_mirror 安装后要修改成的源
|
||||||
|
if is_debian_elts; then
|
||||||
|
if is_in_china; then
|
||||||
|
# https://github.com/tuna/issues/issues/1999
|
||||||
|
# nju 也没同步
|
||||||
|
udeb_mirror=deb.freexian.com/extended-lts
|
||||||
|
deb_mirror=mirror.nju.edu.cn/debian-elts
|
||||||
|
initrd_mirror=mirror.nju.edu.cn/debian-archive/debian
|
||||||
|
else
|
||||||
|
# 按道理不应该用官方源,但找不到其他源
|
||||||
|
udeb_mirror=deb.freexian.com/extended-lts
|
||||||
|
deb_mirror=deb.freexian.com/extended-lts
|
||||||
|
initrd_mirror=archive.debian.org/debian
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if is_in_china; then
|
||||||
|
# ftp.cn.debian.org 不在国内还严重丢包
|
||||||
|
# https://www.itdog.cn/ping/ftp.cn.debian.org
|
||||||
|
mirror=mirror.nju.edu.cn/debian
|
||||||
|
else
|
||||||
|
mirror=deb.debian.org/debian # fastly
|
||||||
|
fi
|
||||||
|
udeb_mirror=$mirror
|
||||||
|
deb_mirror=$mirror
|
||||||
|
initrd_mirror=$mirror
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 云镜像和 firmware 下载源
|
||||||
if is_in_china; then
|
if is_in_china; then
|
||||||
cdimage_mirror=https://mirror.nju.edu.cn/debian-cdimage
|
cdimage_mirror=https://mirror.nju.edu.cn/debian-cdimage
|
||||||
else
|
else
|
||||||
@ -1056,10 +1105,6 @@ setos() {
|
|||||||
|
|
||||||
if is_use_cloud_image; then
|
if is_use_cloud_image; then
|
||||||
# cloud image
|
# cloud image
|
||||||
# debian --ci 用此标记要是否要换 elts 源
|
|
||||||
# shellcheck disable=SC2034
|
|
||||||
is_debian_elts && elts=1 || elts=0
|
|
||||||
|
|
||||||
# https://salsa.debian.org/cloud-team/debian-cloud-images/-/tree/master/config_space/bookworm/files/etc/default/grub.d
|
# https://salsa.debian.org/cloud-team/debian-cloud-images/-/tree/master/config_space/bookworm/files/etc/default/grub.d
|
||||||
# cloud 包括各种奇怪的优化,例如不显示 grub 菜单
|
# cloud 包括各种奇怪的优化,例如不显示 grub 菜单
|
||||||
# 因此使用 nocloud
|
# 因此使用 nocloud
|
||||||
@ -1069,59 +1114,21 @@ setos() {
|
|||||||
ci_type=nocloud
|
ci_type=nocloud
|
||||||
fi
|
fi
|
||||||
eval ${step}_img=$cdimage_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
|
||||||
eval ${step}_kernel=linux-image$flavour-$basearch_alt
|
|
||||||
else
|
else
|
||||||
# 传统安装
|
# 传统安装
|
||||||
if is_debian_elts; then
|
initrd_dir=dists/$codename/main/installer-$basearch_alt/current/images/netboot/debian-installer/$basearch_alt
|
||||||
# https://github.com/tuna/issues/issues/1999
|
|
||||||
# nju 也没同步
|
|
||||||
if false && is_in_china; then
|
|
||||||
hostname=mirrors.tuna.tsinghua.edu.cn
|
|
||||||
hostname=mirror.nju.edu.cn
|
|
||||||
directory=debian-elts
|
|
||||||
initrd_mirror=mirrors.nju.edu.cn/debian-archive
|
|
||||||
else
|
|
||||||
# 按道理不应该用官方源,但找不到其他源
|
|
||||||
hostname=deb.freexian.com
|
|
||||||
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 不在国内还严重丢包
|
|
||||||
# https://www.itdog.cn/ping/ftp.cn.debian.org
|
|
||||||
hostname=mirror.nju.edu.cn
|
|
||||||
else
|
|
||||||
hostname=deb.debian.org # fastly
|
|
||||||
fi
|
|
||||||
directory=debian
|
|
||||||
initrd_mirror=$hostname
|
|
||||||
fi
|
|
||||||
|
|
||||||
initrd_dir=debian/dists/$codename/main/installer-$basearch_alt/current/images/netboot/debian-installer/$basearch_alt
|
|
||||||
|
|
||||||
|
eval ${step}_udeb_mirror=$udeb_mirror
|
||||||
eval ${step}_vmlinuz=https://$initrd_mirror/$initrd_dir/linux
|
eval ${step}_vmlinuz=https://$initrd_mirror/$initrd_dir/linux
|
||||||
eval ${step}_initrd=https://$initrd_mirror/$initrd_dir/initrd.gz
|
eval ${step}_initrd=https://$initrd_mirror/$initrd_dir/initrd.gz
|
||||||
eval ${step}_ks=$confhome/debian.cfg
|
eval ${step}_ks=$confhome/debian.cfg
|
||||||
eval ${step}_firmware=$cdimage_mirror/unofficial/non-free/firmware/$codename/current/firmware.cpio.gz
|
eval ${step}_firmware=$cdimage_mirror/unofficial/non-free/firmware/$codename/current/firmware.cpio.gz
|
||||||
eval ${step}_hostname=$hostname
|
|
||||||
eval ${step}_directory=$directory
|
|
||||||
eval ${step}_codename=$codename
|
eval ${step}_codename=$codename
|
||||||
eval ${step}_kernel=linux-image$flavour-$basearch_alt
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# 官方安装和云镜像都会用到的
|
||||||
|
eval ${step}_deb_mirror=$deb_mirror
|
||||||
|
eval ${step}_kernel=linux-image$flavour-$basearch_alt
|
||||||
}
|
}
|
||||||
|
|
||||||
setos_kali() {
|
setos_kali() {
|
||||||
@ -1144,9 +1151,8 @@ Continue?
|
|||||||
eval ${step}_vmlinuz=$mirror/linux
|
eval ${step}_vmlinuz=$mirror/linux
|
||||||
eval ${step}_initrd=$mirror/initrd.gz
|
eval ${step}_initrd=$mirror/initrd.gz
|
||||||
eval ${step}_ks=$confhome/debian.cfg
|
eval ${step}_ks=$confhome/debian.cfg
|
||||||
eval ${step}_hostname=$hostname
|
eval ${step}_udeb_mirror=$hostname/kali
|
||||||
eval ${step}_codename=$codename
|
eval ${step}_codename=$codename
|
||||||
eval ${step}_directory=kali
|
|
||||||
eval ${step}_kernel=linux-image$flavour-$basearch_alt
|
eval ${step}_kernel=linux-image$flavour-$basearch_alt
|
||||||
# 缺少 firmware 下载
|
# 缺少 firmware 下载
|
||||||
fi
|
fi
|
||||||
@ -1287,20 +1293,21 @@ Continue?
|
|||||||
mirror=https://distfiles.gentoo.org # cdn77
|
mirror=https://distfiles.gentoo.org # cdn77
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if is_use_cloud_image; then
|
dir=releases/$basearch_alt/autobuilds
|
||||||
if [ "$basearch_alt" = arm64 ]; then
|
|
||||||
error_and_exit 'Not support arm64 for gentoo cloud image.'
|
|
||||||
fi
|
|
||||||
|
|
||||||
# openrc 镜像没有附带兼容 cloud-init 的网络管理器
|
if is_use_cloud_image; then
|
||||||
eval ${step}_img=$mirror/experimental/$basearch_alt/openstack/gentoo-openstack-$basearch_alt-systemd-latest.qcow2
|
# 使用 systemd 且没有 cloud-init
|
||||||
|
prefix=di-$basearch_alt-console
|
||||||
|
filename=$(curl -L $mirror/$dir/latest-$prefix.txt | grep '.qcow2' | awk '{print $1}' | grep .)
|
||||||
|
file=$mirror/$dir/$filename
|
||||||
|
test_url "$file" 'qemu'
|
||||||
|
eval ${step}_img=$file
|
||||||
else
|
else
|
||||||
prefix=stage3-$basearch_alt-systemd
|
prefix=stage3-$basearch_alt-systemd
|
||||||
dir=releases/$basearch_alt/autobuilds
|
filename=$(curl -L $mirror/$dir/latest-$prefix.txt | grep '.tar.xz' | awk '{print $1}' | grep .)
|
||||||
file=$(curl -L $mirror/$dir/latest-$prefix.txt | grep '.tar.xz' | awk '{print $1}')
|
file=$mirror/$dir/$filename
|
||||||
stage3=$mirror/$dir/$file
|
test_url "$file" 'tar.xz'
|
||||||
test_url $stage3 'tar.xz'
|
eval ${step}_img=$file
|
||||||
eval ${step}_img=$stage3
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2743,7 +2750,8 @@ build_extra_cmdline() {
|
|||||||
# 会将 extra.xxx=yyy 写入新系统的 /etc/modprobe.d/local.conf
|
# 会将 extra.xxx=yyy 写入新系统的 /etc/modprobe.d/local.conf
|
||||||
# https://answers.launchpad.net/ubuntu/+question/249456
|
# https://answers.launchpad.net/ubuntu/+question/249456
|
||||||
# https://salsa.debian.org/installer-team/rootskel/-/blob/master/src/lib/debian-installer-startup.d/S02module-params?ref_type=heads
|
# https://salsa.debian.org/installer-team/rootskel/-/blob/master/src/lib/debian-installer-startup.d/S02module-params?ref_type=heads
|
||||||
for key in confhome hold force force_old_windows_setup cloud_image main_disk elts \
|
for key in confhome hold force force_cn force_old_windows_setup cloud_image main_disk \
|
||||||
|
elts deb_mirror \
|
||||||
ssh_port rdp_port web_port allow_ping; do
|
ssh_port rdp_port web_port allow_ping; do
|
||||||
value=${!key}
|
value=${!key}
|
||||||
if [ -n "$value" ]; then
|
if [ -n "$value" ]; then
|
||||||
@ -2792,8 +2800,8 @@ build_nextos_cmdline() {
|
|||||||
elif is_distro_like_debian $nextos_distro; then
|
elif is_distro_like_debian $nextos_distro; then
|
||||||
nextos_cmdline="lowmem/low=1 auto=true priority=critical"
|
nextos_cmdline="lowmem/low=1 auto=true priority=critical"
|
||||||
nextos_cmdline+=" url=$nextos_ks"
|
nextos_cmdline+=" url=$nextos_ks"
|
||||||
nextos_cmdline+=" mirror/http/hostname=$nextos_hostname"
|
nextos_cmdline+=" mirror/http/hostname=${nextos_udeb_mirror%/*}"
|
||||||
nextos_cmdline+=" mirror/http/directory=/$nextos_directory"
|
nextos_cmdline+=" mirror/http/directory=/${nextos_udeb_mirror##*/}"
|
||||||
nextos_cmdline+=" base-installer/kernel/image=$nextos_kernel"
|
nextos_cmdline+=" base-installer/kernel/image=$nextos_kernel"
|
||||||
# elts 的 debian 不能用 security 源,否则安装过程会提示无法访问
|
# elts 的 debian 不能用 security 源,否则安装过程会提示无法访问
|
||||||
if [ "$nextos_distro" = debian ] && is_debian_elts; then
|
if [ "$nextos_distro" = debian ] && is_debian_elts; then
|
||||||
@ -2978,12 +2986,12 @@ EOF
|
|||||||
udeb_list=$tmp/udeb_list
|
udeb_list=$tmp/udeb_list
|
||||||
if ! [ -f $udeb_list ]; then
|
if ! [ -f $udeb_list ]; then
|
||||||
# shellcheck disable=SC2154
|
# shellcheck disable=SC2154
|
||||||
curl -L http://$nextos_hostname/$nextos_directory/dists/$nextos_codename/main/debian-installer/binary-$basearch_alt/Packages.gz |
|
curl -L http://$nextos_udeb_mirror/dists/$nextos_codename/main/debian-installer/binary-$basearch_alt/Packages.gz |
|
||||||
zcat | grep 'Filename:' | awk '{print $2}' >$udeb_list
|
zcat | grep 'Filename:' | awk '{print $2}' >$udeb_list
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 下载 udeb
|
# 下载 udeb
|
||||||
curl -Lo $tmp/tmp.udeb http://$nextos_hostname/$nextos_directory/"$(grep /$package $udeb_list)"
|
curl -Lo $tmp/tmp.udeb http://$nextos_udeb_mirror/"$(grep /$package $udeb_list)"
|
||||||
|
|
||||||
if false; then
|
if false; then
|
||||||
# 使用 dpkg
|
# 使用 dpkg
|
||||||
@ -3105,8 +3113,10 @@ EOF
|
|||||||
# hack 3
|
# hack 3
|
||||||
# 修改 trans.sh
|
# 修改 trans.sh
|
||||||
# 1. 直接调用 create_ifupdown_config
|
# 1. 直接调用 create_ifupdown_config
|
||||||
|
# shellcheck disable=SC2154
|
||||||
insert_into_file $initrd_dir/trans.sh after '^: main' <<EOF
|
insert_into_file $initrd_dir/trans.sh after '^: main' <<EOF
|
||||||
distro=$nextos_distro
|
distro=$nextos_distro
|
||||||
|
releasever=$nextos_releasever
|
||||||
create_ifupdown_config /etc/network/interfaces
|
create_ifupdown_config /etc/network/interfaces
|
||||||
exit
|
exit
|
||||||
EOF
|
EOF
|
||||||
@ -3485,7 +3495,7 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
long_opts=
|
long_opts=
|
||||||
for o in ci installer debug minimal allow-ping \
|
for o in ci installer debug minimal allow-ping force-cn \
|
||||||
hold: sleep: \
|
hold: sleep: \
|
||||||
iso: \
|
iso: \
|
||||||
image-name: \
|
image-name: \
|
||||||
@ -3539,6 +3549,11 @@ while true; do
|
|||||||
allow_ping=1
|
allow_ping=1
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
--force-cn)
|
||||||
|
# 仅为了方便测试
|
||||||
|
force_cn=1
|
||||||
|
shift
|
||||||
|
;;
|
||||||
--hold | --sleep)
|
--hold | --sleep)
|
||||||
if ! { [ "$2" = 1 ] || [ "$2" = 2 ]; }; then
|
if ! { [ "$2" = 1 ] || [ "$2" = 2 ]; }; then
|
||||||
error_and_exit "Invalid $1 value: $2"
|
error_and_exit "Invalid $1 value: $2"
|
||||||
|
58
trans.sh
58
trans.sh
@ -10,7 +10,7 @@ set -eE
|
|||||||
|
|
||||||
# 用于判断 reinstall.sh 和 trans.sh 是否兼容
|
# 用于判断 reinstall.sh 和 trans.sh 是否兼容
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
SCRIPT_VERSION=4BACD833-A585-23BA-6CBB-9AA4E08E0002
|
SCRIPT_VERSION=4BACD833-A585-23BA-6CBB-9AA4E08E0003
|
||||||
|
|
||||||
TRUE=0
|
TRUE=0
|
||||||
FALSE=1
|
FALSE=1
|
||||||
@ -892,9 +892,21 @@ EOF
|
|||||||
# ethx
|
# ethx
|
||||||
for ethx in $(get_eths); do
|
for ethx in $(get_eths); do
|
||||||
mode=auto
|
mode=auto
|
||||||
if is_distro_like_debian; then
|
# shellcheck disable=SC2154
|
||||||
if [ -f /etc/network/devhotplug ] && grep -wo "$ethx" /etc/network/devhotplug; then
|
if false; then
|
||||||
mode=allow-hotplug
|
if { [ "$distro" = debian ] && [ "$releasever" -ge 12 ]; } ||
|
||||||
|
[ "$distro" = kali ]; then
|
||||||
|
# alice + allow-hotplug 会有问题
|
||||||
|
# 问题 1 debian 9/10/11/12:
|
||||||
|
# 如果首次启动时,/etc/networking/interfaces 的 ethx 跟安装时不同
|
||||||
|
# 即使启动 networking 服务前成功执行了 fix-eth-name.sh ,网卡也不会启动
|
||||||
|
# 测试方法: 安装时手动修改 /etc/networking/interfaces enp3s0 为其他名字
|
||||||
|
# 问题 2 debian 9/10/11:
|
||||||
|
# 重启系统后会自动启动网卡,但运行 systemctl restart networking 会关闭网卡
|
||||||
|
# 可能的原因: /lib/systemd/system/networking.service 没有 hotplug 相关内容,而 debian 12+ 有
|
||||||
|
if [ -f /etc/network/devhotplug ] && grep -wo "$ethx" /etc/network/devhotplug; then
|
||||||
|
mode=allow-hotplug
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# if is_have_cmd udevadm; then
|
# if is_have_cmd udevadm; then
|
||||||
@ -955,6 +967,21 @@ iface $ethx inet6 static
|
|||||||
address $ipv6_addr
|
address $ipv6_addr
|
||||||
gateway $ipv6_gateway
|
gateway $ipv6_gateway
|
||||||
EOF
|
EOF
|
||||||
|
# debian 9
|
||||||
|
# ipv4 支持静态 onlink 网关
|
||||||
|
# ipv6 不支持静态 onlink 网关,需使用 post-up 添加,未测试动态
|
||||||
|
# ipv6 也不支持直接 ip route add default via xxx onlink
|
||||||
|
if [ "$distro" = debian ] && [ "$releasever" -le 9 ]; then
|
||||||
|
# debian 添加 gateway 失败时不会执行 post-up
|
||||||
|
# 因此 gateway post-up 只能二选一
|
||||||
|
|
||||||
|
# 注释最后一行,也就是 gateway
|
||||||
|
sed -Ei '$s/^( *)/\1# /' "$conf_file"
|
||||||
|
cat <<EOF >>$conf_file
|
||||||
|
post-up ip route add $ipv6_gateway dev $ethx
|
||||||
|
post-up ip route add default via $ipv6_gateway dev $ethx
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# dns
|
# dns
|
||||||
@ -2771,27 +2798,34 @@ EOF
|
|||||||
comps=$(grep '^deb ' $os_dir/etc/apt/sources.list | head -1 | cut -d' ' -f4-)
|
comps=$(grep '^deb ' $os_dir/etc/apt/sources.list | head -1 | cut -d' ' -f4-)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# EOL 处理
|
# ELTS/CN 源处理
|
||||||
if is_elts; then
|
if is_elts; then
|
||||||
|
# ELTS
|
||||||
wget https://deb.freexian.com/extended-lts/archive-key.gpg \
|
wget https://deb.freexian.com/extended-lts/archive-key.gpg \
|
||||||
-O $os_dir/etc/apt/trusted.gpg.d/freexian-archive-extended-lts.gpg
|
-O $os_dir/etc/apt/trusted.gpg.d/freexian-archive-extended-lts.gpg
|
||||||
|
|
||||||
is_in_china &&
|
|
||||||
mirror=http://mirror.nju.edu.cn/debian-elts ||
|
|
||||||
mirror=http://deb.freexian.com/extended-lts
|
|
||||||
|
|
||||||
codename=$(grep '^VERSION_CODENAME=' $os_dir/etc/os-release | cut -d= -f2)
|
codename=$(grep '^VERSION_CODENAME=' $os_dir/etc/os-release | cut -d= -f2)
|
||||||
|
# shellcheck disable=SC2154
|
||||||
if [ -f $os_dir/etc/apt/sources.list.d/debian.sources ]; then
|
if [ -f $os_dir/etc/apt/sources.list.d/debian.sources ]; then
|
||||||
cat <<EOF >$os_dir/etc/apt/sources.list.d/debian.sources
|
cat <<EOF >$os_dir/etc/apt/sources.list.d/debian.sources
|
||||||
Types: deb
|
Types: deb
|
||||||
URIs: $mirror
|
URIs: http://$deb_mirror
|
||||||
Suites: $codename
|
Suites: $codename
|
||||||
Components: $comps
|
Components: $comps
|
||||||
Signed-By: /etc/apt/trusted.gpg.d/freexian-archive-extended-lts.gpg
|
Signed-By: /etc/apt/trusted.gpg.d/freexian-archive-extended-lts.gpg
|
||||||
EOF
|
EOF
|
||||||
else
|
else
|
||||||
echo "deb $mirror $codename $comps" >$os_dir/etc/apt/sources.list
|
echo "deb http://$deb_mirror $codename $comps" >$os_dir/etc/apt/sources.list
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# non-ELTS
|
||||||
|
if is_in_china; then
|
||||||
|
# 不处理 security 源 security.debian.org/debian-security 和 /etc/apt/mirrors/debian-security.list
|
||||||
|
for file in $os_dir/etc/apt/mirrors/debian.list $os_dir/etc/apt/sources.list; do
|
||||||
|
if [ -f "$file" ]; then
|
||||||
|
sed -i "s|deb\.debian\.org/debian|$deb_mirror|" "$file"
|
||||||
|
fi
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user