aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel/test/inet_res_SUITE_data/run-named
diff options
context:
space:
mode:
authorErlang/OTP <[email protected]>2009-11-20 14:54:40 +0000
committerErlang/OTP <[email protected]>2009-11-20 14:54:40 +0000
commit84adefa331c4159d432d22840663c38f155cd4c1 (patch)
treebff9a9c66adda4df2106dfd0e5c053ab182a12bd /lib/kernel/test/inet_res_SUITE_data/run-named
downloadotp-84adefa331c4159d432d22840663c38f155cd4c1.tar.gz
otp-84adefa331c4159d432d22840663c38f155cd4c1.tar.bz2
otp-84adefa331c4159d432d22840663c38f155cd4c1.zip
The R13B03 release.OTP_R13B03
Diffstat (limited to 'lib/kernel/test/inet_res_SUITE_data/run-named')
-rwxr-xr-xlib/kernel/test/inet_res_SUITE_data/run-named163
1 files changed, 163 insertions, 0 deletions
diff --git a/lib/kernel/test/inet_res_SUITE_data/run-named b/lib/kernel/test/inet_res_SUITE_data/run-named
new file mode 100755
index 0000000000..b418607d48
--- /dev/null
+++ b/lib/kernel/test/inet_res_SUITE_data/run-named
@@ -0,0 +1,163 @@
+#! /bin/sh
+##
+## %CopyrightBegin%
+##
+## Copyright Ericsson AB 2009. All Rights Reserved.
+##
+## The contents of this file are subject to the Erlang Public License,
+## Version 1.1, (the "License"); you may not use this file except in
+## compliance with the License. You should have received a copy of the
+## Erlang Public License along with this software. If not, it can be
+## retrieved online at http://www.erlang.org/.
+##
+## Software distributed under the License is distributed on an "AS IS"
+## basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+## the License for the specific language governing rights and limitations
+## under the License.
+##
+## %CopyrightEnd%
+##
+#
+
+#
+## run-named
+##
+## $0 IPAddress PortNum SubDir
+##
+## * Create a work directory ./SubDir, create a named.conf there.
+## * Locate named and check its version.
+## * Zopy zone files from `dirname $0`/SubDir to ./SubDir.
+## * Start named in ./SubDir with logging to named.log there.
+## * Wait for "quit" on stdin.
+## * Terminate named and wait for it.
+##
+## Prints status lines starting with tag and colon (think mail header):
+## Error: have given up, no name server started
+## Running: name server is running, waiting for "quit"
+## Other tags: diagnostics info
+#
+
+unset LDPATH CDPATH ENV BASH_ENV
+IFS=' '
+PATH=/usr/sbin:/sbin:/usr/bin:/bin
+SHELL=/bin/sh
+export PATH SHELL
+
+CONF_FILE=named.conf
+INC_FILE=named_inc.conf
+PID_FILE=named.pid
+LOG_FILE=named.log
+
+error () {
+ r=$?
+ echo "Error: $*"
+ exit $r
+}
+
+# Check argument: IP address
+test :"$1" != : || \
+ error "Empty argument 1: IP address !"
+
+# Check argument: Port number
+expr "0$2" + 0 '>' 0 '&' "0$2" + 0 '<' 65536 >/dev/null 2>&1 || \
+ error "Invalid argument 2: port number !"
+
+# Check argument: Work/Zone subdir
+test :"$3" != : || \
+ error "Empty argument 3: Work/Zone subdir!"
+SRCDIR="`dirname "$0"`/$3"
+test -d "$SRCDIR" || \
+ error "Missing zone directory $SRCDIR !"
+test -f "$SRCDIR/$INC_FILE" || \
+ error "Missing file: $SRCDIR/$INC_FILE !"
+
+# Locate named and check version
+NAMED=named
+for n in /usr/sbin/named /usr/sbin/in.named; do
+ test -x "$n" && NAMED="$n"
+done
+NAMED_VER="`"$NAMED" -v 2>&1`" || \
+ error "Name server not found!"
+NAMED_VER=`echo "$NAMED_VER" | ( read V1 V2 V3 IGNORED && \
+ if test :"$V1" = :'in.named'; then
+ echo "$V2 $V3"
+ else
+ echo "$V1 $V2"
+ fi
+)`
+case :"$NAMED_VER" in
+ :'BIND '8.*) NAMED_FG='-f';;
+ :'BIND '9.*) NAMED_FG='-g';;
+ :*) error "Name server version is unknown: $NAMED_VER";;
+esac
+
+# Create working directory and cd to it
+mkdir "$3" >/dev/null 2>&1
+cd "$3" >/dev/null 2>&1 || \
+ error "Can not cd: $3 !"
+
+# Create $CONF_FILE
+cat >"$CONF_FILE" <<-CONF_FILE
+ #
+ # $CONF_FILE for $NAMED_VER
+ # Generated by $0.
+ #
+ # Copyright: see $0.
+ #
+ logging {
+ category default {
+ default_stderr;
+ };
+ };
+ CONF_FILE
+case :"$NAMED_VER" in
+ :'BIND '8.*|:'BIND '9.[012]|:'BIND '9.[012].*)
+ cat >>"$CONF_FILE" <<-CONF_FILE
+ controls {
+ inet 127.0.0.1 port 0 allow { !0/32; };
+ };
+ options {
+ pid-file "$PID_FILE";
+ listen-on port $2 { $1; };
+ recursion no;
+ allow-query { $1; };
+ };
+ CONF_FILE
+ ;;
+ :*)
+ cat >>"$CONF_FILE" <<-CONF_FILE
+ controls {
+ };
+ options {
+ pid-file none;
+ listen-on port $2 { $1; };
+ recursion no;
+ allow-query { $1; };
+ };
+ CONF_FILE
+ ;;
+esac
+cat >>"$CONF_FILE" <<-CONF_FILE
+ include "$INC_FILE";
+ CONF_FILE
+
+# Copy all subdir files
+( cd "$SRCDIR" && ls -1 ) | while read f; do
+ cp -fp "$SRCDIR/$f" .
+done
+
+# Start nameserver
+echo "Cwd: `pwd`"
+echo "Nameserver: $NAMED_VER"
+echo "Port: $2"
+echo "ZoneDir: $3"
+$NAMED $NAMED_FG -c "$CONF_FILE" >"$LOG_FILE" 2>&1 </dev/null &
+NAMED=$!
+trap "kill -TERM $NAMED >/dev/null 2>&1; wait $NAMED >/dev/null 2>&1" \
+ 0 1 2 3 15
+sleep 1 # Give name server time to load its zone files
+echo "Running: Enter \`\`quit'' to terminate nameserver[$NAMED]..."
+while read LINE; do
+ test :"$LINE" = :'quit' && break
+done
+echo "Closing: Terminating nameserver..."