Added set_r1plus_lan_mac.sh to set orangepir1plus's mac address

This commit is contained in:
leeboby
2020-12-22 16:40:48 +08:00
parent a8c4e4cadb
commit 9ef6aa410d
3 changed files with 57 additions and 1 deletions

View File

@@ -245,6 +245,9 @@ family_tweaks()
if [[ $BOARD == orangepir1plus ]]; then
# execute specific tweaks function if present
[[ $(type -t family_tweaks_s) == function ]] && family_tweaks_s
# rename USB based network to lan0
mkdir -p $SDCARD/etc/udev/rules.d/
echo 'SUBSYSTEM=="net", ACTION=="add", DRIVERS=="r8152", KERNEL=="eth1", NAME="lan0"' > $SDCARD/etc/udev/rules.d/70-rename-lan.rules

View File

@@ -19,7 +19,37 @@ family_tweaks_bsp()
if [[ $BOARD == orangepir1plus ]]; then
:
install -m 755 $EXTER/packages/blobs/rockchip/set_r1plus_lan_mac.sh $destination/usr/bin/
fi
}
family_tweaks_s()
{
if [[ $BOARD == orangepir1plus ]]; then
chroot $SDCARD /bin/bash -c "apt-get -y -qq install rfkill bluetooth bluez bluez-tools >/dev/null 2>&1"
cat <<-EOF > "${SDCARD}"/etc/rc.local
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
/usr/bin/set_r1plus_lan_mac.sh
exit 0
EOF
chmod +x "${SDCARD}"/etc/rc.local
fi
}

View File

@@ -0,0 +1,23 @@
#!/bin/bash
MAC_BEF=$(cat /sys/class/net/lan0/address |cut -b -6)
MAC=$(cat /sys/class/net/lan0/address |cut -b 7-)
MAC=${MAC//:/""}
MAC=$((16#$MAC))
MAC=$(($MAC-1))
MAC=`printf %x $MAC`
NUM=`expr 8 - ${#MAC}`
while [ $NUM -ne 0 ]
do
MAC=0$MAC
let "NUM--"
done
echo ${MAC} >> /usr/local/test.log
echo ${MAC_BEF} >> /usr/local/test.log
MAC=${MAC_BEF}${MAC:0:2}:${MAC:2:2}:${MAC:4:2}:${MAC:6}
ifconfig eth0 down
ifconfig eth0 hw ether $MAC
ifconfig eth0 up