1#!/bin/sh
2
3# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
4#
5# SPDX-License-Identifier: MPL-2.0
6#
7# This Source Code Form is subject to the terms of the Mozilla Public
8# License, v. 2.0.  If a copy of the MPL was not distributed with this
9# file, you can obtain one at https://mozilla.org/MPL/2.0/.
10#
11# See the COPYRIGHT file distributed with this work for additional
12# information regarding copyright ownership.
13
14usage () {
15    echo "Usage: $0 [-s] <number of zones> [<records per zone>]"
16    echo "       -s: use the same zone file all zones"
17    exit 1
18}
19
20if [ "$#" -lt 1 -o "$#" -gt 3 ]; then
21    usage
22fi
23
24single_file=""
25if [ $1 = "-s" ]; then
26    single_file=yes
27    shift
28fi
29
30nzones=$1
31shift
32
33nrecords=5
34[ "$#" -eq 1 ] && nrecords=$1
35
36. ../system/conf.sh
37
38cat << EOF
39options {
40        directory "`pwd`";
41        listen-on { localhost; };
42        listen-on-v6 { localhost; };
43	port 5300;
44        allow-query { any; };
45        allow-transfer { localhost; };
46        allow-recursion { none; };
47        recursion no;
48};
49
50key rndc_key {
51        secret "1234abcd8765";
52        algorithm hmac-md5;
53};
54
55controls {
56        inet 127.0.0.1 port 9953 allow { any; } keys { rndc_key; };
57};
58
59logging {
60        channel basic {
61                file "`pwd`/named.log" versions 3 size 100m;
62                severity info;
63                print-time yes;
64                print-severity no;
65                print-category no;
66        };
67        category default {
68                basic;
69        };
70};
71
72EOF
73
74$PERL makenames.pl $nzones | while read zonename; do
75    if [ $single_file ]; then
76        echo "zone $zonename { type master; file \"smallzone.db\"; };"
77    else
78        [ -d zones ] || mkdir zones
79        $PERL mkzonefile.pl $zonename $nrecords > zones/$zonename.db
80        echo "zone $zonename { type master; file \"zones/$zonename.db\"; };"
81    fi
82done
83