#!/bin/sh

for IPV4 in $(find /tmp -type f -name "newwanip_*"); do
	INTERFACE=$(cat "${IPV4}")
	rm "${IPV4}"

	echo "Reconfiguring IPv4 on ${INTERFACE}"
	configctl -dq interface newip ${INTERFACE} force
done

for IPV6 in $(find /tmp -type f -name "newwanipv6_*"); do
	INTERFACE=$(cat "${IPV6}")
	rm "${IPV6}"

	echo "Reconfiguring IPv6 on ${INTERFACE}"
	configctl -dq interface newipv6 ${INTERFACE} force
done

for PPP in $(find /tmp -type f -name "pppconfigure_*"); do
	INTERFACE=$(cat "${PPP}")
	rm "${PPP}"

	echo "Dialing PPP on ${INTERFACE}"
	# XXX run without -d to avoid code races for now:
	configctl -q interface ppp configure ${INTERFACE}
	# XXX if ppp configure is inadequate we still need this:
	#configctl -q interface reconfigure ${INTERFACE}
done
