#!/usr/bin/perl
#-Description-------------------------------------------
# Launch update process for all config files found in a particular directory.
# See COPYING.TXT file about AWStats GNU General Public License.
#-------------------------------------------------------
# Based on awstats_updateall.pl from Laurent Destailleur

my $DIRCONFIG = "/etc/awstats";
my $AWSTATSSCRIPT = "/srv/www/cgi-bin/awstats.pl";

# Scan directory $DIRCONFIG 
opendir(DIR, $DIRCONFIG) || die "Can't scan directory $DIRCONFIG";
my @files = grep { /^awstats\.(.*)conf$/ } sort readdir(DIR);
closedir(DIR);

# Run update process for each config file found
if (@files) {
	foreach (@files) {
		if ($_ =~ /^awstats\.(.*)conf$/) {
			my $domain = $1||"default"; $domain =~ s/\.$//;
			#print "Update domain $domain\n";
			my $output = `"$AWSTATSSCRIPT" -config=$domain -update 2>&1`;
			#print "$output\n";
		}
	}
} 

0;	# Do not remove this line
