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

START=60
STOP=10

USE_PROCD=1
PROG=/usr/sbin/wifidmd

start_service()
{
	log_level=$(jsonfilter -qe '@.daemon.config.loglevel' < /etc/bbfdm/services/wifidmd.json)
	[ -z "$log_level" ] && log_level="3"

	procd_open_instance "wifidmd"
	procd_set_param command ${PROG}
	procd_append_param command -l "${log_level}"
	procd_set_param respawn
	procd_close_instance
}

reload_service()
{
	ret=$(ubus call service list '{"name":"wifidmd"}' | jsonfilter -qe '@.wifidmd.instances.wifidmd.running')
	if [ "$ret" != "true" ]; then
		stop
		start
	fi
}

service_triggers()
{
	procd_add_reload_trigger wifidmd
}
