File: //scripts.20110531.215904.25158/mkwwwacctconf
#!/usr/bin/perl
# cpanel - mkwwwacctconf Copyright(c) 2010 cPanel, Inc.
# All rights Reserved.
# copyright@cpanel.net http://cpanel.net
# This code is subject to the cpanel license. Unauthorized copying is prohibited
BEGIN { unshift @INC, '/usr/local/cpanel'; }
use strict;
use Cpanel::Config ();
use Cpanel::DIp ();
use Cpanel::OSSys ();
use Cpanel::Hostname ();
my $reset = @ARGV && grep( /^--(?:reset|force)$/, @ARGV ) ? 1 : 0;
my $wwwacctconf = '/etc/wwwacct.conf';
# Don't clobber a valid config
if ( !$reset && -e $wwwacctconf ) {
my %conf = Cpanel::Config::loadwwwacctconf();
exit if ( $conf{'DEFMOD'} || $conf{'NS'} || $conf{'HOST'} ); # Check to see if some common settings are configured
}
my $system = Cpanel::OSSys::get_system();
my $hostname = Cpanel::Hostname::gethostname();
my $sharedip = Cpanel::DIp::getmainserverip();
# Sanity check
if ( !$system ) {
die 'Unable to determine OS.';
}
if ( !$sharedip ) {
die 'Unable to determine main shared IP.';
}
# default home directory
my $homedir = '/home';
if ( $system eq 'freebsd' ) {
$homedir = '/usr/home';
}
# default nameserver entries
my @hostnameparts = split /[.]/, $hostname;
shift @hostnameparts;
my $hostnamedomain = join '.', @hostnameparts;
my $ns = 'ns1.' . $hostnamedomain;
my $ns2 = 'ns2.' . $hostnamedomain;
my %conf = (
'ADDR' => $sharedip,
'CONTACTEMAIL' => '',
'CONTACTPAGER' => '',
'DEFMOD' => 'x3',
'ETHDEV' => '',
'HOMEDIR' => $homedir,
'HOMEMATCH' => 'home',
'LOGSTYLE' => 'combined',
'MINUID' => '',
'NS3' => '',
'NS4' => '',
'NSTTL' => '86400',
'SCRIPTALIAS' => 'y',
'TTL' => '14400',
'HOST' => ( ( $hostname && $hostname =~ m/\./ ) ? $hostname : '' ),
'NS' => ( ( $hostname && $hostname =~ m/\./ ) ? $ns : '' ), # Check the hostname because $ns is built from it
'NS2' => ( ( $hostname && $hostname =~ m/\./ ) ? $ns2 : '' ), # Check the hostname because $ns2 is built from it
);
Cpanel::Config::savewwwacctconf( \%conf );