#!/bin/bash ## If appletalk is off when the script is run, it will be ## enabled on the following interface ("DEFAULT_IF", which is ## set to Ethernet) and will report script feedback using the ## interface name ("DEFAULT_IF_NAME"), so modify these 2 variables ## to your liking: DEFAULT_IF=en0 DEFAULT_IF_NAME=Ethernet ## no need to edit below here, unless changes are desired echo 'Checking AppleTalk status...' echo `appletalk -s` > TAT_TEMP_FILE ETHERNET_STATUS=`cat TAT_TEMP_FILE | grep 'interface' | grep 'en0' | wc -l` AIRPORT_STATUS=`cat TAT_TEMP_FILE | grep 'interface' | grep 'en1' | wc -l` if [ $ETHERNET_STATUS = 1 ]; then echo "AppleTalk is currently set to Ethernet." echo "Switching AppleTalk from Ethernet (en0) to Airport (en1)..." sudo appletalk -d sudo appletalk -q -u en1 echo "Done! Switch was successful." rm TAT_TEMP_FILE exit elif [ $AIRPORT_STATUS = 1 ]; then echo "AppleTalk is currently set to Airport." echo "Switching AppleTalk from Airport (en1) to Ethernet (en0)..." sudo appletalk -d sudo appletalk -q -u en0 echo "Done! Switch was successful." rm TAT_TEMP_FILE exit elif [ -s TAT_TEMP_FILE ]; then echo "AppleTalk is currently disabled." echo "Enabling AppleTalk on "$DEFAULT_IF_NAME" ("$DEFAULT_IF")..." sudo appletalk -q -u $DEFAULT_IF echo "Done! AppleTalk was enabled on "$DEFAULT_IF_NAME" ("$DEFAULT_IF")." rm TAT_TEMP_FILE exit else echo "Unable to determine AppleTalk status. Now exiting..." rm TAT_TEMP_FILE exit fi