Created
August 15, 2013 21:29
-
-
Save craigtracey/6245105 to your computer and use it in GitHub Desktop.
Preseed udev rules. Run these in a late command...especially useful when you want to bond devices.
This file contains 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/bash | |
# this sucks, but I want my devices enumerated the way I want them | |
declare -A mac_devices | |
mac_devices["aa:bb:cc:dd:ee:f1"]="eth0" | |
mac_devices["aa:bb:cc:dd:ee:f2"]="eth1" | |
mac_devices["aa:bb:cc:dd:ee:f3"]="eth2" | |
mac_devices["aa:bb:cc:dd:ee:f4"]="eth3" | |
UDEV_NET_RULES="/etc/udev/rules.d/70-persistent-net.rules" | |
echo "# This file was at least partially configured via pressed late command" > $UDEV_NET_RULES | |
for MAC in `ifconfig -a | grep HWaddr | awk '{print $5}'`; do | |
for i in "${!mac_devices[@]}"; do | |
if [ "$MAC" == "$i" ]; then | |
echo "SUBSYSTEM==\"net\", ACTION==\"add\", DRIVERS==\"?*\", ATTR{address}==\"$i\", ATTR{dev_id}==\"0x0\", ATTR{type}==\"1\", KERNEL==\"eth*\", NAME=\"${mac_devices[$i]}\"" >> $UDEV_NET_RULES | |
fi | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment