#!/bin/sh /etc/rc.common
# Copyright (C) 2021 Keith T. Garner

START=90

USE_PROCD=1

PROG=/usr/sbin/bluld

start_service() {
    config_load bluld

    local led_count
    local colors

    config_get led_count uleds led_count
    config_get colors uleds colors

    procd_open_instance
    procd_set_param command $PROG $led_count $colors
    procd_set_param stdout 1
    procd_set_param stderr 1
    procd_set_param nice 20
    procd_close_instance
}

service_triggers() {
    procd_add_reload_trigger "bluld"
}

reload_service() {
    stop
    start
    /etc/init.d/led restart
}

restart() {
    reload_service
}
