#!/bin/sh /etc/rc.common
# Copyright (c) 2021 OpenWrt.org

START=18

USE_PROCD=1
PROG=/usr/sbin/spotfilter

reload_service() {
	ubus call spotfilter interface_add "$(cat /tmp/spotfilter.json)"
}

start_service() {
	procd_open_instance
	procd_set_param command "$PROG"
	procd_set_param respawn
	procd_close_instance
}

service_started() {
	ubus -t 10 wait_for spotfilter
	[ $? = 0 ] && reload_service
}
