Skip to content

Commit

Permalink
Added enable_external_network_adapter.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
golbiga committed Dec 6, 2013
1 parent c1842b5 commit e112020
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions enable_external_network_adapter/enable_external_network_adapter.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/sh
# Checks to see if the Mac is either a MacBook Pro Retina or MacBook Air
# If it's either of these machines, the script will then check for External Network Adapters
# If either adapter is present, it will add the adapter to network services
# Resolves an issue with USB & Thunderbolt Ethernet adapters with DeployStudio 1.6.3

mbpr=`system_profiler SPHardwareDataType | grep "Model Identifier" | awk '{print $3}' | cut -f1 -d ","`
mba=`system_profiler SPHardwareDataType | grep "Model Identifier" | awk '{print $3}' | cut -c-10`
usbAdapter=`/usr/sbin/networksetup -listallhardwareports | grep "Hardware Port: USB Ethernet"`
tbAdapter=`/usr/sbin/networksetup -listallhardwareports | grep "Hardware Port: Thunderbolt Ethernet"`

/usr/sbin/networksetup -detectnewhardware

if [ $mbpr = "MacBookPro10" -o $mbpr = "MacBookPro11" ]; then
if [ "$usbAdapter" != "" ]; then
/usr/sbin/networksetup -createnetworkservice USB\ Ethernet 'USB Ethernet'
echo "USB Ethernet added to Network Services"
else
echo "No USB Adapter connected"
fi
if [ "$tbAdapter" != "" ]; then
/usr/sbin/networksetup -createnetworkservice Thunderbolt\ Ethernet 'Thunderbolt Ethernet'
echo "Thunderbolt Ethernet added to Network Services"
else
echo "No Thunderbolt Adapter connected"
fi
elif [ $mba = "MacBookAir" ]; then
if [ "$usbAdapter" != "" ]; then
/usr/sbin/networksetup -createnetworkservice USB\ Ethernet 'USB Ethernet'
echo "USB Ethernet added to Network Services"
else
echo "No USB Adapter connected"
fi
if [ "$tbAdapter" != "" ]; then
/usr/sbin/networksetup -createnetworkservice Thunderbolt\ Ethernet 'Thunderbolt Ethernet'
echo "Thunderbolt Ethernet added to Network Services"
else
echo "No Thunderbolt Adapter connected"
fi
else
echo "This machine does not use external network adapters"
fi

exit 0

0 comments on commit e112020

Please sign in to comment.