From b534b0d47124ea2f7f50509ad617a4d1bbeacb4a Mon Sep 17 00:00:00 2001 From: AuxXxilium Date: Tue, 26 Mar 2024 19:47:22 +0100 Subject: [PATCH] tree: rewrite more Signed-off-by: AuxXxilium --- files/initrd/opt/arc/arc-functions.sh | 20 +++++++++++--------- files/initrd/opt/arc/boot.sh | 21 ++++++++------------- files/initrd/opt/arc/include/network.sh | 2 +- files/initrd/opt/arc/init.sh | 9 +++++---- 4 files changed, 25 insertions(+), 27 deletions(-) diff --git a/files/initrd/opt/arc/arc-functions.sh b/files/initrd/opt/arc/arc-functions.sh index dbf1499f..3499be00 100755 --- a/files/initrd/opt/arc/arc-functions.sh +++ b/files/initrd/opt/arc/arc-functions.sh @@ -1211,7 +1211,7 @@ function sysinfo() { [ -d /sys/firmware/efi ] && BOOTSYS="UEFI" || BOOTSYS="Legacy" VENDOR="$(dmidecode -s system-product-name)" BOARD="$(dmidecode -s baseboard-product-name)" - ETHX=$(ls /sys/class/net/ | grep -v lo) || true + ETHX=$(ls /sys/class/net/ | grep eth) || true NIC="$(readConfigKey "device.nic" "${USER_CONFIG_FILE}")" CONFDONE="$(readConfigKey "arc.confdone" "${USER_CONFIG_FILE}")" BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" @@ -1263,6 +1263,7 @@ function sysinfo() { STATICIP="$(readConfigKey "static.${ETH}" "${USER_CONFIG_FILE}")" DRIVER=$(ls -ld /sys/class/net/${ETH}/device/driver 2>/dev/null | awk -F '/' '{print $NF}') MAC="$(readConfigKey "mac.${ETH}" "${USER_CONFIG_FILE}")" + MACR="$(cat /sys/class/net/${ETH}/address | sed 's/://g')" COUNT=0 while true; do if [ "${STATICIP}" = "true" ]; then @@ -1274,16 +1275,16 @@ function sysinfo() { fi if [ -n "${IP}" ]; then SPEED=$(ethtool ${ETH} | grep "Speed:" | awk '{print $2}') - TEXT+="\n ${DRIVER} (${SPEED} | ${MSG}) \ZbIP: ${IP} | Mac: ${MAC}\Zn" + TEXT+="\n ${DRIVER} (${SPEED} | ${MSG}) \ZbIP: ${IP} | Mac: ${MACR} (${MAC})\Zn" break fi if [ ${COUNT} -gt 3 ]; then - TEXT+="\n ${DRIVER} \ZbIP: TIMEOUT | MAC: ${MAC}\Zn" + TEXT+="\n ${DRIVER} \ZbIP: TIMEOUT | MAC: ${MACR} (${MAC})\Zn" break fi sleep 3 if ethtool ${ETH} | grep 'Link detected' | grep -q 'no'; then - TEXT+="\n ${DRIVER} \ZbIP: NOT CONNECTED | MAC: ${MAC}\Zn" + TEXT+="\n ${DRIVER} \ZbIP: NOT CONNECTED | MAC: ${MACR} (${MAC})\Zn" break fi COUNT=$((${COUNT} + 3)) @@ -1492,6 +1493,7 @@ function fullsysinfo() { STATICIP="$(readConfigKey "static.${ETH}" "${USER_CONFIG_FILE}")" DRIVER=$(ls -ld /sys/class/net/${ETH}/device/driver 2>/dev/null | awk -F '/' '{print $NF}') MAC="$(cat /sys/class/net/${ETH}/address | sed 's/://g')" + MACR="$(cat /sys/class/net/${ETH}/address | sed 's/://g')" COUNT=0 while true; do if [ "${STATICIP}" = "true" ]; then @@ -1503,16 +1505,16 @@ function fullsysinfo() { fi if [ -n "${IP}" ]; then SPEED=$(ethtool ${ETH} | grep "Speed:" | awk '{print $2}') - TEXT+="\n${DRIVER} (${SPEED} | ${MSG}) IP: ${IP} | Mac: ${MAC}" + TEXT+="\n${DRIVER} (${SPEED} | ${MSG}) IP: ${IP} | Mac: ${MACR} (${MAC})" break fi if [ ${COUNT} -gt 3 ]; then - TEXT+="\n${DRIVER} IP: TIMEOUT | MAC: ${MAC}" + TEXT+="\n${DRIVER} IP: TIMEOUT | MAC: ${MACR} (${MAC})" break fi sleep 3 if ethtool ${ETH} | grep 'Link detected' | grep -q 'no'; then - TEXT+="\n${DRIVER} IP: NOT CONNECTED | MAC: ${MAC}" + TEXT+="\n${DRIVER} IP: NOT CONNECTED | MAC: ${MACR} (${MAC})" break fi COUNT=$((${COUNT} + 3)) @@ -1676,7 +1678,7 @@ function fullsysinfo() { # Shows Networkdiag to user function networkdiag() { MSG="" - ETHX=$(ls /sys/class/net/ | grep -v lo) || true + ETHX=$(ls /sys/class/net/ | grep eth) || true for ETH in ${ETHX}; do MSG+="Interface: ${ETH}\n" addr=$(getIP ${ETH}) @@ -1751,7 +1753,7 @@ function credits() { # allow setting Static IP for Loader function staticIPMenu() { # Get Amount of NIC - ETHX=$(ls /sys/class/net/ | grep -v lo) || true + ETHX=$(ls /sys/class/net/ | grep eth) || true for ETH in ${ETHX}; do STATIC="$(readConfigKey "static.${ETH}" "${USER_CONFIG_FILE}")" DRIVER=$(ls -ld /sys/class/net/${ETH}/device/driver 2>/dev/null | awk -F '/' '{print $NF}') diff --git a/files/initrd/opt/arc/boot.sh b/files/initrd/opt/arc/boot.sh index 2066c5dc..67731886 100755 --- a/files/initrd/opt/arc/boot.sh +++ b/files/initrd/opt/arc/boot.sh @@ -88,7 +88,7 @@ KERNELLOAD="$(readConfigKey "arc.kernelload" "${USER_CONFIG_FILE}")" KERNELPANIC="$(readConfigKey "arc.kernelpanic" "${USER_CONFIG_FILE}")" DIRECTBOOT="$(readConfigKey "arc.directboot" "${USER_CONFIG_FILE}")" EMMCBOOT="$(readConfigKey "arc.emmcboot" "${USER_CONFIG_FILE}")" -ETHX=$(ls /sys/class/net/ | grep -v lo) || true +ETHX=$(ls /sys/class/net/ | grep eth) || true declare -A CMDLINE @@ -101,21 +101,16 @@ CMDLINE['vid']="${VID}" CMDLINE['pid']="${PID}" CMDLINE['sn']="${SN}" +NIC=0 +for ETH in ${ETHX}; do + MAC="$(readConfigKey "mac.${ETH}" "${USER_CONFIG_FILE}")" + [ -n "${MAC}" ] && NIC=$((${NIC} + 1)) && CMDLINE["mac${NIC}"]="${MAC}" +done +CMDLINE['netif_num']="${NIC}" + if [ "${MACSYS}" = "hardware" ]; then - NIC=0 - for ETH in ${ETHX}; do - MAC="$(readConfigKey "mac.${ETH}" "${USER_CONFIG_FILE}")" - [ -n "${MAC}" ] && NIC=$((${NIC} + 1)) && CMDLINE["mac${NIC}"]="${MAC}" - done - CMDLINE['netif_num']="${NIC}" CMDLINE['skip_vender_mac_interfaces']="0,1,2,3,4,5,6,7" elif [ "${MACSYS}" = "custom" ]; then - NIC=0 - for ETH in ${ETHX}; do - MAC="$(readConfigKey "mac.${ETH}" "${USER_CONFIG_FILE}")" - [ -n "${MAC}" ] && NIC=$((${NIC} + 1)) && CMDLINE["mac${NIC}"]="${MAC}" - done - CMDLINE['netif_num']="${NIC}" CMDLINE['skip_vender_mac_interfaces']="$(seq -s, ${NIC} 7)" fi diff --git a/files/initrd/opt/arc/include/network.sh b/files/initrd/opt/arc/include/network.sh index 4c8bcfb6..7bbfe4b4 100755 --- a/files/initrd/opt/arc/include/network.sh +++ b/files/initrd/opt/arc/include/network.sh @@ -68,7 +68,7 @@ function getnet() { } # Get Amount of NIC -ETHX=$(ls /sys/class/net/ | grep -v lo) || true +ETHX=$(ls /sys/class/net/ | grep eth) || true # Get actual IP for ETH in ${ETHX}; do IPCON="$(readConfigKey "ip.${ETH}" "${USER_CONFIG_FILE}")" diff --git a/files/initrd/opt/arc/init.sh b/files/initrd/opt/arc/init.sh index 04ece4ce..0a4dbb9a 100755 --- a/files/initrd/opt/arc/init.sh +++ b/files/initrd/opt/arc/init.sh @@ -8,6 +8,9 @@ set -e [ -z "${LOADER_DISK}" ] && die "Loader Disk not found!" +# Get Loader Disk Bus +BUS=$(getBus "${LOADER_DISK}") + # Shows title clear [ -z "${COLUMNS}" ] && COLUMNS=50 @@ -71,7 +74,7 @@ else fi # Init Network -ETHX=$(ls /sys/class/net/ | grep -v lo) || true +ETHX=$(ls /sys/class/net/ | grep eth) || true MACSYS="$(readConfigKey "arc.macsys" "${USER_CONFIG_FILE}")" # Write Mac to config NIC=0 @@ -102,7 +105,6 @@ writeConfigKey "device.nic" "${NIC}" "${USER_CONFIG_FILE}" # Get the VID/PID if we are in USB VID="0x46f4" PID="0x0001" -BUS=$(getBus "${LOADER_DISK}") if [ "${BUS}" = "usb" ]; then VID="0x$(udevadm info --query property --name "${LOADER_DISK}" | grep ID_VENDOR_ID | cut -d= -f2)" @@ -203,8 +205,7 @@ mkdir -p "${MODEL_CONFIG_PATH}" mkdir -p "${PATCH_PATH}" mkdir -p "${BACKUPDIR}" -# Load Arc -updateAddons +# Load Arc Overlay echo -e "\033[1;34mLoading Arc Overlay...\033[0m" sleep 2