Created
October 30, 2019 20:19
-
-
Save zaneclaes/89ffcaa8ac4cbb07c002cdc313a727ef to your computer and use it in GitHub Desktop.
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 | |
interfaces=(eth0 eth1 eth2) # which interfaces to auto-detect, in descending order of priority | |
interface="eth0" # the default/current interface | |
while true; do | |
newif="$interface" | |
for i in "${interfaces[@]}"; do | |
if $(ip link show dev "$i"); then | |
newif="$i" | |
fi | |
done | |
if [[ ! "$interface" == "$newif" ]]; then | |
echo "Switching from $interface to $newif" | |
brctl delif br0 "$interface" || true | |
brctl addif br0 "$newif" | |
interface="$newif" | |
fi | |
sleep 5 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment