#!/bin/sh
#
# Make sure wifi MAC is the same as wired MAC, to get DHCP to work with
# static assignment.

set -e

PATH=/sbin:$PATH
export PATH

iface_mac() {
    IF="$1"
    LC_ALL=C ifconfig $IF | grep HWa | cut -c39-55
}

MAC1=$(iface_mac eth0)
MACW0=$(iface_mac wlan0)
if [ "$MACW0" ] ; then
    logger -t wicd/set_wireless_mac_from_eth0 \
	"changing MAC address of wlan0 from $MACW0 to $MAC1"
    ifconfig wlan0 down
    ifconfig wlan0 hw ether $MAC1
    ifconfig wlan0 up
fi
