aboutsummaryrefslogtreecommitdiffstats
path: root/tools/make-first-zones.pl
blob: 1227129a3e6b0c4aa0c2b2ac107aaac1309c3aca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/usr/bin/perl -I /root/tgmanage
use strict;

use Net::IP;

BEGIN {
        require "include/config.pm";
        eval {
                require "include/config.local.pm";
        };
}

my $base = "/etc";
$base = $ARGV[0] if $#ARGV > -1;
$base .= "/" if not $base =~ m/\/$/ and not $base eq "";

my $tgname    = $nms::config::tgname;
my $pri_a     = $nms::config::pri_a;
my $pri_ptr   = $nms::config::pri_ptr;
my $pri_v6    = $nms::config::pri_v6;
my $sec_a     = $nms::config::sec_a;
my $sec_ptr   = $nms::config::sec_ptr;
my $sec_v6    = $nms::config::sec_v6;
my $ipv6zone = $nms::config::ipv6zone;

# FIXME: THIS IS NOT APPRORPIATE!
my $serial = `date +%Y%m%d01`;
chomp $serial;
# FIXME

my $zonefile;

$zonefile = $base . "bind/" . $tgname . ".gathering.org.zone";
if ( not -f  $zonefile )
{
	print $zonefile . "\n";
	open MAINZONE, ">" . $zonefile or die $! . " " . $zonefile;

	print MAINZONE <<"EOF";
\$TTL 3600
@	IN	SOA	$pri_a.$tgname.gathering.org.	abuse.gathering.org. (
			$serial; serial
			3600 ; refresh 
			1800 ; retry
			608400 ; expire
			3600 ) ; minimum and default TTL

		IN	NS	ns1.$tgname.gathering.org.
		IN	NS	ns2.$tgname.gathering.org.

ns1		IN	A	$pri_ptr
ns1		IN	AAAA	$pri_v6
ns2		IN	A	$sec_ptr
ns2		IN	AAAA	$sec_v6
$pri_a		IN	A	$pri_ptr
$pri_a		IN	AAAA	$pri_v6
$sec_a		IN	A	$sec_ptr
$sec_a		IN	AAAA	$sec_v6

; Generated by make-all-config.sh on the bootstrapping/nms server.
; Will not be overwritten unless it is missing ;)

EOF
	close MAINZONE;
}
else { print "Skipped TG-zone, file exists.\n"; }

$zonefile = $base . "bind/infra." . $tgname . ".gathering.org.zone";
if ( not -f  $zonefile )
{
	print $zonefile . "\n";
	open MAINZONE, ">" . $zonefile or die $! . " " . $zonefile;

	print MAINZONE <<"EOF";
\$TTL 3600
@	IN	SOA	$pri_a.$tgname.gathering.org.	abuse.gathering.org. (
			$serial; serial
			3600 ; refresh 
			1800 ; retry
			608400 ; expire
			3600 ) ; minimum and default TTL

		IN	NS	$pri_a.$tgname.gathering.org.
		IN	NS	$sec_a.$tgname.gathering.org.

; Generated by make-all-config.sh on the bootstrapping/nms server.
; Will not be overwritten unless it is missing ;)
EOF
	close MAINZONE;
}
else { print "Skipped infra-zone, file exists.\n"; }

$zonefile = $base . "bind/" . $ipv6zone . ".zone";
if ( not -f  $zonefile )
{
	print $zonefile . "\n";
	open IPV6ZONE, ">" . $zonefile or die $! . " " . $zonefile;

	print IPV6ZONE <<"EOF";
; autogenerated, and updated from dhcpd -- DO NOT TOUCH!
\$TTL 3600
@       IN      SOA     ns1.$tgname.gathering.org. abuse.gathering.org. (
			$serial; serial
                        3600 ; refresh
                        1800 ; retry
                        608400 ; expire
                        3600 ) ; minimum and default TTL

                IN      NS      ns1.$tgname.gathering.org.
                IN      NS      ns2.$tgname.gathering.org.

; WARNING! Do not edit this file directly!
; on the bootstrapping/nms server!

EOF
	my $ip_pri = new Net::IP( $pri_v6 ) or die ( "Error, new Net::IP for " . $pri_v6 );
	my $ip_sec = new Net::IP( $sec_v6 ) or die ( "Error, new Net::IP for " . $sec_v6 );
	print IPV6ZONE $ip_pri->reverse_ip() . " IN PTR ns1.$tgname.gathering.org.\n";
	print IPV6ZONE $ip_pri->reverse_ip() . " IN PTR $pri_a.$tgname.gathering.org.\n";
	print IPV6ZONE $ip_sec->reverse_ip() . " IN PTR ns2.$tgname.gathering.org.\n";
	print IPV6ZONE $ip_sec->reverse_ip() . " IN PTR $sec_a.$tgname.gathering.org.\n";
	close IPV6ZONE;
}
else { print "Skipped v6-reverse-zone, file exists.\n"; }