Initial commit

tags/0.0.1 0.0.1
Daniel Berteaud 13 years ago
commit 57e28e0efc
  1. 9
      createlinks
  2. 53
      ipasserelle-stats.spec
  3. 1
      root/etc/e-smith/db/configuration/defaults/awstats/access
  4. 1
      root/etc/e-smith/db/configuration/defaults/awstats/status
  5. 1
      root/etc/e-smith/db/configuration/defaults/awstats/type
  6. 37
      root/etc/e-smith/events/actions/awstats-dir
  7. 50
      root/etc/e-smith/events/actions/awstats-init-domain
  8. 12
      root/etc/e-smith/templates/etc/cron.hourly/awstats/10All
  9. 63
      root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/98awstats
  10. 28
      root/etc/e-smith/templates/var/lib/lemonldap-ng/conf/lmConf/070awstats

@ -0,0 +1,9 @@
#!/usr/bin/perl -w
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");
}

@ -0,0 +1,53 @@
%define version 0.0.1
%define release 1.beta0
%define name ipasserelle-stats
Summary: Statistiques web
Name: %{name}
Version: %{version}
Release: %{release}%{?dist}
License: GPL
Group: Networking/Daemons
Source: %{name}-%{version}.tar.gz
BuildRoot: /var/tmp/%{name}-%{version}-%{release}-buildroot
BuildArchitectures: noarch
BuildRequires: e-smith-devtools
Requires: ipasserelle-base
Requires: awstats
%description
Génère des statistique de consultation de vos sites web
%changelog
* Tue Mar 27 2012 Daniel Berteaud <daniel@firewall-services.com> 0.0.1-1.sme
- initial release
%prep
%setup -q -n %{name}-%{version}
%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
%defattr(-,root,root)
%clean
rm -rf $RPM_BUILD_ROOT
%post
%preun

@ -0,0 +1,37 @@
#!/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{
@doains = ($d->domains);
}
foreach my $dom (@domains){
my $name = $dom->key;
if (($event eq 'domain-delete') ){
rmtree "/home/e-smith/files/stats/$domain";
}
else{
my $stats = $dom->prop('Stats') || 'disabled';
if (($stats eq 'enabled') && (!-d "/home/e-smith/files/stats/$domain")){
mkdir "/home/e-smith/files/stats/$domain", 0755;
}
elsif (($stats ne 'enabled') && (-d "/home/e-smith/files/stats/$domain")){
rmtree "/home/e-smith/files/stats/$domain";
}
}
}
exit (0);

@ -0,0 +1,50 @@
#!/usr/bin/perl -w
#----------------------------------------------------------------------
# copyright (C) 2012 Firewall-Services
# daniel@firewall-services.com
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#----------------------------------------------------------------------
use strict;
use warnings;
use esmith::DomainsDB;
use esmith::ConfigDB;
my $d = esmith::DomainsDB->open or die "Couldn't open DomainsDB\n";
my $c = esmith::ConfigDB->open_ro() or die "Couldn't open ConfigDB\n";
my $domain = $c->get('DomainName')->value;
my $vhost;
$vhost = $d->get("stats.$domain");
if (!$vhost){
$d->new_record("stats.$domain",{
type => 'domain',
Content => 'Primary',
Description => "Statistiques web",
Nameservers => 'internet',
TemplatePath => 'WebAppVirtualHost',
DocumentRoot => '/home/e-smith/files/stats',
LemonLDAP => 'enabled',
Removable => 'yes',
});
unless ( system("/sbin/e-smith/signal-event", "domain-create", "stats.$domain") == 0 ){
die "Failed to create domain stats.$domain\n";
}
}

@ -0,0 +1,12 @@
{
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 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";
}
}

@ -0,0 +1,63 @@
{
use esmith::DomainsDB;
my $d = esmith::DomainsDB->open_ro or die "Couldn't open DomainsDB\n";
my $status = $awstats{'status'} || 'disabled';
my $access = $awstats{'access'} || 'private';
if ($status ne 'enabled'){
$OUT .= "# AWStats is disabled\n";
}
else{
my $allow = ($status eq 'public') ? 'all':"$localAccess $externalSSLAccess";
$OUT .=<<"EOF";
Alias /awstatsclasses "/usr/share/awstats/wwwroot/classes/"
Alias /awstatscss "/usr/share/awstats/wwwroot/css/"
Alias /awstatsicons "/usr/share/awstats/wwwroot/icon/"
<Directory "/usr/share/awstats/wwwroot">
Options None
AllowOverride None
Order deny,allow
Deny from all
Allow from $allow
</Directory>
<Directory "/usr/share/awstats/wwwroot/cgi-bin">
Deny from all
</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>
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
}
EOF
}
}

@ -0,0 +1,28 @@
{
$conf->{'exportedHeaders'}->{"stats.$domain"} = {
'Auth-User' => '$uid',
} unless ($conf->{'exportedHeaders'}->{"stats.$domain"});
$conf->{'locationRules'}->{"stats.$domain"} = {
'default' => '$groups =~ /\\badmins\\b/',
} unless ($conf->{'locationRules'}->{"stats.$domain"});
$conf->{'applicationList'}->{'030admin'}->{'awstats'} = {
'options' => {
'logo' => 'network.png',
'name' => 'Statistiques web',
'description' => 'AWStats',
'uri' => "https://stats.$domain",
'display' => 'auto'
},
'type' => 'application'
} unless ($conf->{'applicationList'}->{'030admin'}->{'awstats'});
$OUT = '';
}
Loading…
Cancel
Save