From: khoff Date: Sat, 9 Mar 2002 10:19:38 +0000 (+0000) Subject: Support for default CNAME/A records X-Git-Tag: freeside_1_4_0_pre12~155 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=56ef0a8a658b8449d1125fe017b21e0c636a8b0c Support for default CNAME/A records --- diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index e8686b575..5dba387fe 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -450,6 +450,20 @@ httemplate/docs/config.html }, { + 'key' => 'arecords', + 'section' => 'BIND', + 'description' => 'A list of tab seperated A records to add automatically when creating a domain', + 'type' => 'textarea', + }, + + { + 'key' => 'cnamerecords', + 'section' => 'BIND', + 'description' => 'A list of tab seperated CNAME records to add automatically when creating a domain', + 'type' => 'textarea', + }, + + { 'key' => 'nismachines', 'section' => 'shell', 'description' => 'Your NIS master (not slave master) machines, one per line. This enables export of `/etc/global/passwd\' and `/etc/global/shadow\'.', diff --git a/FS/FS/svc_domain.pm b/FS/FS/svc_domain.pm index 84a102911..1e16ba87f 100644 --- a/FS/FS/svc_domain.pm +++ b/FS/FS/svc_domain.pm @@ -3,7 +3,7 @@ package FS::svc_domain; use strict; use vars qw( @ISA $whois_hack $conf $smtpmachine @mxmachines @nsmachines $soadefaultttl $soaemail $soaexpire $soamachine - $soarefresh $soaretry $qshellmachine $nossh_hack + $soarefresh $soaretry $qshellmachine $nossh_hack %arecords %cnamerecords ); use Carp; use Mail::Internet; @@ -29,6 +29,8 @@ $FS::UID::callback{'FS::domain'} = sub { $smtpmachine = $conf->config('smtpmachine'); + %arecords = map { split /\t/ } $conf->config('arecords'); + %cnamerecords = map { split /\t/ } $conf->config('cnamerecords'); @mxmachines = $conf->config('mxmachines'); @nsmachines = $conf->config('nsmachines'); $soadefaultttl = $conf->config('soadefaultttl'); @@ -123,6 +125,10 @@ records are added to the domain_record table (see L). If any machines are defined in the I configuration file, MX records are added to the domain_record table (see L). +If the I configuration file exits, A records are added to the +domain_record table. The I file does the same thing for +CNAME records. + If a machine is defined in the I configuration value, the I configuration file exists, and the I field points to an an account with a home directory (see L), the command: @@ -224,6 +230,36 @@ sub insert { } } + foreach my $arecord ( keys %arecords ) { + my $arec = new FS::domain_record { + 'svcnum' => $self->svcnum, + 'reczone' => $arecord, + 'recaf' => 'IN', + 'rectype' => 'A', + 'recdata' => $arecords{$arecord}, + }; + my $error = $arec->insert; + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return "WARNING: couldn't insert A record for new domain: $error"; + } + } + + foreach my $cnamerecord ( keys %cnamerecords ) { + my $cnamerec = new FS::domain_record { + 'svcnum' => $self->svcnum, + 'reczone' => $cnamerecord, + 'recaf' => 'IN', + 'rectype' => 'CNAME', + 'recdata' => $cnamerecords{$cnamerecord}, + }; + my $error = $cnamerec->insert; + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return "WARNING: couldn't insert CNAME record for new domain: $error"; + } + } + } $dbh->commit or die $dbh->errstr if $oldAutoCommit; @@ -424,7 +460,7 @@ sub submit_internic { =head1 VERSION -$Id: svc_domain.pm,v 1.24 2002-02-20 01:03:09 ivan Exp $ +$Id: svc_domain.pm,v 1.25 2002-03-09 10:19:38 khoff Exp $ =head1 BUGS