Use cgi instead of static

This commit is contained in:
Daniel Berteaud 2012-04-03 15:24:36 +02:00
parent 5661fa833c
commit a1ab21c4da
6 changed files with 17 additions and 49 deletions

View File

@ -2,7 +2,7 @@
use esmith::Build::CreateLinks qw(:all);
templates2events("/etc/cron.hourly/awstats", qw(webapps-update bootstrap-console-save domain-create domain-modify domain-delete));
templates2events("/usr/share/awstats/wwwroot/index.html", 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-update", "$event", "80");

View File

@ -1,5 +1,5 @@
%define version 0.1.0
%define release 1
%define version 0.1.1
%define release 1.beta0
%define name ipasserelle-stats
@ -31,14 +31,12 @@ Génère des statistique de consultation de vos sites web
%build
perl createlinks
%{__mkdir_p} root/home/e-smith/files/stats/
%install
/bin/rm -rf $RPM_BUILD_ROOT
(cd root ; /usr/bin/find . -depth -print | /bin/cpio -dump $RPM_BUILD_ROOT)
/bin/rm -f %{name}-%{version}-filelist
/sbin/e-smith/genfilelist $RPM_BUILD_ROOT \
--dir /home/e-smith/files/stats/ 'attr(0750,root,www)' \
> %{name}-%{version}-filelist
%files -f %{name}-%{version}-filelist

View File

@ -38,7 +38,7 @@ if (!$vhost){
Description => "Statistiques web",
Nameservers => 'internet',
TemplatePath => 'WebAppVirtualHost',
DocumentRoot => '/home/e-smith/files/stats',
DocumentRoot => '/usr/share/awstats/wwwroot',
LemonLDAP => 'enabled',
Removable => 'yes',
});

View File

@ -1,14 +0,0 @@
{
use esmith::DomainsDB;
my $d = esmith::DomainsDB->open_ro or die "Couldn't open DomainsDB\n";
my $lang = $awstats{'Language'} || 'fr';
$OUT .= 'YEAR=$(date +%Y)'."\n";
foreach my $dom ($d->domains){
my $stats = $dom->prop('Stats') || 'disabled';
next if ($stats ne 'enabled');
my $name = $dom->key;
$OUT .= 'mkdir -p /home/e-smith/files/stats/'."$name".'/$YEAR/'."\n";
$OUT .= "/usr/share/awstats/tools/awstats_buildstaticpages.pl -config=$name -update -lang=$lang -dir=/home/e-smith/files/stats/$name/\$YEAR/ 2>&1 > /dev/null\n\n";
}
}

View File

@ -24,40 +24,13 @@ Alias /awstatsicons "/usr/share/awstats/wwwroot/icon/"
Allow from $allow
</Directory>
<Directory "/usr/share/awstats/wwwroot/cgi-bin">
Deny from all
Options +ExecCGI
SetHandler cgi-script
</Directory>
<IfModule mod_env.c>
SetEnv PERL5LIB /usr/share/awstats/lib:/usr/share/awstats/plugins
</IfModule>
<Directory /home/e-smith/files/stats>
Options None
Options +Indexes
Order deny,allow
Deny from all
Allow from $allow
SSLRequireSSL on
</Directory>
EOF
foreach my $dom ($d->domains){
my $stats = $dom->prop('Stats') || 'disabled';
next unless ($stats eq 'enabled');
my $name = $dom->key;
my @users = split /[;,]/, ($dom->prop('StatsUsers') || '');
foreach my $u (@users){
$OUT .= " SetEnvIf Auth-User \"$u\" allow_$name\n";
}
my $allowfromenv = (scalar @users > 0) ? "allow from env=allow_$name":'';
$OUT .=<<"HERE";
<Directory /home/e-smith/files/stats/$name>
DirectoryIndex awstats.$name.html
$allowfromenv
</Directory>
HERE
}
}
}

View File

@ -0,0 +1,11 @@
{
use esmith::DomainsDB;
my $d = esmith::DomainsDB->open_ro or die "Couldn't open DomainsDB\n";
foreach my $dom ($d->domains){
my $stats = $dom->prop('Stats') || 'disabled';
next unless ($stats eq 'enabled');
my $name = $dom->key;
$OUT .= "<a href=\"https://stats.$DomainName/cgi-bin/awstats.pl?config=$name\">$name</a><p>\n";
HERE
}
}