You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.2 KiB

#!/usr/bin/perl -w
use esmith::DomainsDB;
use File::Path qw/rmtree/;
my $event = $ARGV [0];
my $domain = $ARGV [1];
use esmith::DomainsDB;
my $d = esmith::DomainsDB->open_ro or die "Couldn't open DomainsDB\n";
die "Event name missing\n" unless defined ($event);
my @domains = ();
if (defined $domain){
@domains = $d->get($domain);
}
else{
@domains = ($d->domains);
}
foreach my $dom (@domains){
my $name = $dom->key;
if (($event eq 'domain-delete') ){
rmtree "/home/e-smith/files/stats/$name";
unlink <"/etc/awstats/$awstats.$domain.conf">;
}
else{
my $stats = $dom->prop('Stats') || 'disabled';
if ($stats eq 'enabled'){
mkdir "/home/e-smith/files/stats/$name", 0755 if (!-d "/home/e-smith/files/stats/$name");
processTemplate({
TEMPLATE_PATH => "/etc/awstats/domain.conf",
MORE_DATA => {DOMAIN=>$name},
OUTPUT_FILENAME => "/etc/awstats/awstats.$name.conf",
});
}
elsif (($stats ne 'enabled') && (-d "/home/e-smith/files/stats/$name")){
rmtree "/home/e-smith/files/stats/$name";
}
}
}
exit (0);