OpenWrt – Blame information for rev 4
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
4 | office | 1 | #!/bin/sh |
2 | |||
3 | set_ether_mac() { |
||
4 | # Most devices have a standard "VCTL" partition |
||
5 | CONFIG_PARTITION="$(grep "VCTL" /proc/mtd | cut -d: -f1)" |
||
6 | if [ ! -z $CONFIG_PARTITION ] ; then |
||
7 | MAC1="$(strings /dev/$CONFIG_PARTITION |grep MAC|cut -d: -f2|cut -c3-14|sed -e 's,\(..\),:\1,g' -e 's,^:,,')" |
||
8 | MAC2="$(strings /dev/$CONFIG_PARTITION |grep MAC|cut -d: -f8|cut -c3-14|sed -e 's,\(..\),:\1,g' -e 's,^:,,')" |
||
9 | |||
10 | ifconfig eth0 hw ether $MAC1 2>/dev/null |
||
11 | ifconfig eth1 hw ether $MAC2 2>/dev/null |
||
12 | return 0 |
||
13 | fi |
||
14 | |||
15 | # The DNS-313 has a special field in its RedBoot |
||
16 | # binary that we need to check |
||
17 | CONFIG_PARTITION="$(grep "RedBoot" /proc/mtd | cut -d: -f1)" |
||
18 | if [ ! -z $CONFIG_PARTITION ] ; then |
||
19 | DEVID="$(dd if=/dev/mtdblock0 bs=1 skip=119508 count=7 2>/dev/null)" |
||
20 | if [ "x$DEVID" = "xdns-313" ] ; then |
||
21 | MAC1="$(dd if=/dev/mtdblock0 bs=1 skip=119540 count=6 2>/dev/null | hexdump -n6 -e '/1 ":%02X"' | sed s/^://g)" |
||
22 | ifconfig eth0 hw ether $MAC1 2>/dev/null |
||
23 | return 0 |
||
24 | fi |
||
25 | fi |
||
26 | } |
||
27 | |||
28 | boot_hook_add preinit_main set_ether_mac |