#!/bin/sh

[ -f /etc/config/xmpp ] || exit 0

[ "$ACTION" = "ifup" ] || exit 0
[ "$INTERFACE" = "loopback" ] && exit 0

DEFWAN=$(uci -q get cwmp.cpe.default_wan_interface)
[ -n "$DEFWAN" ] && [ "$(uci -q get network."${DEFWAN}")" = "interface" ] && [ "$DEFWAN" != "$INTERFACE" ] && exit 0

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

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

IFNAME="$(uci -q get network."${INTERFACE}".ifname)"
[ "${IFNAME:0:1}" = "@" ] && exit 0

# reload xmppc if not running already
if ! pidof xmppc; then
	/etc/init.d/xmppc reload &
fi

