network: add sanity check

Signed-off-by: AuxXxilium <info@auxxxilium.tech>
This commit is contained in:
AuxXxilium
2024-05-18 16:30:16 +02:00
parent cdefd4a21f
commit 948531e59c
3 changed files with 7 additions and 6 deletions

View File

@@ -157,6 +157,8 @@ for ETH in ${ETHX}; do
MAC="$(readConfigKey "mac.${ETH}" "${USER_CONFIG_FILE}")"
[ -n "${MAC}" ] && NIC=$((${NIC} + 1)) && CMDLINE["mac${NIC}"]="${MAC}"
done
ETHN=$(ls /sys/class/net/ 2>/dev/null | grep eth | wc -l)
[ ${NIC} -ne ${ETHN} ] && echo -e "\033[1;31mWarning: NIC mismatch (NICs: ${NIC} | Real: ${ETHN})\033[0m"
CMDLINE['netif_num']="${NIC}"
if [ "${MACSYS}" = "hardware" ]; then
CMDLINE['skip_vender_mac_interfaces']="0,1,2,3,4,5,6,7"

View File

@@ -16,11 +16,8 @@ function getnet() {
elif [ "${ARCPATCH}" = "false" ]; then
ETHN=$(ls /sys/class/net/ 2>/dev/null | grep eth | wc -l)
MACS=($(generateMacAddress "${MODEL}" ${ETHN}))
N=1
for ETH in ${ETHX}; do
MAC=$(echo "${MACS}" | cut -d ' ' -f ${N})
writeConfigKey "mac.${ETH}" "${MAC}" "${USER_CONFIG_FILE}"
N=$((${N} + 1))
for I in $(seq 1 ${ETHN}); do
writeConfigKey "mac.eth$((${I} - 1))" "${MACS[$((${I} - 1))]}" "${USER_CONFIG_FILE}"
done
elif [ "${ARCPATCH}" = "user" ]; then
# User Mac

View File

@@ -100,10 +100,12 @@ for ETH in ${ETHX}; do
fi
NIC=$((${NIC} + 1))
done
echo
ETHN=$(ls /sys/class/net/ 2>/dev/null | grep eth | wc -l)
[ ${NIC} -ne ${ETHN} ] && echo "Warning: NIC mismatch (NICs: ${NIC} | Real: ${ETHN})"
# Write NIC Amount to config
writeConfigKey "device.nic" "${NIC}" "${USER_CONFIG_FILE}"
# No network devices
echo
[ ${NIC} -le 0 ] && die "No NIC found! - Loader does not work without Network connection."
# Get the VID/PID if we are in USB