clover: Adjust mac address script to read correctly from persist
This commit is contained in:
parent
8e41df59bf
commit
3b86140029
1 changed files with 42 additions and 13 deletions
|
@ -27,20 +27,49 @@
|
||||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#
|
#
|
||||||
|
|
||||||
MACADDRESS=/persist/wlan_mac.bin
|
CLOVERMAC=/persist/wlan_mac.clover
|
||||||
MACADDRESSVENDOR=/vendor/firmware/wlan/qca_cld/wlan_mac.bin
|
WLAN_MAC_BIN=/persist/wlan_mac.bin
|
||||||
|
MACADDRESSBIN=/persist/wlan_bt/wlan.mac
|
||||||
|
INTFSTR0="Intf0MacAddress="
|
||||||
|
MAC0=000AF58989FF
|
||||||
|
|
||||||
# Mount vendor with read write permission
|
get_mac () {
|
||||||
mount -o remount,rw /vendor
|
if [ -f $MACADDRESSBIN ]; then
|
||||||
|
realMac=$(printf "%b" | od -An -t x1 -w6 -N6 $MACADDRESSBIN | tr -d '\n ')
|
||||||
|
else
|
||||||
|
if [ -f $WLAN_MAC_BIN ]; then
|
||||||
|
checkMac=$(printf "%b" | od -An -t x1 -w6 -N6 $CLOVERMAC | tr -d '\n ')
|
||||||
|
if [ $checkMac != $MAC0 ] && [ "${checkMac:0:2}" != "49" ]; then
|
||||||
|
realMac=$checkMac
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
realMac=$MAC0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Remove old wlan_mac.bin file in vendor
|
wlan_mac () {
|
||||||
rm -f /vendor/firmware/wlan/qca_cld/wlan_mac.bin
|
wlanMac=$(head -n 1 $CLOVERMAC)
|
||||||
|
wlanMac=$(echo -e "${wlanMac//$INTFSTR0}")
|
||||||
|
}
|
||||||
|
|
||||||
# Read out WiFi Mac Address
|
write_mac () {
|
||||||
macaddr=$(printf "%b" | od -An -t x1 -w6 -N6 $MACADDRESS | tr -d '\n ')
|
echo -e "$INTFSTR0""$realMac" >$CLOVERMAC
|
||||||
|
echo -e "END">>$CLOVERMAC
|
||||||
|
chown wifi $CLOVERMAC
|
||||||
|
chgrp wifi $CLOVERMAC
|
||||||
|
}
|
||||||
|
|
||||||
# Write new Mac Adress in Vendor
|
if [ -f $CLOVERMAC ]; then
|
||||||
echo -e "Intf0MacAddress=$macaddr" "\nEND">$MACADDRESSVENDOR
|
get_mac
|
||||||
|
wlan_mac
|
||||||
# Mount vendor with read only permission
|
if [ "${realMac:0:6}" == "${wlanMac:0:6}" ] && [ "${wlanMac:0:2}" != "49" ]; then
|
||||||
mount -o remount,ro /vendor
|
exit 1
|
||||||
|
else
|
||||||
|
get_mac
|
||||||
|
write_mac
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
get_mac
|
||||||
|
write_mac
|
||||||
|
fi
|
||||||
|
|
Loading…
Reference in a new issue