Last active
January 11, 2018 01:26
-
-
Save elvisizer/9d22d7d7e82c672841b284617ab30325 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/bash | |
echo "detecting network hardware" | |
networksetup -detectnewhardware | |
sleep 1 | |
echo "setting network service order" | |
while read networkService; do | |
if [[ ${networkService} == "Thunderbolt Bridge" ]]; then | |
deprioritizedServices+=( "${networkService}" ) | |
elif [[ ${networkService} =~ .*Ethernet.* ]] || [[ ${networkService} =~ .*Thunderbolt.* ]]; then | |
prioritizedServices+=( "${networkService}" ) | |
elif [[ ${networkService} =~ .*Bluetooth.* ]] || [[ ${networkService} =~ .*FireWire.* ]]; then | |
deprioritizedServices+=( "${networkService}" ) | |
else | |
otherServices+=( "${networkService}" ) | |
fi | |
done < <( networksetup -listnetworkserviceorder | awk '/^\([0-9]/{$1 ="";gsub("^ ","");print}' ) | |
networksetup -ordernetworkservices "${prioritizedServices[@]}" "${otherServices[@]}" "${deprioritizedServices[@]}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment