#!/bin/bash

. ${TOOLKIT}-functions.sh

set -e

exporter_ip=$(jtconf dns.exporter_ip)

kudjb-makeservice -p "local"	/etc/dnslocal
kudjb-makeservice -p "exporter"	/etc/dnscachex -l $exporter_ip


# rebuild links
#
(cd /etc; updatelink dnslocal/root dns)


# start services if needed
#
kudjb-service --check dnslocal	|| kudjb-service --add /etc/dnslocal
kudjb-service --check dnscachex	|| kudjb-service --add /etc/dnscachex


# rebuild dns
#
file=/etc/dns/hosts.src
if [ -f $file ]
then
	(cd /etc/dns; rm -f data data.cdb; make) || :
else
	putwarning "DJBDNS hosts.src" \
		"go to /etc/dns directory, fill your dns entries into the " \
		"file 'hosts.src' and type the command 'make' to rebuild the db"
	installfile local/hosts.src.empty $file root:root 664
fi

# cleanup old files
#
purgefiles /etc/dns/make-dns-files.sh

exit 0
