09_hardware 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/bin/sh
  2. #
  3. # Copyright (C) 2010 OpenWrt.org
  4. #
  5. # This is free software, licensed under the GNU General Public License v2.
  6. # See /LICENSE for more information.
  7. #
  8. #
  9. # This script sets system defaults for the hardware on firstboot
  10. #
  11. local hardware=`sed -n /Hardware/s/.*:.//p /proc/cpuinfo`
  12. wrt350nv2_default() {
  13. # leds
  14. uci batch <<__EOF
  15. set system.power_led=led
  16. set system.power_led.name='Power LED (green)'
  17. set system.power_led.sysfs='wrt350nv2:green:power'
  18. set system.power_led.default='1'
  19. set system.wifi_led=led
  20. set system.wifi_led.name='Wireless LED (green)'
  21. set system.wifi_led.sysfs='wrt350nv2:green:wireless'
  22. set system.wifi_led.trigger='netdev'
  23. set system.wifi_led.dev='wlan0'
  24. set system.wifi_led.mode='link tx rx'
  25. set system.wifi_led.default='0'
  26. commit system
  27. __EOF
  28. # add mac address from U-Boot partition to lan and wan devices
  29. MTD=`grep -e 'u-boot' /proc/mtd`
  30. MTD=`echo ${MTD} | sed 's/[a-z]*\([0-9]*\):.*/\1/'`
  31. [ -n "${MTD}" ] && {
  32. MACADDR=`dd if=/dev/mtdblock${MTD} bs=1 skip=262048 count=6 2>/dev/null | hexdump -e '1/1 "%02x"'`
  33. MACADDR2=$(( 0x${MACADDR} + 1))
  34. MACADDR2=`printf "%012x" ${MACADDR2}`
  35. MACADDR=`echo ${MACADDR} | sed 's/\(..\)/\1:/g' | sed 's/:$//'`
  36. MACADDR2=`echo ${MACADDR2} | sed 's/\(..\)/\1:/g' | sed 's/:$//'`
  37. uci set network.eth0.macaddr=${MACADDR}
  38. uci set network.lan.macaddr=${MACADDR}
  39. uci set network.wan.macaddr=${MACADDR2}
  40. uci commit network
  41. }
  42. }
  43. case "${hardware}" in
  44. 'Linksys WRT350N v2')
  45. wrt350nv2_default
  46. ;;
  47. esac