Hello again Martin, On Mon, Feb 01, 2010 at 11:48:30AM +1300, martin f. krafft wrote: > +if ! echo "$MD5SUM" | md5sum -c 2>&1; then > + invoke-rc.d unbound force-reload > +fi
For unbound, force-reload is actually the same as restart, so you are forcing it to restart (including discarding the contents of its cache) every time the nameserver information changes. Unbound supports dynamically setting the upstream resolvers using unbound-control. I believe that's both cleaner (no messy files in /var/cache) and less disruptive. I have attached a script /etc/resolvconf/update.d/unbound that does it the unbound-control way, in case you're interested. -Phil
#!/bin/sh # # Script to tell unbound to use forwarders # # Assumption: On entry, PWD contains the resolv.conf-type files # # Licensed under the GNU GPL. See /usr/share/doc/resolvconf/copyright. # # Written by Phil Vandry <van...@tzone.org> based on existing scripts # by Thomas Hood <jdth...@yahoo.co.uk> set -e PATH=/sbin:/bin [ -x /usr/sbin/unbound ] || exit 0 [ -x /usr/sbin/unbound-control ] || exit 0 [ -x /lib/resolvconf/list-records ] || exit 1 # Default value SET_UNBOUND_FORWARDERS=y # Default override [ -r /etc/default/resolvconf ] && . /etc/default/resolvconf case "$SET_UNBOUND_FORWARDERS" in y|Y|yes|YES|Yes) ;; *) exit 0 ;; esac # Stores arguments (minus duplicates) in RSLT, separated by spaces # Doesn't work properly if an argument itself contain whitespace uniquify() { RSLT="" while [ "$1" ] ; do for E in $RSLT ; do [ "$1" = "$E" ] && { shift ; continue 2 ; } done RSLT="${RSLT:+$RSLT }$1" shift done } # Get list of records, excluding all those for the loopback interface RSLVCNFFILES="$(/lib/resolvconf/list-records | sed -e '/^lo$/d' -e '/^lo[.]/d')" ### Compile semicolon-separated list nameservers ### NMSRVRS="" if [ "$RSLVCNFFILES" ] ; then uniquify $(sed -n -e 's/^[[:space:]]*nameserver[[:space:]]\+//p' $RSLVCNFFILES) [ "$RSLT" ] && NMSRVRS="${RSLT}" fi if [ -z "$NMSRVRS" ]; then ARGS=off else ARGS="$NMSRVRS" fi if /usr/sbin/unbound-control status >/dev/null 2>&1; then stopped=no elif [ $? -eq 3 ]; then stopped=yes else # any other error, assume it's running and try anyway stopped=no fi if [ $stopped = no ]; then /usr/sbin/unbound-control forward $ARGS | grep -v '^ok$' || : else # Try to set the forwarders anyway but it probably won't # work so silence errors /usr/sbin/unbound-control forward $ARGS >/dev/null 2>&1 || : fi