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

START=90

USE_PROCD=1

reload_service() {
	restart
}

service_triggers() {
	procd_add_reload_trigger fbwifi
}

start_service() {

	config_load fbwifi
	config_get_bool enabled 'main' 'enabled' '0'
	[ "$enabled" -eq 0 ] && return

	config_get http_port main http_port
	[ -z "$http_port" ] && {
		logger -t fbwifi "required option http_port not set"
		exit 1
	}

	config_get https_port main https_port
	[ -z "$https_port" ] && {
		logger -t fbwifi "required option https_port not set"
		exit 1
	}

	logger "[fbwifi] Enabled; starting"

	mkdir -p /tmp/fbwifi

	/usr/sbin/fbwifi reload

	procd_open_instance
	procd_set_param command /usr/sbin/fbwifi_validate_token_db
	procd_set_param respawn 1 300 0
	procd_close_instance
}
