#!/bin/sh
[ "$ACTION" = ifup -o "$ACTION" = ifupdate -o "$ACTION" = ifdown -o "$ACTION" = iflink ] || exit 0

/etc/init.d/omr-tracker enabled || exit 0

if [ "$ACTION" = ifup -o "$ACTION" = ifupdate -o "$ACTION" = iflink ]; then
	#if [ "$(uci -q get network.${INTERFACE}.multipath)" = "on" ] || [ "$(uci -q get network.${INTERFACE}.multipath)" = "master" ]; then
	if [ "$INTERFACE" = "omrvpn" ]; then
		logger -t "OMR-Tracker" "Reloading OMR-Tracker due to $ACTION of $INTERFACE ($DEVICE)"
		# Detached: the restart waits for the old tracker to exit, up to
		# term_timeout, and netifd runs one hotplug event at a time, so
		# waiting here held back the events of every other interface
		( /etc/init.d/omr-tracker restart "$INTERFACE" >/dev/null 2>&1 </dev/null & )
	fi
fi

