#!/bin/sh

# exit if running in an extender
enabled="$(uci -q get uspc.global.enabled)"
if [ "$enabled" -eq 0 ]; then
	return 0;
fi

section_exist=$(uci -q get mosquitto.uspc)
if [ -z "${section_exist}" ]; then
	uci set mosquitto.uspc=listener
fi

port=$(uci -q get uspc.mqtt.BrokerPort)
uci -q set mosquitto.uspc.enabled="1"
uci -q set mosquitto.uspc.port=$port
uci -q set mosquitto.uspc.allow_anonymous="1"
