The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

new account and Name Server

Discussion in 'General Discussion' started by mautik, Sep 7, 2004.

  1. mautik

    mautik Registered

    Joined:
    Sep 4, 2004
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    When i create a new account ( mydomain.com) i need restart the name server manually to propagate the new account.

    What i need change in the server to restart the DNS server atomatically when i create a new account?
    :confused:
     
  2. sawbuck

    sawbuck Well-Known Member

    Joined:
    Jan 18, 2004
    Messages:
    1,367
    Likes Received:
    5
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    When you add a new domain the zone file is automatically added to your named.conf file.
     
  3. linux-image

    linux-image Well-Known Member

    Joined:
    Jun 8, 2004
    Messages:
    1,192
    Likes Received:
    1
    Trophy Points:
    38
    Location:
    India
    cPanel Access Level:
    Root Administrator
    and the rndc gets reloaded. in case it is not; please check the script /scripts/adddns to see if rndc reload is still there .
     
  4. mautik

    mautik Registered

    Joined:
    Sep 4, 2004
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    This is the script/adddns in my server:

    #!/usr/bin/perl
    # cpanel8 - scripts Copyright(c) 1997-2003 cPanel, Inc.
    # All rights Reserved.
    # nick@darkorb.net http://cpanel.net
    # This code is subject to the cpanel license. Unauthorized copying is prohibited

    BEGIN {
    push(@INC,"/scripts");
    }

    use POSIX;
    use RcsRecord qw(rcsrecord);

    print "Add Dns 1.0 ... \n";
    print "Warning, this only adds dns to the local server ... \n";
    print "If this server is not the dns master, this will not work\n";


    if (-e "/usr/sbin/named-checkconf") {
    $checkconf = `/usr/sbin/named-checkconf`;
    if ($checkconf =~ /error/) {
    print "Cannot continue... named.conf is corrupt\n";
    print "[$checkconf]\n";
    exit;
    }
    }


    $ndomain = $ARGV[0];
    $ip = $ARGV[1];

    die if (! -t STDIN) && ($ip eq "" || $ndomain eq "");

    open(CONF,"/etc/wwwacct.conf") || die "/etc/wwwacct.conf not found\n";
    while(<CONF>) {
    $_ =~ s/\n//g;
    if ($_ !~ /^;/) {
    if(/^NS (\S+)$/) {
    $nameserver = $1;
    }
    if(/^NS2 (\S+)$/) {
    $nameserver2 = $1;
    }
    if (/^CONTACTEMAIL/) {
    (undef,$contactemail) = split(/ /, $_);
    }
    }
    }
    close(CONF);


    if ($contactemail eq "") {
    my($hostname);
    chomp($hostname = `hostname`);
    $contactemail = 'root@' . $hostname;
    }

    my $rpemail = $contactemail;

    $rpemail =~ s/\,.*$//g;
    $rpemail =~ s/\;.*$//g;
    $rpemail =~ s/\s|\n//g;

    $rpemail =~ s/\@/\./g;



    if ($nameserver eq "" || $nameserver2 eq "") { die "Can't figure out your nameservers, your /etc/wwwacct.conf is
    incomplete. Please fill in values for NS and NS2"; }

    if ($ip eq "") {
    print "Enter ip? ";
    chomp($ip = <STDIN>);
    }
    if ($ndomain eq "") {
    print "Enter the new domain? ";
    chomp($ndomain = <STDIN>);
    }

    $exists = 0;
    open(NDC,"/etc/named.conf");
    while(<NDC>) {
    if (/zone\s+\"$ndomain\"/i) {
    $exists = 1;
    last;
    }
    }
    close(NDC);

    if (!$exists) {
    open(NCD,">>/etc/named.conf");
    print NCD <<EOM;

    zone "$ndomain" {
    type master;
    file "/var/named/$ndomain.db";
    };
    EOM
    close(NCD);
    }


    $time = time();
    my $sr = getnewsrnum(0);
    open(ZONE,">/var/named/$ndomain.db") || die "Can't open zone file";
    print ZONE<<EOM;
    @ IN SOA $nameserver. ${rpemail}. (
    ${sr} ; serial, todays date+todays serial #
    28800 ; refresh, seconds
    7200 ; retry, seconds
    3600000 ; expire, seconds
    86400 ) ; minimum, seconds

    $ndomain. IN NS $nameserver.
    $ndomain. IN NS $nameserver2.
    $ndomain. IN A $ip

    localhost.$ndomain. IN A 127.0.0.1

    $ndomain. IN MX 0 $ndomain.

    mail IN CNAME $ndomain.
    www IN CNAME $ndomain.
    ftp IN CNAME $ndomain.
    EOM
    close(ZONE);
    system("/usr/sbin/ndc reload");
    print "Setup $ndomain OK\n";
    rcsrecord("/etc/named.conf");



    sub getnewsrnum {
    my($sr) = @_;
    my $todaytime = POSIX::strftime("%Y%m%d", localtime(time()));
    if ($sr =~ /^${todaytime}/) {
    $sr++;
    } else {
    $sr = "${todaytime}00";
    }
    return($sr);
    }
     
  5. linux-image

    linux-image Well-Known Member

    Joined:
    Jun 8, 2004
    Messages:
    1,192
    Likes Received:
    1
    Trophy Points:
    38
    Location:
    India
    cPanel Access Level:
    Root Administrator
    i dont see a problem out there. maybe tht your wwwaccreate has a problem.
     
Loading...

Share This Page