#!/bin/sh /etc/rc.common
START=40

USE_PROCD=1
PROG=/bin/poe.lua

service_triggers() {
	procd_add_reload_trigger poe
}

start_service() {
	[ "$(uci get poe.poe.enable)" -eq 1 ] || return 0

	local budget=$(uci get poe.poe.budget)

	procd_open_instance
	procd_set_param command "$PROG"
	procd_append_param command ${budget:-65}
	for p in `seq 1 8`; do
		local pwr=$(uci get poe.poe.port$p)
		procd_append_param command  ${pwr:-0}
	done
	procd_close_instance
}
