#!/bin/sh /etc/rc.common
# Example script
# Copyright (C) 2007 OpenWrt.org
START=50
STOP=90

USE_PROCD=1
PARAM_PATH="/tmp/param/"

start_service() {
	local testenv=`uci get debug.debug_mode.testserver_enable`

    # check param dir
    if [ ! -d "$PARAM_PATH" ]; then
        mkdir -p "$PARAM_PATH"
    fi
	procd_open_instance

	if [ -n "${testenv}" -a "${testenv}" != "0" ]; then
		procd_set_param command /usr/sbin/auto_update -t
	else
		procd_set_param command /usr/sbin/auto_update
	fi

	#procd_set_param limits core="unlimited"
	procd_set_param respawn
	procd_close_instance
}
reload_service() {
	rc_procd start_service
	return 0
}

start() {
	local testenv=`uci get debug.debug_mode.testserver_enable`

	if [ -n "${testenv}" -a "${testenv}" != "0" ]; then
		auto_update -t &
	else
		auto_update &
	fi
}

stop() {
    killall auto_update
}
