#!/bin/sh
[ "$(uci get syncdial.config.enabled)" = "1" ] && \
	[ "$(uci get syncdial.config.old_frame)" = "1" ] && \
	[ "$DEVICE" = "$(uci get network.wan.device)" ] && \
	[ "$ACTION" = "ifup" ] && {
	device=$(uci get network.wan.device)
	wannum=$(uci get syncdial.config.wannum)
	for i in $(seq 1 $wannum)
	do
		[ -d /sys/class/net/macvlan$i ] || {
			ip link add link $device name macvlan$i type macvlan
			ifconfig macvlan$i hw ether $(echo $(cat /sys/class/net/$device/address|awk -F ":" '{print $1":"$2":"$3":"$4":"$5":" }')$(echo "" | awk -F ":" '{printf("%X\n", 16+i);}' i=$i))
			ifconfig macvlan$i up
		}
	done
}
