Root/target/linux/ramips/base-files/lib/preinit/06_set_iface_mac

1#
2# Copyright (C) 2011 OpenWrt.org
3#
4
5nw718_set_mac() {
6    local part
7    local mac
8
9    [ -z $(which maccalc) ] && return
10
11    . /etc/functions.sh
12
13    part=$(find_mtd_part "factory")
14    [ -z $part ] && return
15
16    mac=$(dd bs=1 skip=4 count=6 if=$part 2>/dev/null | maccalc bin2mac)
17    [ -z $mac ] && return
18
19    mac=$(maccalc or "$mac" "02:00:00:00:00:00")
20    ifconfig eth0 hw ether $mac 2>/dev/null
21}
22
23preinit_set_mac_address() {
24    . /lib/ramips.sh
25
26    case $(ramips_board_name) in
27    nw718)
28        nw718_set_mac
29        ;;
30    esac
31}
32
33boot_hook_add preinit_main preinit_set_mac_address
34

Archive Download this file



interactive