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

START=98
STOP=10

USE_PROCD=1
NAME=mcast

include /lib/network
include /lib/mcast


service_triggers() {
	procd_add_reload_trigger network $NAME
}

start_mcast_service() {
	local param=$@

	procd_open_instance

	procd_set_param command "${PROG_EXE}"
	if [ -n "${param}" ]; then
		procd_append_param command ${param}
	fi
	procd_set_param respawn

	procd_close_instance
}

start_service() {
	if [ -f "/etc/config/mcast" ]; then
		configure_mcast
	fi

	if ! validate_params; then
		return
	fi

	if [ -z "${PROG_PARAMS}" ]; then
		start_mcast_service
	else
		local prev_IFS="${IFS}"
		IFS=${PROG_PARAMS_SEPARATOR}
		for param in ${PROG_PARAMS}; do
			IFS="${prev_IFS}"
			start_mcast_service ${param}
		done
	fi
}

boot() {
	setup_mcast_mode
	start
}

reload_service() {
	stop
	start
}
