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

USE_PROCD=1

START=95
STOP=01

CONFIGURATION=esp2net
SECTION=esp2net

parse_esp2net()
{
    local uart
    local port
    local disabled
    config_get uart "${1}" uart
    config_get port "${1}" port
    config_get_bool disabled "${1}" disabled 0
    [ "$disabled" -eq 1 ] && return;
    procd_open_instance
    procd_set_param respawn 3600 5 5
    procd_set_param command /usr/sbin/esp2net "$uart" "$port"
    procd_set_param file /etc/config/esp2net
    procd_set_param stdout 1
    procd_set_param stderr 1
    procd_close_instance
}

start_service() {
    config_load "${CONFIGURATION}"
    config_foreach parse_esp2net "${SECTION}"
}
