#!/bin/sh

# do not start testnet if the feature is explicitly disabled
[ "$(uci -q get testnet.global.enabled)" = "0" ] && exit 0

[ "$ACTION" == "ifup" -o "$ACTION" == "ifdown" ] || exit 0

interface_check() {
	[ "$(uci -q get network.$INTERFACE.is_lan)" = "1" ] && exit 0

	[ "$(uci -q get network.$INTERFACE.proto)" = "none" ] && exit 0

	[ "$(uci -q get network.$INTERFACE.defaultroute)" = "0" ] && exit 0
}

interface_check
/etc/init.d/testnet reload
