Allow service to be called from subscribers
authorRoy Marples <roy@marples.name>
Tue, 21 Apr 2009 15:58:12 +0000 (15:58 +0000)
committerRoy Marples <roy@marples.name>
Tue, 21 Apr 2009 15:58:12 +0000 (15:58 +0000)
libc.in
pdns_recursor.in
resolvconf.in

diff --git a/libc.in b/libc.in
index fb2cde90f12502a15e650bb11bbb44b300fc04f8..87ff437332889d22c2c1f87723b1ee0e5211fc32 100644 (file)
--- a/libc.in
+++ b/libc.in
@@ -148,8 +148,8 @@ fi
 (umask 022; printf "$newconf" >"$resolv_conf")
 
 $RESOLVCONF -s nscd restart
-retval=$?
 
+retval=0
 # Notify users of the resolver
 for script in "$LIBEXECDIR"/libc.d/*; do
        if [ -f "$script" -a -x "$script" ]; then
index 01da8dd9ef0a1d701917242937bafc5f6035e447..f73cc7235bd77a201c8b8a8b1e5ac3a3386bddfd 100755 (executable)
@@ -50,12 +50,9 @@ for d in $DOMAINS; do
        [ -n "$newns" ] && newzones="$newzones${d%%:*}=$newns\n"
 done
 
-changed=false
 if [ ! -f "$pdns_zones" ] || \
        [ "$(cat "$pdns_zones")" != "$(printf "$newzones")" ]
 then
-       changed=true
        printf "$newzones" >"$pdns_zones"
+       $RESOLVCONF -s pdns_recursor restart
 fi
-
-$changed && $RESOLVCONF -s pdns_recursor restart
\ No newline at end of file
index bebf3309ec46d5fd5faa21f015cf5a9bc7074afc..feddaa0fb85a1e4cbf4a5444d32d42663fd63ffd 100644 (file)
@@ -258,29 +258,14 @@ make_vars()
        echo "NAMESERVERS='$(uniqify $NAMESERVERS)'"
 }
 
-force=false
-while getopts a:d:fhilm:ps:uv OPT; do
-       case "$OPT" in
-       f) force=true;;
-       h) usage;;
-       m) IF_METRIC="$OPTARG";;
-       p) IF_PRIVATE=1;;
-       s) cmd=s; service="$OPTARG";;
-       '?') ;;
-       *) cmd="$OPT"; iface="$OPTARG";;
-       esac
-done
-shift $(($OPTIND - 1))
-args="$iface${iface:+ }$@"
-
 # We do our service restarting here so that our subscribers don't have to know
 # about the OS's init system.
-if [ "$cmd" = "s" ]; then
-       if [ -n "$1" ]; then
-               action="$1"
-               shift
-       fi
+service()
+{
+       local service="$1" action="$2"
+
        [ -z "$action" ] && usage "Action not specified"
+       shift; shift
 
        # If restarting check if service is running or not if we can
        if [ "$action" = restart ]; then
@@ -317,6 +302,25 @@ if [ "$cmd" = "s" ]; then
                error_exit "Don't know how to interact with services on" \
                        "this platform"
        fi
+}
+
+force=false
+while getopts a:d:fhilm:ps:uv OPT; do
+       case "$OPT" in
+       f) force=true;;
+       h) usage;;
+       m) IF_METRIC="$OPTARG";;
+       p) IF_PRIVATE=1;;
+       s) cmd=s; service="$OPTARG";;
+       '?') ;;
+       *) cmd="$OPT"; iface="$OPTARG";;
+       esac
+done
+shift $(($OPTIND - 1))
+args="$iface${iface:+ }$@"
+
+if [ "$cmd" = s ]; then
+       service "$service" "$@"
        exit $?
 fi