4 use POSIX qw(strftime);
6 require("/usr/share/gforge/lib/include.pl"); # Include all the predefined functions
10 @dns_zone = open_array_file($file_dir."/bind/dns.head");
13 # Update the Serial Number
15 $date_line = $dns_zone[6];
17 $date_line =~ s/\t\t\t/\t/;
19 ($blah,$date_str,$comments) = split(" ", $date_line);
23 $serial = substr($date, 8, 2);
24 $old_day = substr($date, 6, 2);
28 $now_string = strftime "%Y%m%d", localtime;
29 $new_day = substr($now_string, 6, 2);
31 if ($old_day != $new_day) { $serial = "01"; }
33 $new_serial = $now_string.$serial;
35 $dns_zone[6] = " $blah $new_serial $comments";
37 write_array_file($file_dir."/bind/dns.head", @dns_zone);
40 # grab Table information
42 my $query = "SELECT http_domain,unix_group_name,group_name,unix_box FROM groups WHERE http_domain LIKE '%.%' AND status = 'A'";
43 my $c = $dbh->prepare($query);
46 while(my ($http_domain,$unix_group_name,$group_name,$unix_box) = $c->fetchrow()) {
48 ($name, $aliases, $addrtype, $length, @addrs) = gethostbyname("$unix_box".".".$sys_default_domain );
49 @blah = unpack('C4', $addrs[0]);
50 $ip = join(".", @blah);
53 push @dns_zone, sprintf("%-24s%-16s",$unix_group_name,"IN\tA\t" . "$ip\n");
54 # Does not work with bind9 or bad syntax ???
55 #push @dns_zone, sprintf("%-24s%-28s","", "IN\tMX\t" . "mail." . $sys_default_domain . ".\n");
56 push @dns_zone, sprintf("%-24s%-20s","cvs.".$unix_group_name,"IN\tCNAME\t".$sys_scm_host.".\n\n");
58 push @dns_zone, sprintf("; Could not get ip for %s","$unix_box".".".$sys_default_domain."\n");
62 write_array_file($file_dir."/bind/dns.zone", @dns_zone);