mirror of
https://github.com/AuxXxilium/arc-addons.git
synced 2024-11-23 21:50:52 +07:00
sortnetif: fix
Signed-off-by: AuxXxilium <info@auxxxilium.tech>
This commit is contained in:
parent
00e35c3cd6
commit
186885d43e
@ -10,15 +10,15 @@ if [ "${1}" = "patches" ]; then
|
||||
echo "Installing addon sortnetif - ${1}"
|
||||
|
||||
ETHLIST=""
|
||||
ETHX=$(ls /sys/class/net/ 2>/dev/null | grep eth) # real network cards list
|
||||
ETHX="$(ls /sys/class/net/ 2>/dev/null | grep eth)" # real network cards list
|
||||
for ETH in ${ETHX}; do
|
||||
MAC="$(cat /sys/class/net/${ETH}/address 2>/dev/null | sed 's/://g' | tr '[:upper:]' '[:lower:]')"
|
||||
BUS=$(ethtool -i ${ETH} 2>/dev/null | grep bus-info | cut -d' ' -f2)
|
||||
BUS="$(ethtool -i ${ETH} 2>/dev/null | grep bus-info | cut -d' ' -f2)"
|
||||
ETHLIST="${ETHLIST}${BUS} ${MAC} ${ETH}\n"
|
||||
done
|
||||
|
||||
if [ -n "${2}" ]; then
|
||||
MACS=$(echo "${2}" | sed 's/://g' | tr '[:upper:]' '[:lower:]' | tr ',' ' ')
|
||||
MACS="$(echo "${2}" | sed 's/://g' | tr '[:upper:]' '[:lower:]' | tr ',' ' ')"
|
||||
ETHLISTTMPC=""
|
||||
ETHLISTTMPF=""
|
||||
|
||||
@ -47,23 +47,23 @@ EOF
|
||||
while true; do
|
||||
cat /tmp/ethlist
|
||||
[ ${IDX} -ge $(wc -l </tmp/ethlist) ] && break
|
||||
ETH=$(cat /tmp/ethlist | sed -n "$((${IDX} + 1))p" | cut -d' ' -f3)
|
||||
ETH="$(cat /tmp/ethlist | sed -n "$((${IDX} + 1))p" | cut -d' ' -f3)"
|
||||
echo "ETH: ${ETH}"
|
||||
if [ -n "${ETH}" ] && [ ! "${ETH}" = "eth${IDX}" ]; then
|
||||
echo "change ${ETH} <=> eth${IDX}"
|
||||
ip link set dev eth${IDX} down
|
||||
ip link set dev ${ETH} down
|
||||
sleep 1
|
||||
ip link set dev eth${IDX} name tmp
|
||||
ip link set dev eth${IDX} name ethN
|
||||
ip link set dev ${ETH} name eth${IDX}
|
||||
ip link set dev tmp name ${ETH}
|
||||
ip link set dev ethN name ${ETH}
|
||||
sleep 1
|
||||
ip link set dev eth${IDX} up
|
||||
ip link set dev ${ETH} up
|
||||
sleep 1
|
||||
sed -i "s/eth${IDX}/tmp/" /tmp/ethlist
|
||||
sed -i "s/eth${IDX}/ethN/" /tmp/ethlist
|
||||
sed -i "s/${ETH}/eth${IDX}/" /tmp/ethlist
|
||||
sed -i "s/tmp/${ETH}/" /tmp/ethlist
|
||||
sed -i "s/ethN/${ETH}/" /tmp/ethlist
|
||||
sleep 1
|
||||
fi
|
||||
IDX=$((${IDX} + 1))
|
||||
|
Loading…
Reference in New Issue
Block a user