#!/bin/sh

[ -z "$ROOT" ] && ROOT=/www
CONFIG=$ROOT/config
SCRIPT=$ROOT/script

source /lib/functions/system.sh
source $CONFIG/ap.conf
source $CONFIG/ng.conf
source $SCRIPT/utils/wifi.sh

ethMac=`cat /sys/class/net/eth0/address`

ssids=`seq 1 "$NO_SSID"`
radios=`getRadioCount`
for ssid in $ssids ; do
  [ ! `isSsidEnabled "$ssid"` ] && continue  
  for radio in `seq 1 $radios` ; do
    radioName=`getRadioName $radio`
    radioMode=`getRadioMode $radio`
    mode=`[ ! -z "$radioMode" ] && echo "_${radioMode}"`

    mac=$(macaddr_add $ethMac +$((1 + radio)))
    uci set "wireless.ssid${ssid}${mode}.macaddr"=$mac
  done
done

uci commit
