diff --git a/build/functions/common.sh b/build/functions/common.sh index 321570f7..3d696cab 100755 --- a/build/functions/common.sh +++ b/build/functions/common.sh @@ -244,6 +244,37 @@ download_file_if_missing() { return 1 } +# 下载 rc.local 文件 +download_rc_local() { + local platform_id="$1" + local rc_local_path="$SRCPATH/image/$platform_id/rc.local" + local relative_path="image/$platform_id/rc.local" + local remote_url="$REMOTE_PREFIX/$relative_path" + + echo "信息:检查是否需要下载 rc.local 文件 ($platform_id)..." + + # 如果本地文件不存在,尝试下载 + if [ ! -f "$rc_local_path" ]; then + echo "信息:本地 rc.local 文件不存在,尝试从远程下载..." + ensure_dir "$(dirname "$rc_local_path")" + + if curl -sSL --fail "$remote_url" -o "$rc_local_path"; then + echo "信息:成功下载 rc.local 文件:$remote_url" + # 在 GitHub Actions 环境中记录下载的文件 + if is_github_actions; then + echo "$rc_local_path" >> "$DOWNLOADED_FILES_LIST" + fi + return 0 + else + echo "信息:远程 rc.local 文件不存在或下载失败:$remote_url" + return 1 + fi + else + echo "信息:使用本地 rc.local 文件:$rc_local_path" + return 0 + fi +} + # 清理下载的文件(仅在 GitHub Actions 环境中) cleanup_downloaded_files() { if is_github_actions && [[ -f "$DOWNLOADED_FILES_LIST" ]]; then diff --git a/build/functions/devices.sh b/build/functions/devices.sh index 041d1833..b40ca697 100755 --- a/build/functions/devices.sh +++ b/build/functions/devices.sh @@ -66,9 +66,10 @@ onecloud_rootfs() { } cumebox2_rootfs() { - local source_image="$SRCPATH/image/cumebox2/Armbian_25.2.2_Khadas-vim1_bookworm_current_6.12.17_minimal.img" + local source_image="$SRCPATH/image/cumebox2/Armbian_24.8.1_Khadas-vim1_bookworm_current_6.6.47_minimal.img" local target_image="$TMPDIR/rootfs.img" local offset=$((8192 * 512)) + local add_size_mb=900 echo "信息:准备 Cumebox2 Rootfs..." ensure_dir "$TMPDIR" @@ -77,7 +78,10 @@ cumebox2_rootfs() { download_file_if_missing "$source_image" || { echo "错误:下载 Cumebox2 原始镜像失败" >&2; exit 1; } cp "$source_image" "$target_image" || { echo "错误:复制 Cumebox2 原始镜像失败" >&2; exit 1; } - + + echo "信息:扩展镜像文件 (${add_size_mb}MB)..." + sudo dd if=/dev/zero bs=1M count="$add_size_mb" >> "$target_image" || { echo "错误:扩展镜像文件失败" >&2; exit 1; } + echo "信息:调整镜像分区大小..." sudo parted -s "$target_image" resizepart 1 100% || { echo "错误:使用 parted 调整分区大小失败" >&2; exit 1; } @@ -188,7 +192,7 @@ e900v22c_rootfs() { } octopus_flanet_rootfs() { - local source_image="$SRCPATH/image/octopus-flanet/Armbian_24.11.0_amlogic_s912_bookworm_6.1.114_server_2024.11.01.img" + local source_image="$SRCPATH/image/octopus-flanet/Armbian_25.05.0_amlogic_s912_bookworm_6.1.129_server_2025.03.02.img" local target_image="$TMPDIR/rootfs.img" local boot_offset=$((8192 * 512)) local rootfs_offset=$((1056768 * 512)) @@ -293,4 +297,4 @@ config_octopus_flanet_files() { download_file_if_missing "$config_file" || echo "警告:下载 Octopus-Planet 配置文件失败" sudo cp "$config_file" "$ROOTFS/etc/model_database.conf" || echo "警告:复制 model_database.conf 失败" -} \ No newline at end of file +} diff --git a/build/functions/install.sh b/build/functions/install.sh index f52329cc..bc6e6ebf 100755 --- a/build/functions/install.sh +++ b/build/functions/install.sh @@ -77,6 +77,8 @@ config_base_files() { sudo cp scripts/kvmd-gencert scripts/kvmd-bootconfig scripts/kvmd-certbot scripts/kvmd-udev-hdmiusb-check scripts/kvmd-udev-restart-pass build/scripts/kvmd-firstrun.sh "$ROOTFS/usr/bin/" sudo chmod +x "$ROOTFS/usr/bin/kvmd-gencert" "$ROOTFS/usr/bin/kvmd-bootconfig" "$ROOTFS/usr/bin/kvmd-certbot" "$ROOTFS/usr/bin/kvmd-udev-hdmiusb-check" "$ROOTFS/usr/bin/kvmd-udev-restart-pass" "$ROOTFS/usr/bin/kvmd-firstrun.sh" + # 尝试下载或使用本地 rc.local 文件 + download_rc_local "$platform_id" if [ -f "$SRCPATH/image/$platform_id/rc.local" ]; then echo "信息:复制设备特定的 rc.local 文件..." sudo cp "$SRCPATH/image/$platform_id/rc.local" "$ROOTFS/etc/" diff --git a/configs/os/udev/v2-hdmiusb-rpi4.rules b/configs/os/udev/v2-hdmiusb-rpi4.rules index 2bab50be..1aaaa4b5 100644 --- a/configs/os/udev/v2-hdmiusb-rpi4.rules +++ b/configs/os/udev/v2-hdmiusb-rpi4.rules @@ -4,3 +4,4 @@ KERNEL=="video[0-9]*", SUBSYSTEM=="video4linux", PROGRAM="/usr/bin/kvmd-udev-hdm KERNEL=="hidg0", GROUP="kvmd", SYMLINK+="kvmd-hid-keyboard" KERNEL=="hidg1", GROUP="kvmd", SYMLINK+="kvmd-hid-mouse" KERNEL=="hidg2", GROUP="kvmd", SYMLINK+="kvmd-hid-mouse-alt" +KERNEL=="ttyUSB0", GROUP="kvmd", SYMLINK+="kvmd-hid"