|
jvdias |
66f2cc |
#!/bin/bash
|
|
jvdias |
66f2cc |
#
|
|
jvdias |
66f2cc |
# This script uses the named D-BUS support, which must be enabled in
|
|
jvdias |
66f2cc |
# the running named with the named '-D' option, to set the forwarding zones
|
|
jvdias |
66f2cc |
# in the running server.
|
|
jvdias |
66f2cc |
#
|
|
jvdias |
66f2cc |
# One zone argument is required, followed by any number of server IP (v4 or v6)
|
|
jvdias |
66f2cc |
# addresses. If the server IP address list is empty, any forwarders for the zone
|
|
jvdias |
66f2cc |
# will be removed.
|
|
jvdias |
66f2cc |
#
|
|
jvdias |
66f2cc |
# Usage:
|
|
jvdias |
66f2cc |
# SetForwarders [ -t <'first' | 'only'> ] <zone> [ <server IP> [...<server IP>] ]
|
|
jvdias |
66f2cc |
#
|
|
jvdias |
66f2cc |
# Copyright(C) Jason Vas Dias<jvdias@redhat.com> Red Hat Inc. 2005
|
|
jvdias |
66f2cc |
#
|
|
jvdias |
66f2cc |
# This program is free software; you can redistribute it and/or modify
|
|
jvdias |
66f2cc |
# it under the terms of the GNU General Public License as published by
|
|
jvdias |
66f2cc |
# the Free Software Foundation at
|
|
jvdias |
66f2cc |
# http://www.fsf.org/licensing/licenses/gpl.txt
|
|
jvdias |
66f2cc |
# and included in this software distribution as the "LICENSE" file.
|
|
jvdias |
66f2cc |
#
|
|
jvdias |
66f2cc |
# This program is distributed in the hope that it will be useful,
|
|
jvdias |
66f2cc |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
jvdias |
66f2cc |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
jvdias |
66f2cc |
# GNU General Public License for more details.
|
|
jvdias |
66f2cc |
#
|
|
jvdias |
66f2cc |
usage() { echo "Usage: SetForwarders [ -t <'first' | 'only'> ] <zone> [ <server> [...<server>] ]"; }
|
|
jvdias |
66f2cc |
type=''
|
|
jvdias |
66f2cc |
if [ $# -eq 0 ]; then
|
|
jvdias |
66f2cc |
usage;
|
|
jvdias |
66f2cc |
exit 1;
|
|
jvdias |
66f2cc |
elif [ "$1" = "-t" ]; then
|
|
jvdias |
66f2cc |
if [ $# -lt 2 ]; then
|
|
jvdias |
66f2cc |
echo '-t option requires an argument.'
|
|
jvdias |
66f2cc |
exit 1;
|
|
jvdias |
66f2cc |
fi;
|
|
jvdias |
66f2cc |
type=$2;
|
|
jvdias |
66f2cc |
shift 2;
|
|
jvdias |
66f2cc |
fi;
|
|
jvdias |
66f2cc |
if [ $# -lt 1 ]; then
|
|
jvdias |
66f2cc |
echo '<zone> first argument required.'
|
|
jvdias |
66f2cc |
exit 1;
|
|
jvdias |
66f2cc |
fi;
|
|
jvdias |
66f2cc |
zone='string:'"$1";
|
|
jvdias |
66f2cc |
shift;
|
|
jvdias |
66f2cc |
servers='';
|
|
jvdias |
66f2cc |
if [ $# -gt 0 ]; then
|
|
jvdias |
66f2cc |
for svr in $*; do
|
|
jvdias |
66f2cc |
servers="$servers string:$svr";
|
|
jvdias |
66f2cc |
done
|
|
jvdias |
66f2cc |
fi;
|
|
jvdias |
66f2cc |
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;
|