fixmac: a udev rule to generate a random MAC address when needed for eth* devices
This replaces 'genmac' which only works when using 'ifupdown' as networkmanager. Signed-off-by: Koen Kooi <koen@dominion.thruhere.net>
This commit is contained in:
21
recipes-bsp/fixmac/fixmac.bb
Normal file
21
recipes-bsp/fixmac/fixmac.bb
Normal file
@@ -0,0 +1,21 @@
|
||||
SUMMARY = "Provide random MAC address for devices with 00:00:00:00:00 as MAC address"
|
||||
LICENSE = "MIT"
|
||||
LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=3f40d7994397109285ec7b81fdeb3b58"
|
||||
|
||||
|
||||
SRC_URI = "file://fixmac.sh \
|
||||
file://fixmac.rules"
|
||||
|
||||
|
||||
do_install() {
|
||||
install -d ${D}${sysconfdir}/udev/rules.d
|
||||
install -m 0644 ${WORKDIR}/fixmac.rules ${D}${sysconfdir}/udev/rules.d
|
||||
|
||||
install -d ${D}${bindir}
|
||||
install -m 0755 ${WORKDIR}/fixmac.sh ${D}${bindir}
|
||||
|
||||
sed -i -e s:/sbin:${base_sbindir}:g -e s:/etc:${sysconfdir}:g ${D}${bindir}/fixmac.sh
|
||||
|
||||
}
|
||||
|
||||
RDEPENDS_${PN} = "ranpwd"
|
||||
1
recipes-bsp/fixmac/fixmac/fixmac.rules
Normal file
1
recipes-bsp/fixmac/fixmac/fixmac.rules
Normal file
@@ -0,0 +1 @@
|
||||
KERNEL=="eth*", ACTION=="add", ATTR{address}=="00:00:00:00:00:00", RUN += "/usr/bin/fixmac.sh %k"
|
||||
10
recipes-bsp/fixmac/fixmac/fixmac.sh
Executable file
10
recipes-bsp/fixmac/fixmac/fixmac.sh
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ -e /etc/ethernetmac.$1 ] ; then
|
||||
MACADDRESS="$(cat /etc/ethernetmac.$1)"
|
||||
else
|
||||
MACADDRESS="$(ranpwd -m)"
|
||||
echo ${MACADDRESS} > /etc/ethernetmac.$1
|
||||
fi
|
||||
|
||||
/sbin/ifconfig $1 hw ether ${MACADDRESS} && /sbin/ifconfig $1 up
|
||||
24
recipes-bsp/fixmac/ranpwd_git.bb
Normal file
24
recipes-bsp/fixmac/ranpwd_git.bb
Normal file
@@ -0,0 +1,24 @@
|
||||
DESCRIPTION = "Random password generator"
|
||||
LICENSE = "GPLv2+"
|
||||
LIC_FILES_CHKSUM = "file://ranpwd.c;beginline=1;endline=11;md5=0e8585e19117526efedfaeb50c345d7a"
|
||||
SECTION = "console/utils"
|
||||
PV = "1.2+git${SRCPV}"
|
||||
PR = "r0"
|
||||
|
||||
inherit autotools
|
||||
|
||||
SRC_URI = "git://git.zytor.com/utils/ranpwd.git"
|
||||
SRCREV = "b62aab579e288715b82d5575befaa2b8ff210c2b"
|
||||
|
||||
S="${WORKDIR}/git"
|
||||
|
||||
do_configure_prepend () {
|
||||
if [ ! -e acinclude.m4 -a -e aclocal.m4 ]; then
|
||||
cp aclocal.m4 acinclude.m4
|
||||
fi
|
||||
}
|
||||
|
||||
do_install() {
|
||||
install -d ${D}/${bindir}
|
||||
install -m 0755 ${S}/ranpwd ${D}/${bindir}/ranpwd
|
||||
}
|
||||
Reference in New Issue
Block a user