#!/usr/bin/sh

. /usr/libexec/ddns-update/functions

DAEMON=false

while [ $# -gt 0 ]; do
	case $1 in
		-c)
			CONF="$2"
			shift
			;;
		-d|--daemon)
			DAEMON=true
			if [ $# -ge 2 ]; then
				INTERVAL=$2
				shift
			fi
			;;
		*)
			echo "Unknown parameter $1" 1>&2
			exit 1
	esac
	shift
done

if $DAEMON ; then
	echo $$ > /run/ddns-update/ddns-update.pid
	while : ; do
		discover_update
		sleep $INTERVAL
	done
else
	discover_update
fi
