#!/bin/sh

start() {

	while [ 1 ]
	do
		tr069_enable=$(uci -q get tr069.@tr069[0].cpe_enable)
		if [ $tr069_enable -eq 1 ]; then
			proc_tr069=$(ps | grep [t]r069_client)
			if [ -z "$proc_tr069" ]; then
				tr069_client &
			fi
		fi
		sleep 10
	done
}

stop() {
	killall tr069_client
}

case "$1" in
	start) start;;
	stop) stop;;
esac
