dns_add_script
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| dns_add_script [2009/08/18 21:55] – jt | dns_add_script [2020/08/10 02:35] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 2: | Line 2: | ||
| # | # | ||
| ##Jason Thomas | ##Jason Thomas | ||
| + | ##Last Modified 20090819 | ||
| + | |||
| use strict; | use strict; | ||
| use lib '/ | use lib '/ | ||
| Line 10: | Line 12: | ||
| + | ##my $repository = "/ | ||
| my $repository = "/ | my $repository = "/ | ||
| my $dnsData = " | my $dnsData = " | ||
| + | ##currently designed to read from file. however if fqdn is not before fqhn, it will not be able write | ||
| + | ##the entry until db.fqdn is created | ||
| Line 19: | Line 24: | ||
| foreach my $entry (@dnsLine){ | foreach my $entry (@dnsLine){ | ||
| + | |||
| chomp ($entry); | chomp ($entry); | ||
| + | |||
| my ($hostName, $ipAddress) = split(' | my ($hostName, $ipAddress) = split(' | ||
| - | ## if ( !defined($ipAddress) ) {print " | ||
| my ($domainName, | my ($domainName, | ||
| - | my $dbZoneFile = checkZoneExist($domainName, $subDomain, $ipAddress); | + | checkZoneExist($domainName, |
| - | addToZone($dbZoneFile, $subDomain, $ipAddress); | + | |
| } | } | ||
| Line 47: | Line 51: | ||
| return ($hostName, undef); | return ($hostName, undef); | ||
| } | } | ||
| - | + | ||
| else{ | else{ | ||
| Line 55: | Line 59: | ||
| if ( ! defined($subDomain) ){ | if ( ! defined($subDomain) ){ | ||
| + | |||
| $subDomain=$tmp[$counter]; | $subDomain=$tmp[$counter]; | ||
| } | } | ||
| + | |||
| else{ | else{ | ||
| + | |||
| $subDomain=" | $subDomain=" | ||
| } | } | ||
| } | } | ||
| + | |||
| return ($domainName, | return ($domainName, | ||
| } | } | ||
| Line 72: | Line 80: | ||
| my $dbZoneFile = " | my $dbZoneFile = " | ||
| my $userName = " | my $userName = " | ||
| - | my $soa = " | + | my $soa = " |
| if ( -e $repository.$dbZoneFile ){ | if ( -e $repository.$dbZoneFile ){ | ||
| - | ## print "File Exists!" | + | |
| + | ## write subdomain to file if file exists; | ||
| + | addToZone($dbZoneFile, | ||
| + | |||
| } | } | ||
| - | else{ | + | elsif ( (! defined($subDomain)) || $subDomain eq "" |
| + | |||
| my ($tabs) = tabLength($domainName." | my ($tabs) = tabLength($domainName." | ||
| makeZone(" | makeZone(" | ||
| + | |||
| } | } | ||
| - | return $dbZoneFile; | ||
| } | } | ||
| - | |||
| - | |||
| sub makeZone{ | sub makeZone{ | ||
| - | my ($templateSource, | + | my ($templateSource, |
| my $template = Text:: | my $template = Text:: | ||
| my $result = $template-> | my $result = $template-> | ||
| + | |||
| + | if (! defined $result) { | ||
| + | die " | ||
| + | } | ||
| open(DBFILE, | open(DBFILE, | ||
| Line 115: | Line 129: | ||
| else { | else { | ||
| + | |||
| my ($tabs) = tabLength($subDomain); | my ($tabs) = tabLength($subDomain); | ||
| open(DBFILE, | open(DBFILE, | ||
| print DBFILE " | print DBFILE " | ||
| close (DBFILE); | close (DBFILE); | ||
| + | |||
| } | } | ||
| } | } | ||
| Line 132: | Line 148: | ||
| return $tabs; | return $tabs; | ||
| } | } | ||
| + | |||
| ########################################################################### | ########################################################################### | ||
| Line 148: | Line 165: | ||
| exit(0); | exit(0); | ||
| } | } | ||
| - | + | ||
| </ | </ | ||
dns_add_script.1250632555.txt.gz · Last modified: 2020/08/10 02:28 (external edit)
