#!/usr/bin/perl -w use esmith::DomainsDB; use esmith::templates; 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,$d->get_all_by_prop(type=>'vhost')); } 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);