nokia-n900-mac-hack.sh 469 B

1234567891011121314151617181920212223
  1. #!/bin/sh
  2. if [ $# -ne 2 ]; then
  3. echo "Usage: $0 iface newmac"
  4. echo " newmac is only saved if /etc/<iface>MAC is not found"
  5. exit 1
  6. fi
  7. iface="$1"
  8. newmac="$2"
  9. macfile=/etc/"$iface"mac
  10. # If no MAC is found, save the one given as argument
  11. if [ ! -e $macfile ]; then
  12. /bin/echo "$newmac" > $macfile
  13. # Otherwise load MAC from file
  14. else
  15. newmac=`/bin/cat $macfile`
  16. fi
  17. # Configure interface
  18. /sbin/ifconfig "$iface" down
  19. /sbin/ifconfig "$iface" hw ether $newmac