1#!/bin/bash 2# 3# This script uses the named D-BUS support, which must be enabled in 4# the running named with the named '-D' option, to set the forwarding zones 5# in the running server. 6# 7# One zone argument is required, followed by any number of server IP (v4 or v6) 8# addresses. If the server IP address list is empty, any forwarders for the zone 9# will be removed. 10# 11# Usage: 12# SetForwarders [ -t <'first' | 'only'> ] <zone> [ <server IP> [...<server IP>] ] 13# 14# Copyright(C) Jason Vas Dias<jvdias@redhat.com> Red Hat Inc. 2005 15# 16# This program is free software; you can redistribute it and/or modify 17# it under the terms of the GNU General Public License as published by 18# the Free Software Foundation at 19# http://www.fsf.org/licensing/licenses/gpl.txt 20# and included in this software distribution as the "LICENSE" file. 21# 22# This program is distributed in the hope that it will be useful, 23# but WITHOUT ANY WARRANTY; without even the implied warranty of 24# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 25# GNU General Public License for more details. 26# 27usage() { echo "Usage: SetForwarders [ -t <'first' | 'only'> ] <zone> [ <server> [...<server>] ]"; } 28type='' 29if [ $# -eq 0 ]; then 30 usage; 31 exit 1; 32elif [ "$1" = "-t" ]; then 33 if [ $# -lt 2 ]; then 34 echo '-t option requires an argument.' 35 exit 1; 36 fi; 37 type=$2; 38 shift 2; 39fi; 40if [ $# -lt 1 ]; then 41 echo '<zone> first argument required.' 42 exit 1; 43fi; 44zone='string:'"$1"; 45shift; 46servers=''; 47if [ $# -gt 0 ]; then 48 for svr in $*; do 49 servers="$servers string:$svr"; 50 done 51fi; 52dbus-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; 53