#!/bin/sh /etc/rc.common

USE_PROCD=1
START=93
STOP=100

SVC="upagent"

start_service() {
	local factory_mode=`envctl factory get factory_mode`
	if [ "$factory_mode" == "off" ]; then
		procd_open_instance $SVC
		procd_set_param command /usr/bin/upagent
		procd_set_param respawn ${respawn_threshold:-3600} ${respawn_timeout:-30} ${respawn_retry:-5}
		echo '/tmp/%e.%p.%s.%t.core' > /proc/sys/kernel/core_pattern
		procd_set_param limits core="unlimited"
		procd_close_instance
	fi
}

stop_service() {
    killall upagent
    kill -17 1
    rm /tmp/upagent.pid
}

boot() {
    start
}

restart() {
    stop
	d2 -c upstatus.addXdeviceIdDone false 
    start
}

#start_nonopenwrt used for NH ODM to start upagent module 
#Just call this procedure to start upagent module for NH SKUs
start_nonopenwrt() {
  echo "start upagent module for Non openWRT ********* "
  /usr/bin/upagent &
}
