Created
January 12, 2017 11:06
-
-
Save vincentbernat/4efb349ab8e823be3ea4a78dde06dfd5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
for iface in /sys/class/net/*; do | |
[ -f $iface ] || continue | |
ip link set up dev ${iface##*/} | |
done | |
count=0 | |
pci="" | |
for iface in /sys/class/net/*; do | |
[ -f $iface/device/product ] || continue | |
case "$(cat $iface/speed 2> /dev/null)" in | |
10000) | |
ip link set down dev ${iface##*/} | |
ip link set name eth-10gb-$count dev ${iface##*/} | |
ip link set up dev eth-10gb-$count | |
count=$((count+1)) | |
pci=$(cat $iface/device/vendor):$(cat $iface/device/product) | |
;; | |
"") continue ;; | |
*) | |
ip link set down dev ${iface##*/} | |
;; | |
esac | |
done | |
[ $(count) -eq 2 ] || { | |
for iface in /sys/class/net/*; do | |
[ -f $iface/device/product ] || continue | |
case ${iface##*/},$(cat $iface/device/vendor):$(cat $iface/device/product) in | |
eth-10gb-0,*) continue ;; | |
*,$pci) | |
ip link set down dev ${iface##*/} | |
ip link set name eth-10gb-1 dev ${iface##*/} | |
ip link set up dev eth-10gb-1 | |
;; | |
esac | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment