diff --git a/files/initrd/opt/arc/boot.sh b/files/initrd/opt/arc/boot.sh index 1f2a04020..06375fd47 100755 --- a/files/initrd/opt/arc/boot.sh +++ b/files/initrd/opt/arc/boot.sh @@ -197,11 +197,11 @@ fi ETHX=$(ip -o link show | awk -F': ' '{print $2}' | grep eth) ETHM=$(readConfigKey "${MODEL}.ports" "${S_FILE}" 2>/dev/null) ETHN=$(echo ${ETHX} | wc -w) -[ -z "${ETHM}" ] && ETHM=${ETHN} +[ -z "${ETHM}" ] && ETHM="${ETHN}" NIC=0 for N in ${ETHX}; do - MAC="$(readConfigKey "${N}" "${USER_CONFIG_FILE}")" - [ -z "${MAC}" ] && MAC="$(cat /sys/class/net/${N}/address 2>/dev/null | tr '[:lower:]' '[:upper:]')" || NIC=$((${NIC} + 1)) + MAC="$(readConfigKey "${N}" "${USER_CONFIG_FILE}" | tr '[:lower:]' '[:upper:]')" + [ -z "${MAC}" ] && MAC="$(cat /sys/class/net/${N}/address 2>/dev/null | tr '[:lower:]' '[:upper:]')" || NIC=$((NIC + 1)) [ ${NIC} -le ${ETHM} ] && CMDLINE["mac${NIC}"]="${MAC}" [ ${NIC} -ge ${ETHM} ] && break done @@ -260,8 +260,8 @@ elif [ "${DIRECTBOOT}" = "false" ]; then echo -e "\r${DRIVER}: \033[1;37mNOT CONNECTED\033[0m" break fi - COUNT=$((${COUNT} + 1)) - IP="$(getIP ${N})" + COUNT=$((COUNT + 1)) + IP="$(getIP "${N}")" if [ -n "${IP}" ]; then SPEED=$(ethtool ${N} 2>/dev/null | grep "Speed:" | awk '{print $2}') if [[ "${IP}" =~ ^169\.254\..* ]]; then diff --git a/files/initrd/opt/arc/include/functions.sh b/files/initrd/opt/arc/include/functions.sh index fb268286a..0464d54ab 100755 --- a/files/initrd/opt/arc/include/functions.sh +++ b/files/initrd/opt/arc/include/functions.sh @@ -277,7 +277,7 @@ function getBus() { # 1 - ethN function getIP() { local IP="" - MACR="$(cat /sys/class/net/${1}/address 2>/dev/null | sed 's/://g' | tr '[:lower:]' '[:upper:]')" + MACR="$(cat /sys/class/net/${1}/address 2>/dev/null | sed 's/://g')" IPR="$(readConfigKey "network.${MACR}" "${USER_CONFIG_FILE}")" if [ -n "${IPR}" ]; then IFS='/' read -r -a IPRA <<<"${IPR}" diff --git a/files/initrd/opt/arc/include/network.sh b/files/initrd/opt/arc/include/network.sh index 41c358996..ae7f38b8c 100755 --- a/files/initrd/opt/arc/include/network.sh +++ b/files/initrd/opt/arc/include/network.sh @@ -42,9 +42,9 @@ function getnet() { } # Get Amount of NIC -ETHX="$(ls /sys/class/net 2>/dev/null | grep eth)" +ETHX=$(ip -o link show | awk -F': ' '{print $2}' | grep eth) # Get actual IP -for ETH in ${ETHX}; do - IPCON=$(getIP ${ETH}) +for N in ${ETHX}; do + IPCON="$(getIP "${N}")" [ -n "${IPCON}" ] && break done \ No newline at end of file diff --git a/files/initrd/opt/arc/init.sh b/files/initrd/opt/arc/init.sh index b47d85d43..0e2374fc6 100755 --- a/files/initrd/opt/arc/init.sh +++ b/files/initrd/opt/arc/init.sh @@ -94,26 +94,26 @@ if arrayExistItem "sortnetif:" $(readConfigMap "addons" "${USER_CONFIG_FILE}"); fi # Read/Write IP/Mac to config ETHX=$(ip -o link show | awk -F': ' '{print $2}' | grep eth) -for N in ${ETHX}; do - MACR="$(cat /sys/class/net/${N}/address 2>/dev/null | sed 's/://g' | tr '[:lower:]' '[:upper:]')" - IPR="$(readConfigKey "network.${MACR}" "${USER_CONFIG_FILE}")" - if [ -n "${IPR}" ] && [ "1" = "$(cat /sys/class/net/${N}/carrier 2>/dev/null)" ]; then - IFS='/' read -r -a IPRA <<<"${IPR}" - ip addr flush dev ${N} - ip addr add ${IPRA[0]}/${IPRA[1]:-"255.255.255.0"} dev ${N} - if [ -n "${IPRA[2]}" ]; then - ip route add default via ${IPRA[2]} dev ${N} - fi - if [ -n "${IPRA[3]:-${IPRA[2]}}" ]; then - sed -i "/nameserver ${IPRA[3]:-${IPRA[2]}}/d" /etc/resolv.conf - echo "nameserver ${IPRA[3]:-${IPRA[2]}}" >>/etc/resolv.conf + for N in ${ETHX}; do + MACR="$(cat /sys/class/net/${N}/address 2>/dev/null | sed 's/://g')" + IPR="$(readConfigKey "network.${MACR}" "${USER_CONFIG_FILE}")" + if [ -n "${IPR}" ] && [ "1" = "$(cat /sys/class/net/${N}/carrier 2>/dev/null)" ]; then + IFS='/' read -r -a IPRA <<<"${IPR}" + ip addr flush dev "${N}" + ip addr add "${IPRA[0]}/${IPRA[1]:-"255.255.255.0"}" dev "${N}" + if [ -n "${IPRA[2]}" ]; then + ip route add default via "${IPRA[2]}" dev "${N}" + fi + if [ -n "${IPRA[3]:-${IPRA[2]}}" ]; then + sed -i "/nameserver ${IPRA[3]:-${IPRA[2]}}/d" /etc/resolv.conf + echo "nameserver ${IPRA[3]:-${IPRA[2]}}" >>/etc/resolv.conf + fi + sleep 1 fi - sleep 1 - fi - [ "${N::3}" = "eth" ] && ethtool -s ${N} wol g 2>/dev/null || true - # [ "${N::3}" = "eth" ] && ethtool -K ${N} rxhash off 2>/dev/null || true - initConfigKey "${N}" "${MACR}" "${USER_CONFIG_FILE}" -done + [ "${N::3}" = "eth" ] && ethtool -s "${N}" wol g 2>/dev/null || true + # [ "${N::3}" = "eth" ] && ethtool -K ${N} rxhash off 2>/dev/null || true + initConfigKey "${ETH}" "${MACR}" "${USER_CONFIG_FILE}" + done ETHN=$(echo ${ETHX} | wc -w) writeConfigKey "device.nic" "${ETHN}" "${USER_CONFIG_FILE}" # No network devices @@ -177,8 +177,8 @@ for N in ${ETHX}; do echo -e "\r${DRIVER}: \033[1;37mNOT CONNECTED\033[0m" break fi - COUNT=$((${COUNT} + 1)) - IP="$(getIP ${N})" + COUNT=$((COUNT + 1)) + IP="$(getIP "${N}")" if [ -n "${IP}" ]; then SPEED=$(ethtool ${N} 2>/dev/null | grep "Speed:" | awk '{print $2}') if [[ "${IP}" =~ ^169\.254\..* ]]; then