netbase (imx233-olinuxino-maxi): add MAC persistency

Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
This commit is contained in:
Otavio Salvador 2012-05-21 07:03:31 -03:00
parent b5ec87e785
commit 968b00896e
3 changed files with 53 additions and 0 deletions

View File

@ -0,0 +1,22 @@
#!/bin/sh
set -e
mac_file="/var/lib/mac/mac.$IFACE"
# Store MAC for reuse
mkdir -p /var/lib/mac
if [ ! -r "$mac_file" ]; then
echo "Storing MAC for $IFACE for future use." > /dev/stderr
cat /sys/class/net/usb0/address > "$mac_file"
exit 0
fi
# Restore MAC setting
stored=`cat "$mac_file"`
current=`cat /sys/class/net/usb0/address`
if [ "$current" != "$stored" ]; then
echo "Setting back to old MAC."
ifconfig $IFACE hw ether $stored
fi

View File

@ -0,0 +1,22 @@
# /etc/network/interfaces -- configuration file for ifup(8), ifdown(8)
# The loopback interface
auto lo
iface lo inet loopback
# Wireless interfaces
iface wlan0 inet dhcp
wireless_mode managed
wireless_essid any
wpa-driver wext
wpa-conf /etc/wpa_supplicant.conf
auto usb0
iface usb0 inet static
address 192.168.7.2
netmask 255.255.255.0
network 192.168.7.0
gateway 192.168.7.1

View File

@ -0,0 +1,9 @@
FILESEXTRAPATHS_prepend := "${THISDIR}/netbase:"
PRINC := "${@int(PRINC) + 1}"
SRC_URI_append_imx233-olinuxino-maxi = " file://00-persistent-mac"
do_install_append_imx233-olinuxino-maxi () {
install -m 0755 ${WORKDIR}/00-persistent-mac ${D}${sysconfdir}/network/if-pre-up.d
}