#!/bin/sh /etc/rc.common
# shellcheck disable=SC2039
# vim: set noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 :
# Copyright (C) 2018-2022 Ycarus (Yannick Chabanois) <ycarus@zugaina.org>
# Released under GPL 3. See LICENSE for the full terms.

# shellcheck disable=SC2034
{
	START=90
	STOP=10
	USE_PROCD=1
}

. /usr/lib/unbound/iptools.sh
. /lib/functions/network.sh

_launch_autorate() {
	logger -t "SQM-autorate" "Launch on $1"
	config_get enabled "$1" enabled
	[ "${enabled}" != "1" ] && return
	config_get autorate "$1" autorate
	[ "${autorate}" != "1" ] && return

	procd_open_instance
	# shellcheck disable=SC2086
	procd_set_param command /usr/share/sqm-autorate/CAKE-autorate.sh "$1"
#	procd_append_param env "OMR_TRACKER_SERVER_HTTP_TEST=$server_http_test"
	procd_set_param limits nofile="51200 51200"
	procd_set_param respawn 0 10 0
	procd_set_param stderr 1
	procd_close_instance
	sleep 2
}

start_service() {
	config_load sqm
	config_foreach _launch_autorate queue
}

