#!/bin/sh

unique_append()
{
	grep -qF "$1" "$2" || echo "$1" >> "$2"
}

uci set shared-state.bat_hosts=dataType
uci set shared-state.bat_hosts.name='bat-hosts'
uci set shared-state.bat_hosts.scope='community'
uci set shared-state.bat_hosts.ttl='2400'
uci set shared-state.bat_hosts.update_interval='30'
uci commit shared-state

unique_append \
	'*/30 * * * * ((sleep $(($RANDOM % 120)); shared-state-publish_bat_hosts &> /dev/null)&)' \
	/etc/crontabs/root
