set-mac.sh 434 Bytes
Newer Older
fuyanbin's avatar
fuyanbin committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/system/bin/sh
if [[ -f /system/.no_macaddres_in_eeprom ]]
then
    macaddress=$(cat /data/.macaddress)
    if [[ -z $macaddress ]]
    then
        MAC_ADDRESS_OUIID="2c:f0:5d"
        macaddress=$(hexdump -n3 -e"/3 \"$MAC_ADDRESS_OUIID\" 3/1 \":%02x\"" /dev/random)
        echo $macaddress > /data/.macaddress
    fi
    ip link set eth0 down
    ip link set dev eth0 addr $macaddress
    ip link set eth0 up
    restart netd
fi