Correct issue with dragonfly libexecdir
[openresolv] / pdns_recursor.in
old mode 100755 (executable)
new mode 100644 (file)
index f73cc72..ad2d922
@@ -1,5 +1,5 @@
 #!/bin/sh
-# Copyright 2009 Roy Marples
+# Copyright (c) 2009-2011 Roy Marples
 # All rights reserved
 
 # PowerDNS Recursor subscriber for resolvconf
 [ -f "@SYSCONFDIR@"/resolvconf.conf ] || exit 0
 . "@SYSCONFDIR@/resolvconf.conf" || exit 1
 [ -z "$pdns_zones" ] && exit 0
-: ${RESOLVCONF:=resolvconf}
-[ -z "$NAMESERVERS" -a -z "$DOMAINS" ] && eval "$("$RESOLVCONF" -v)"
+[ -z "$RESOLVCONF" ] && eval "$(@SBINDIR@/resolvconf -v)"
+NL="
+"
+
+: ${pdns_service:=pdns_recursor}
 
 newzones=
-for n in $NAMESERVERS; do
-       newzones="$newzones${newzones:+,}$n"
-done
-[ -n "$newzones" ] && newzones=".=$newzones\n"
 
-dbusdest=
+# pds_recursor does not present support global forward servers, which
+# does limit it's usefulness somewhat.
+# If it did, the below code can be enabled, or something like it.
+#for n in $NAMESERVERS; do
+#      newzones="$newzones${newzones:+,}$n"
+#done
+#[ -n "$newzones" ] && newzones=".=$newzones$NL"
+
 for d in $DOMAINS; do
        newns=
        ns="${d#*:}"
@@ -47,12 +53,26 @@ for d in $DOMAINS; do
                [ "$ns" = "${ns#*,}" ] && break
                ns="${ns#*,}"
        done
-       [ -n "$newns" ] && newzones="$newzones${d%%:*}=$newns\n"
+       [ -n "$newns" ] && newzones="$newzones${d%%:*}=$newns$NL"
 done
 
+# Try to ensure that config dirs exist
+if type config_mkdirs >/dev/null 2>&1; then
+       config_mkdirs "$pdnsd_zones"
+else
+       @SBINDIR@/resolvconf -D "$pdnsd_zones"
+fi
+
 if [ ! -f "$pdns_zones" ] || \
-       [ "$(cat "$pdns_zones")" != "$(printf "$newzones")" ]
+       [ "$(cat "$pdns_zones")" != "$(printf %s "$newzones")" ]
 then
-       printf "$newzones" >"$pdns_zones"
-       $RESOLVCONF -s pdns_recursor restart
+       printf %s "$newzones" >"$pdns_zones"
+       if [ -n "$pdns_restart" ]; then
+               eval $pdns_restart
+       elif [ -n "$RESTARTCMD" ]; then
+               set -- ${pdns_service}
+               eval $RESTARTCMD
+       else
+               @SBINDIR@/resolvconf -r ${pdns_service}
+       fi
 fi