#!/bin/sh /etc/rc.common
# OpenWRT init script for srunc. Drop into /etc/init.d/ and `chmod +x`.
#
# Setup:
#   cp srunc /usr/sbin/srunc                    # the binary
#   mkdir -p /etc/srunc
#   cp config.example.toml /etc/srunc/config.toml && vi /etc/srunc/config.toml
#   cp srunc /etc/init.d/srunc && chmod +x /etc/init.d/srunc
#   /etc/init.d/srunc enable
#   /etc/init.d/srunc start

USE_PROCD=1
START=95
STOP=01

PROG=/usr/sbin/srunc
CONFIG=/etc/srunc/config.toml

start_service() {
    procd_open_instance
    procd_set_param command "$PROG" -c "$CONFIG" login -k -D
    procd_set_param respawn 5 5 0
    procd_set_param stdout 1
    procd_set_param stderr 1
    procd_close_instance
}
