Compare commits

...

4 Commits

Author SHA1 Message Date
f2cfe672d1 windows: 修复查找 iso 功能失效
现在 massgrave 的 iso 链接 href="" 少了双引号
2026-01-18 18:51:37 +08:00
0cc3fc77d6 core: 避免有时 modloop 下载不完整导致报错
fixes #308 #370 #376
2026-01-08 22:33:44 +08:00
6a35bf681a ubuntu: 软件包不存在时才执行 apt install ,避免浪费时间更新 2026-01-08 22:33:43 +08:00
e7f8802bdd net: 修复天翼云电脑 udhcpc 不断尝试获取动态 IP
fixes #518
2026-01-08 22:33:43 +08:00
3 changed files with 54 additions and 30 deletions

View File

@ -345,14 +345,14 @@ EOF
db_progress INFO netcfg/link_detect_progress db_progress INFO netcfg/link_detect_progress
else else
# alpine # alpine
# h3c 移动云电脑使用 udhcpc 会重复提示 sending select无法获得 ipv6 # h3c 移动云电脑使用 udhcpc 会重复提示 sending select因此添加 timeout 强制结束进程
# dhcpcd 会配置租约时间,过期会移除 IP但我们的没有在后台运行 dhcpcd ,因此用 udhcpc # dhcpcd 会配置租约时间,过期会移除 IP但我们的没有在后台运行 dhcpcd ,因此用 udhcpc
method=udhcpc method=udhcpc
case "$method" in case "$method" in
udhcpc) udhcpc)
udhcpc -i "$ethx" -f -q -n || true timeout $DHCP_TIMEOUT udhcpc -i "$ethx" -f -q -n || true
udhcpc6 -i "$ethx" -f -q -n || true timeout $DHCP_TIMEOUT udhcpc6 -i "$ethx" -f -q -n || true
sleep $DNS_FILE_TIMEOUT # 好像不用等待写入 dns但是以防万一 sleep $DNS_FILE_TIMEOUT # 好像不用等待写入 dns但是以防万一
;; ;;
dhcpcd) dhcpcd)

View File

@ -1089,7 +1089,7 @@ get_windows_iso_link() {
curl -L "$page_url" | curl -L "$page_url" |
tr -d '\n' | sed -e 's,<a ,\n<a ,g' -e 's,</a>,</a>\n,g' | # 使每个 <a></a> 占一行 tr -d '\n' | sed -e 's,<a ,\n<a ,g' -e 's,</a>,</a>\n,g' | # 使每个 <a></a> 占一行
grep -Ei '\.(iso|img)</a>$' | # 找出是 iso 或 img 的行 grep -Ei '\.(iso|img)</a>$' | # 找出是 iso 或 img 的行
sed -E 's,<a href="([^"]+)".+>(.+)</a>,\2 \1,' >$tmp/win.list # 提取文件名和链接 sed -E 's,<a href="?([^" ]+)"?.+>(.+)</a>,\2 \1,' >$tmp/win.list # 提取文件名和链接
# 如果不是 ltsc ,应该先去除 ltsc 链接,否则最终链接有 ltsc 的 # 如果不是 ltsc ,应该先去除 ltsc 链接,否则最终链接有 ltsc 的
# 例如查找 windows 10 iot enterprise会得到 # 例如查找 windows 10 iot enterprise会得到

View File

@ -414,23 +414,31 @@ extract_env_from_cmdline() {
} }
ensure_service_started() { ensure_service_started() {
service=$1 local service=$1
if ! rc-service -q $service status; then if ! rc-service -q "$service" start; then
if ! retry 5 rc-service -q $service start; then for i in $(seq 10); do
error_and_exit "Failed to start $service." if [ "$service" = modloop ]; then
# 避免有时 modloop 下载不完整导致报错
# * Failed to verify signature of !
# mount: mounting /dev/loop0 on /.modloop failed: Invalid argument
rm -f /lib/modloop-lts /lib/modloop-virt
fi fi
if rc-service -q "$service" start; then
return
fi
sleep 5
done
error_and_exit "Failed to start $service."
fi fi
} }
ensure_service_stopped() { ensure_service_stopped() {
service=$1 local service=$1
if rc-service -q $service status; then if ! retry 10 5 rc-service -q "$service" stop; then
if ! retry 5 rc-service -q $service stop; then
error_and_exit "Failed to stop $service." error_and_exit "Failed to stop $service."
fi fi
fi
} }
mod_motd() { mod_motd() {
@ -3488,10 +3496,8 @@ EOF
! sh /can_use_cloud_kernel.sh "$xda" $(get_eths); then ! sh /can_use_cloud_kernel.sh "$xda" $(get_eths); then
kernel_package=$(echo "$kernel_package" | sed 's/-cloud//') kernel_package=$(echo "$kernel_package" | sed 's/-cloud//')
fi fi
# 如果镜像自带内核跟最佳内核是同一种且有更新
# 则 apt install 只会进行更新,不会将包设置成 manual # 该方法包含了 apt-mark manual
# 需要再运行 apt install 才会将包设置成 manual
chroot_apt_install $os_dir "$kernel_package"
chroot_apt_install $os_dir "$kernel_package" chroot_apt_install $os_dir "$kernel_package"
# 使用 autoremove 删除非最佳内核 # 使用 autoremove 删除非最佳内核
@ -4192,7 +4198,7 @@ chroot_dnf() {
} }
chroot_apt_update() { chroot_apt_update() {
os_dir=$1 local os_dir=$1
current_hash=$(cat $os_dir/etc/apt/sources.list $os_dir/etc/apt/sources.list.d/*.sources 2>/dev/null | md5sum) 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 if ! [ "$saved_hash" = "$current_hash" ]; then
@ -4202,15 +4208,30 @@ chroot_apt_update() {
} }
chroot_apt_install() { chroot_apt_install() {
os_dir=$1 local os_dir=$1
shift shift
# 只安装未安装的软件包
# 避免更新浪费时间
local pkg='' pkgs=''
for pkg in "$@"; do
if chroot $os_dir dpkg -s "$pkg" >/dev/null 2>&1; then
# 如果已安装则标记为 manual防止被 autoremove 删除
chroot $os_dir apt-mark manual "$pkg"
else
pkgs="$pkgs $pkg"
fi
done
# 一次性安装,避免多次 update-initramfs
if [ -n "$pkgs" ]; then
chroot_apt_update $os_dir chroot_apt_update $os_dir
DEBIAN_FRONTEND=noninteractive chroot $os_dir apt-get install -y "$@" DEBIAN_FRONTEND=noninteractive chroot $os_dir apt-get install -y $pkgs
fi
} }
chroot_apt_remove() { chroot_apt_remove() {
os_dir=$1 local os_dir=$1
shift shift
# minimal 镜像 删除 grub-pc 时会安装 grub-efi-amd64 # minimal 镜像 删除 grub-pc 时会安装 grub-efi-amd64
@ -4233,7 +4254,7 @@ chroot_apt_remove() {
} }
chroot_apt_autoremove() { chroot_apt_autoremove() {
os_dir=$1 local os_dir=$1
change_confs() { change_confs() {
action=$1 action=$1
@ -4782,10 +4803,13 @@ EOF
# 安装最佳内核 # 安装最佳内核
flavor=$(get_ubuntu_kernel_flavor) flavor=$(get_ubuntu_kernel_flavor)
echo "Use kernel flavor: $flavor" echo "Use kernel flavor: $flavor"
# 如果镜像自带内核跟最佳内核是同一种且有更新
# 则 apt install 只会进行更新,不会将包设置成 manual # 题外话
# 需要再运行 apt install 才会将包设置成 manual # 如果某个包是 auto 状态且有更新
chroot_apt_install $os_dir "linux-image-$flavor" # 则 apt install PKG 只会进行更新,不会将包设置成 manual
# 需要再次运行 apt install PKG 才会将包设置成 manual
# 该方法包含了 apt-mark manual
chroot_apt_install $os_dir "linux-image-$flavor" chroot_apt_install $os_dir "linux-image-$flavor"
# 使用 autoremove 删除多余内核 # 使用 autoremove 删除多余内核