#!/bin/bash -e

# Unconfigured installations do not contact the Hub.
[ -s "${HUBDNS_REGISTRY:-/var/lib/hubdns}/sub_apikey" ] || exit 0
[ -s "${HUBDNS_REGISTRY:-/var/lib/hubdns}/fqdn" ] || exit 0

# random sleep (max 5 min) to prevent clients from hitting the hub at the same time
SLEEP=$[ ($RANDOM % 3600) ] && sleep $SLEEP

hubdns-update --quiet
