From ff3dce9dd74e34c2230ab26930a38e73ed2fbe03 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Thu, 29 Mar 2012 13:04:33 +0200 Subject: [PATCH] tempaltes for awstats conf --- createlinks | 2 +- .../events/actions/{awstats-dir => awstats-update} | 10 ++++++++-- .../e-smith/templates/etc/awstats/domain.conf/000Setup | 17 +++++++++++++++++ .../e-smith/templates/etc/awstats/domain.conf/010Log | 4 ++++ .../templates/etc/awstats/domain.conf/020DomainName | 2 ++ .../e-smith/templates/etc/awstats/domain.conf/030Dir | 3 +++ .../etc/e-smith/templates/etc/cron.hourly/awstats/10All | 2 +- 7 files changed, 36 insertions(+), 4 deletions(-) rename root/etc/e-smith/events/actions/{awstats-dir => awstats-update} (64%) create mode 100644 root/etc/e-smith/templates/etc/awstats/domain.conf/000Setup create mode 100644 root/etc/e-smith/templates/etc/awstats/domain.conf/010Log create mode 100644 root/etc/e-smith/templates/etc/awstats/domain.conf/020DomainName create mode 100644 root/etc/e-smith/templates/etc/awstats/domain.conf/030Dir diff --git a/createlinks b/createlinks index 2be8f8a..3ee8ff5 100644 --- a/createlinks +++ b/createlinks @@ -5,7 +5,7 @@ use esmith::Build::CreateLinks qw(:all); templates2events("/etc/cron.hourly/awstats", qw(webapps-update bootstrap-console-save domain-create domain-modify domain-delete)); foreach my $event (qw/webapps-update bootstrap-console-save domain-create domain-modify domain-delete/){ - event_link("awstats-dir", "$event", "80"); + event_link("awstats-update", "$event", "80"); } foreach my $event (qw/ipasserelle-update bootstrap-console-save webapps-update/){ event_link("awstats-init-domain", "$event", "80"); diff --git a/root/etc/e-smith/events/actions/awstats-dir b/root/etc/e-smith/events/actions/awstats-update similarity index 64% rename from root/etc/e-smith/events/actions/awstats-dir rename to root/etc/e-smith/events/actions/awstats-update index baa3d39..b79606e 100644 --- a/root/etc/e-smith/events/actions/awstats-dir +++ b/root/etc/e-smith/events/actions/awstats-update @@ -22,11 +22,17 @@ 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') && (!-d "/home/e-smith/files/stats/$name")){ - mkdir "/home/e-smith/files/stats/$name", 0755; + 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"; diff --git a/root/etc/e-smith/templates/etc/awstats/domain.conf/000Setup b/root/etc/e-smith/templates/etc/awstats/domain.conf/000Setup new file mode 100644 index 0000000..dabe585 --- /dev/null +++ b/root/etc/e-smith/templates/etc/awstats/domain.conf/000Setup @@ -0,0 +1,17 @@ +{ + +use esmith::HostsDB; +use esmith::DomainsDB; +my $hdb = esmith::HostsDB->open_ro(); +my %domains = map { $_->key => 1 } esmith::DomainsDB->open_ro->domains; + +$domain = $DOMAIN; +my @hosts = grep { + my $h = $_; + ($h->prop('HostType') eq 'Self') && !$domains{$h->key} + } $hdb->get_hosts_by_domain($domain); +$alias = join " ", map { $_->key } @hosts; + +$OUT .= ''; +} + diff --git a/root/etc/e-smith/templates/etc/awstats/domain.conf/010Log b/root/etc/e-smith/templates/etc/awstats/domain.conf/010Log new file mode 100644 index 0000000..e18619b --- /dev/null +++ b/root/etc/e-smith/templates/etc/awstats/domain.conf/010Log @@ -0,0 +1,4 @@ +LogFile="/var/log/httpd/access_log" +LogType=W +LogFormat=1 +LogSeparator=" " diff --git a/root/etc/e-smith/templates/etc/awstats/domain.conf/020DomainName b/root/etc/e-smith/templates/etc/awstats/domain.conf/020DomainName new file mode 100644 index 0000000..5930403 --- /dev/null +++ b/root/etc/e-smith/templates/etc/awstats/domain.conf/020DomainName @@ -0,0 +1,2 @@ +SiteDomain="{$domain}" +HostAliases="{$alias}" diff --git a/root/etc/e-smith/templates/etc/awstats/domain.conf/030Dir b/root/etc/e-smith/templates/etc/awstats/domain.conf/030Dir new file mode 100644 index 0000000..8d6dbc0 --- /dev/null +++ b/root/etc/e-smith/templates/etc/awstats/domain.conf/030Dir @@ -0,0 +1,3 @@ +DirData="/var/lib/awstats" +DirCgi="/awstats" +DirIcons="/awstatsicons" diff --git a/root/etc/e-smith/templates/etc/cron.hourly/awstats/10All b/root/etc/e-smith/templates/etc/cron.hourly/awstats/10All index f71966e..5efd2e0 100644 --- a/root/etc/e-smith/templates/etc/cron.hourly/awstats/10All +++ b/root/etc/e-smith/templates/etc/cron.hourly/awstats/10All @@ -7,6 +7,6 @@ foreach my $dom ($d->domains){ next if ($stats ne 'enabled'); my $name = $dom->key; my $lang = $awstats{'Language'} || 'fr'; - $OUT .= "/usr/share/awstats/tools/awstats_buildstaticpages.pl -config=$name -update -lang=$lang -dir=/var/lib/stats/$name\n"; + $OUT .= "/usr/share/awstats/tools/awstats_buildstaticpages.pl -config=$name -update -lang=$lang -dir=/home/e-smith/files/stats/$name\n"; } }