From 66f2cc4936f3dd4c5a705894ffcbbc3279ad78a1 Mon Sep 17 00:00:00 2001 From: jvdias Date: Sun, 13 Nov 2005 19:40:55 +0000 Subject: [PATCH] script to set named forwarders with D-BUS --- namedSetForwarders | 52 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100755 namedSetForwarders diff --git a/namedSetForwarders b/namedSetForwarders new file mode 100755 index 0000000..8ee4ce1 --- /dev/null +++ b/namedSetForwarders @@ -0,0 +1,52 @@ +#!/bin/bash +# +# This script uses the named D-BUS support, which must be enabled in +# the running named with the named '-D' option, to set the forwarding zones +# in the running server. +# +# One zone argument is required, followed by any number of server IP (v4 or v6) +# addresses. If the server IP address list is empty, any forwarders for the zone +# will be removed. +# +# Usage: +# SetForwarders [ -t <'first' | 'only'> ] [ [...] ] +# +# Copyright(C) Jason Vas Dias Red Hat Inc. 2005 +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation at +# http://www.fsf.org/licensing/licenses/gpl.txt +# and included in this software distribution as the "LICENSE" file. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +usage() { echo "Usage: SetForwarders [ -t <'first' | 'only'> ] [ [...] ]"; } +type='' +if [ $# -eq 0 ]; then + usage; + exit 1; +elif [ "$1" = "-t" ]; then + if [ $# -lt 2 ]; then + echo '-t option requires an argument.' + exit 1; + fi; + type=$2; + shift 2; +fi; +if [ $# -lt 1 ]; then + echo ' first argument required.' + exit 1; +fi; +zone='string:'"$1"; +shift; +servers=''; +if [ $# -gt 0 ]; then + for svr in $*; do + servers="$servers string:$svr"; + done +fi; +dbus-send --system --type=method_call --print-reply --reply-timeout=20000 --dest=com.redhat.named /com/redhat/named com.redhat.named.text.SetForwarders $zone $type $servers;