From e1f8c285a7d254cb164251da224d2011a8b2bad6 Mon Sep 17 00:00:00 2001 From: AuxXxilium Date: Thu, 27 Jun 2024 18:46:03 +0200 Subject: [PATCH] tree: rewrite mac Signed-off-by: AuxXxilium --- files/initrd/opt/arc/boot.sh | 2 +- files/initrd/opt/arc/include/network.sh | 6 +++--- files/initrd/opt/arc/init.sh | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/files/initrd/opt/arc/boot.sh b/files/initrd/opt/arc/boot.sh index 4810f549..bd5a320c 100755 --- a/files/initrd/opt/arc/boot.sh +++ b/files/initrd/opt/arc/boot.sh @@ -163,7 +163,7 @@ else fi for ETH in ${ETHX}; do MAC="$(readConfigKey "arc.${ETH}" "${USER_CONFIG_FILE}")" - [ -z "${MAC}" ] && MAC="$(cat /sys/class/net/${ETH}/address 2>/dev/null | sed 's/://g')" + [ -z "${MAC}" ] && MAC="$(cat /sys/class/net/${ETH}/address 2>/dev/null | sed 's/://g' | tr '[:upper:]' '[:lower:]')" ETHN=$((${ETHN} + 1)) if [ ${ETHN} -le ${NICPORTS} ]; then CMDLINE['mac${ETHN}']="${MAC}" diff --git a/files/initrd/opt/arc/include/network.sh b/files/initrd/opt/arc/include/network.sh index ec27e99e..3a08aa5c 100755 --- a/files/initrd/opt/arc/include/network.sh +++ b/files/initrd/opt/arc/include/network.sh @@ -22,13 +22,13 @@ function getnet() { while true; do MAC="$(cat /sys/class/net/${ETH}/address | sed 's/://g')" dialog --backtitle "$(backtitle)" --title "Mac Setting" \ - --inputbox "Type a custom MAC for ${ETH} (Eq. 001132123456)." 7 50 "${MAC}"\ + --inputbox "Type a custom MAC for ${ETH} (Eq. 001132abc123)." 7 50 "${MAC}"\ 2>"${TMP_PATH}/resp" [ $? -ne 0 ] && break MAC=$(cat "${TMP_PATH}/resp") [ -z "${MAC}" ] && MAC="$(readConfigKey "arc.${ETH}" "${USER_CONFIG_FILE}")" - [ -z "${MAC}" ] && MAC="$(cat /sys/class/net/${ETH}/address | sed 's/://g')" - MAC="$(echo "${MAC}" | sed "s/:\|-\| //g")" + [ -z "${MAC}" ] && MAC="$(cat /sys/class/net/${ETH}/address 2>/dev/null | sed 's/://g' | tr '[:upper:]' '[:lower:]')" + MAC="$(echo "${MAC}" | sed "s/:\|-\| //g" | tr '[:upper:]' '[:lower:]')" if [ ${#MAC} -eq 12 ]; then writeConfigKey "arc.${ETH}" "${MAC}" "${USER_CONFIG_FILE}" break diff --git a/files/initrd/opt/arc/init.sh b/files/initrd/opt/arc/init.sh index 88751629..e36ff92b 100755 --- a/files/initrd/opt/arc/init.sh +++ b/files/initrd/opt/arc/init.sh @@ -84,7 +84,7 @@ if arrayExistItem "sortnetif:" $(readConfigMap "addons" "${USER_CONFIG_FILE}"); fi # Read/Write IP/Mac config for ETH in ${ETHX}; do - MACR="$(cat /sys/class/net/${ETH}/address 2>/dev/null | sed 's/://g')" + MACR="$(cat /sys/class/net/${ETH}/address 2>/dev/null | sed 's/://g' | tr '[:upper:]' '[:lower:]')" IPR="$(readConfigKey "network.${MACR}" "${USER_CONFIG_FILE}")" if [ -n "${IPR}" ]; then IFS='/' read -r -a IPRA <<<"$IPR"