#!/bin/sh /etc/rc.common
# shellcheck shell=sh
# shellcheck disable=SC2034
# Procd wrapper for /usr/libexec/r01-net-watchdog. Starts late (after
# travelmate, after wireless is brought up) and runs the watchdog loop
# under procd so it gets respawned if it dies.
#
# Suppressed lints:
#   SC2034: USE_PROCD/START/STOP are contract vars consumed by /etc/rc.common

USE_PROCD=1
START=98
STOP=02

start_service() {
	procd_open_instance r01-net-watchdog
	procd_set_param command /usr/libexec/r01-net-watchdog
	procd_set_param respawn 5 5 0
	procd_set_param stdout 1
	procd_set_param stderr 1
	procd_close_instance
}

service_triggers() {
	# Reload when the netwatch section in /etc/config/r01 changes,
	# so live UCI tuning is picked up by 'uci commit r01 && reload_config'.
	procd_add_reload_trigger r01
}

reload_service() {
	stop
	start
}
