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

START=99
USE_PROCD=1

get_config() {
	config_load netspeedtest
	config_get "iperf3_enabled" "config" "iperf3_enabled" "0"
}

start_service() {
	get_config
	[ "$iperf3_enabled" -ne "1" ] && return 1
	procd_open_instance "iperf3"
	procd_set_param command /usr/bin/taskset -c 0-1 /usr/bin/iperf3
	procd_append_param command -s
	procd_set_param respawn
	procd_set_param stdout 0
	procd_set_param stderr 0
	procd_close_instance "iperf3"
}

service_triggers() {
	procd_add_reload_trigger "netspeedtest"
}

reload_service() {
	stop
	sleep 1
	start
}
