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

START=99
STOP=10

USE_PROCD=1
PROG="/usr/sbin/xmppc"

start_service() {
	procd_open_instance
	procd_set_param command "$PROG"
	procd_close_instance
}

reload_service() {
	xmpp_running="$(ubus call service list '{"name":"xmppc"}' | jq ".xmppc.instances.instance1.running")"
	if [ "${xmpp_running}" = "true" ]; then
		procd_send_signal xmppc '*' SIGKILL
	fi

	if [ -f "/var/state/xmppc" ]; then
		uci -q -c /var/state delete xmppc.conn_status
		uci -q -c /var/state commit xmppc
	fi
	start
}

service_triggers()
{
	procd_add_reload_trigger xmpp
}
