From 2f02843dffe61161baafafd9863244213baa055a Mon Sep 17 00:00:00 2001 From: Ing Date: Wed, 17 Sep 2025 12:59:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20boot.sh=20=E5=92=8C=20func?= =?UTF-8?q?tions.sh=EF=BC=8C=E4=BF=AE=E5=A4=8D=E8=AE=BE=E5=A4=87=E6=A3=80?= =?UTF-8?q?=E6=B5=8B=E9=80=BB=E8=BE=91=EF=BC=8C=E6=94=AF=E6=8C=81=20Docker?= =?UTF-8?q?=20=E7=8E=AF=E5=A2=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- files/initrd/opt/rr/boot.sh | 2 +- files/initrd/opt/rr/include/functions.sh | 4 +++- files/initrd/opt/rr/init.sh | 6 ++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/files/initrd/opt/rr/boot.sh b/files/initrd/opt/rr/boot.sh index ef36d9b6..2c26282a 100755 --- a/files/initrd/opt/rr/boot.sh +++ b/files/initrd/opt/rr/boot.sh @@ -112,7 +112,7 @@ printf "%s \033[1;36m%s\033[0m\n" "$(TEXT "MEM: ")" "${MEM}" if ! readConfigMap "addons" "${USER_CONFIG_FILE}" | grep -q nvmesystem; then HASATA=0 - for D in $(lsblk -dpno NAME); do + for D in $(lsblk -dpno KNAME); do [ "${D}" = "${LOADER_DISK}" ] && continue if echo "sata sas scsi" | grep -wq "$(getBus "${D}")"; then HASATA=1 diff --git a/files/initrd/opt/rr/include/functions.sh b/files/initrd/opt/rr/include/functions.sh index 03ff0061..ea8bc1ce 100755 --- a/files/initrd/opt/rr/include/functions.sh +++ b/files/initrd/opt/rr/include/functions.sh @@ -246,6 +246,7 @@ function _sort_netif() { ETHLIST="" for F in /sys/class/net/eth*; do [ ! -e "${F}" ] && continue + local ETH MAC BUS ETH="$(basename "${F}")" MAC="$(cat "/sys/class/net/${ETH}/address" 2>/dev/null | sed 's/://g; s/.*/\L&/')" BUS="$(ethtool -i "${ETH}" 2>/dev/null | grep bus-info | cut -d' ' -f2)" @@ -288,10 +289,11 @@ function _sort_netif() { # 1 - device path function getBus() { local BUS="" + [ -f "/.dockerenv" ] && BUS="docker" # usb/ata(ide)/sata/sas/spi(scsi)/virtio/mmc/nvme [ -z "${BUS}" ] && BUS=$(lsblk -dpno KNAME,TRAN 2>/dev/null | grep "${1} " | awk '{print $2}' | sed 's/^ata$/ide/' | sed 's/^spi$/scsi/') #Spaces are intentional # usb/scsi(ide/sata/sas)/virtio/mmc/nvme/vmbus/xen(xvd) - [ -z "${BUS}" ] && BUS=$(lsblk -dpno KNAME,SUBSYSTEMS 2>/dev/null | grep "${1} " | awk '{print $2}' | awk -F':' '{print $(NF-1)}' | sed 's/_host//' | sed 's/^.*xen.*$/xen/') # Spaces are intentional + [ -z "${BUS}" ] && BUS=$(lsblk -dpno KNAME,SUBSYSTEMS 2>/dev/null | grep "${1} " | awk '{split($2,a,":"); if(length(a)>1) print a[length(a)-1]}' | sed 's/_host//' | sed 's/^.*xen.*$/xen/') # Spaces are intentional [ -z "${BUS}" ] && BUS="unknown" echo "${BUS}" return 0 diff --git a/files/initrd/opt/rr/init.sh b/files/initrd/opt/rr/init.sh index 241f5d5d..25f6df20 100755 --- a/files/initrd/opt/rr/init.sh +++ b/files/initrd/opt/rr/init.sh @@ -94,7 +94,7 @@ fi initConfigKey "modules" "{}" "${USER_CONFIG_FILE}" initConfigKey "modblacklist" "evbug,cdc_ether" "${USER_CONFIG_FILE}" -if [ ! "LOCALBUILD" = "${LOADER_DISK}" ]; then +if [ ! -f "/.dockerenv" ] && [ ! "LOCALBUILD" = "${LOADER_DISK}" ]; then if arrayExistItem "sortnetif:" "$(readConfigMap "addons" "${USER_CONFIG_FILE}")"; then _sort_netif "$(readConfigKey "addons.sortnetif" "${USER_CONFIG_FILE}")" fi @@ -129,12 +129,14 @@ PID="0x0001" TYPE="DoM" BUS=$(getBus "${LOADER_DISK}") -BUSLIST="usb sata sas scsi nvme mmc ide virtio vmbus xen" +BUSLIST="usb sata sas scsi nvme mmc ide virtio vmbus xen docker" if [ "${BUS}" = "usb" ]; then VID="0x$(udevadm info --query property --name "${LOADER_DISK}" 2>/dev/null | grep "ID_VENDOR_ID" | cut -d= -f2)" PID="0x$(udevadm info --query property --name "${LOADER_DISK}" 2>/dev/null | grep "ID_MODEL_ID" | cut -d= -f2)" [ "${VID}" = "0x" ] || [ "${PID}" = "0x" ] && die "$(TEXT "The loader disk does not support the current USB Portable Hard Disk.")" TYPE="flashdisk" +elif [ "${BUS}" = "docker" ]; then + TYPE="PC" elif ! echo "${BUSLIST}" | grep -wq "${BUS}"; then if [ "LOCALBUILD" = "${LOADER_DISK}" ]; then echo "LOCALBUILD MODE"