[users] sarg should be updated (current version is 2.2 !!!)

Bernard Lheureux bernard.lheureux at bbsoft4.org
Tue May 23 20:59:13 CEST 2006


Dag, or Dries, 

Here are 2 specfiles I have make for sarg 2.1 and 2.2, as Arrfab told
you lately, Dag, I've already built them and used for some of our
customers with success...



 
 M$-Internet Exploder est le cancer de l'Internet, voyez pourquoi ici :
 http://www.aful.org/publi/articles/msie_et_la_securite/index_html/view
 -----------------> http://www.shlomifish.org/no-ie/ <-----------------

--
(°-   Bernard Lheureux Gestionnaire des MailingLists ML, TechML, LinuxML
//\   http://www.bbsoft4.org/Mailinglists.htm ** MailTo:root at bbsoft4.org
v_/_  http://www.bbsoft4.org/ <<<<<< * >>>>>> http://www.portalinux.org/
-------------- next part --------------
%define sarg_ver      2.2
%define sysconfdir    /etc/sarg
%define bindir        /usr/bin
%define mandir        /usr/share/man/man1
%define htmloutputdir %{_localstatedir}/www/sarg
%define debug_package %{nil}

Summary: Squid usage report generator per user/ip/name
Name: sarg
Version: %{sarg_ver}
Release: 1
License: GPL
Group: Applications/Network
URL: http://sarg.sf.net/sarg.php

Source0: http://dl.sf.net/sarg/sarg-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}

BuildRequires: perl, gd-devel
Requires: bash, coreutils, squid, gzip, gd >= 1.8
Obsoletes: sqrmgrlog

%description
Squid Analysis Report Generator is a tool that allows you to view "where"
your users are going to on the Internet. Sarg generate reports in html
showing users, IP Addresses, bytes, sites and times.


%prep
%setup -q -n %{name}-%{sarg_ver}

# Fix dir permissions
chmod 755 sarg-php/locale

%{__perl} -pi.orig -e '
                s|^#(access_log) (.+)$|#$1 $2\n$1 %{_localstatedir}/log/squid/access.log|;
                s|^#(output_dir) (.+)$|#$1 $2\n$1 %{htmloutputdir}/ONE-SHOT|;
                s|^#(resolve_ip) (.+)$|#$1 $2\n$1 yes|;
                s|^#(show_successful_message) (.+)$|#$1 $2\n$1 no|;
                s|^#(mail_utility) (.+)$|#$1 $2\n$1 mail|;
                s|^#(external_css_file) (.+)$|#$1 $2\n$1 %{htmloutputdir}/sarg.css|;
		
        ' sarg.conf


%{__cat} <<'EOF' >sarg.daily
#!/bin/bash
exec %{_bindir}/sarg \
          -o %{htmloutputdir}/daily \
          -d "$(date --date "1 day ago" +%d/%m/%Y)"  > /dev/null 2>&1

exit 0
EOF


%{__cat} <<'EOF' >sarg.weekly
#!/bin/bash
LOG_FILES=
if [[ -s %{_localstatedir}/log/squid/access.log.1.gz ]]; then
    LOG_FILES="$LOG_FILES -l %{_localstatedir}/log/squid/access.log.1.gz"
fi
if [[ -s %{_localstatedir}/log/squid/access.log ]]; then
    LOG_FILES="$LOG_FILES -l %{_localstatedir}/log/squid/access.log"
fi

# Get yesterday's date
YESTERDAY=$(date --date "1 days ago" +%d/%m/%Y)

# Get one week ago date
WEEKAGO=$(date --date "7 days ago" +%d/%m/%Y)

exec %{_bindir}/sarg \
	$LOG_FILES \
        -o %{htmloutputdir}/weekly \
	-d $WEEKAGO-$YESTERDAY > /dev/null 2>&1

exit 0
EOF


%{__cat} <<'EOF' >sarg.monthly
#!/bin/bash
LOG_FILES=
if [[ -s %{_localstatedir}/log/squid/access.log.4.gz ]]; then
    LOG_FILES="$LOG_FILES -l %{_localstatedir}/log/squid/access.log.4.gz"
fi
if [[ -s %{_localstatedir}/log/squid/access.log.3.gz ]]; then
    LOG_FILES="$LOG_FILES -l %{_localstatedir}/log/squid/access.log.3.gz"
fi
if [[ -s %{_localstatedir}/log/squid/access.log.2.gz ]]; then
    LOG_FILES="$LOG_FILES -l %{_localstatedir}/log/squid/access.log.2.gz"
fi
if [[ -s %{_localstatedir}/log/squid/access.log.1.gz ]]; then
    LOG_FILES="$LOG_FILES -l %{_localstatedir}/log/squid/access.log.1.gz"
fi
if [[ -s %{_localstatedir}/log/squid/access.log ]]; then
    LOG_FILES="$LOG_FILES -l %{_localstatedir}/log/squid/access.log"
fi


# Get yesterday's date
YESTERDAY=$(date --date "1 day ago" +%d/%m/%Y)

# Get 1 month ago date
MONTHAGO=$(date --date "1 month ago" +%d/%m/%Y)

exec %{_bindir}/sarg \
        $LOG_FILES \
        -o %{htmloutputdir}/monthly \
	-d $MONTHAGO-$YESTERDAY  > /dev/null 2>&1

exit 0
EOF


%{__cat} <<EOF >sarg-index.html
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
        <title>Squid User's Access Report</title>
	<style type="text/css">
		#content         { width:20em; margin-left:auto; margin-right:auto; }
		h1               { color:green; font-size:1.2em; text-align:center; }
		table#reports    { border-collapse:collapse; width:20em; margin-left:auto; margin-right:auto; font-size:0.8em; }
		table#reports td { padding:2px; background-color:#f5f5dc; border:solid white 1px; }
		table#reports th { background-color:#feebcd; border:solid white 1px; color:#00008b; }
	</style>
</head>
<body>

<div id="content">
	<h1>Squid User's Access Report</h1>

	<table summary="" id="reports">
	<tbody>
	<tr>
		<th>DIRECTORY</th>
		<th>DESCRIPTION</th>
	</tr>
	<tr>
		<td><a href="ONE-SHOT/index.html">ONE-SHOT</a></td>
		<td>One shot reports</td>
	</tr>
	<tr>
		<td><a href="daily/index.html">daily</a></td>
		<td>Daily reports</td>
	</tr>
	<tr>
		<td><a href="weekly/index.html">weekly</a></td>
		<td>Weekly reports</td>
	</tr>
	<tr>
		<td><a href="monthly/index.html">monthly</a></td>
		<td>Monthly reports</td>
	</tr>
	</tbody>
	</table>
</div>
</body>
</html>
EOF

%{__cat} <<EOF >sarg-http.conf
Alias /sarg %{htmloutputdir}

<Directory %{htmloutputdir}>
    DirectoryIndex index.html
    Order deny,allow
    Deny from all
    Allow from 127.0.0.1
    Allow from ::1
    # Allow from your-workstation.com
</Directory>
EOF



%build
%configure \
	--enable-bindir=%{bindir} \
	--enable-sysconfdir=%{sysconfdir} \
	--enable-mandir=%{mandir} \
	--enable-htmldir=%{htmloutputdir}

%{__make} %{?_smp_mflags}


%install
%{__rm} -rf %{buildroot}
%{__install} -d -m0755 %{buildroot}%{sysconfdir} \
		    %{buildroot}%{bindir} \
		    %{buildroot}%{mandir} \
		    %{buildroot}%{htmloutputdir}

%{__install} -d -m0755 %{buildroot}/%{htmloutputdir}/{ONE-SHOT,daily,weekly,monthly}/
%{__install} -D -m0644 sarg-http.conf %{buildroot}%{_sysconfdir}/httpd/conf.d/sarg.conf
%{__install} -D -m0755 sarg.daily %{buildroot}%{_sysconfdir}/cron.daily/sarg
%{__install} -D -m0755 sarg.weekly %{buildroot}%{_sysconfdir}/cron.weekly/sarg
%{__install} -D -m0755 sarg.monthly %{buildroot}%{_sysconfdir}/cron.monthly/sarg
%{__install} -D -m0644 sarg-index.html %{buildroot}/%{htmloutputdir}/index.html
%{__install} -D -m0644 css.tpl %{buildroot}/%{htmloutputdir}/sarg.css

%{__install} -m0755 -d %{buildroot}/%{htmloutputdir}
%{__install} -m0755 -d %{buildroot}%{bindir}
%{__install} -m0755 sarg %{buildroot}%{bindir}
%{__install} -m0755 -d %{buildroot}%{sysconfdir}
%{__install} -m0644 sarg.conf %{buildroot}%{sysconfdir}/sarg.conf
%{__install} -m0644 exclude_codes %{buildroot}%{sysconfdir}/exclude_codes
%{__install} -m0644 sarg.1 %{buildroot}%{mandir}

cp -r ./images %{buildroot}%{sysconfdir}/images
cp -r ./languages %{buildroot}%{sysconfdir}/languages
cp -r ./fonts %{buildroot}%{sysconfdir}/fonts
rm -rf %{buildroot}%{sysconfdir}/languages/.new


%clean
%{__rm} -rf %{buildroot}


%files
%defattr(-, root, root, 0755)
%doc ChangeLog CONTRIBUTORS COPYING README DONATIONS
%config(noreplace) %{_sysconfdir}/sarg/sarg.conf
%config(noreplace) %{_sysconfdir}/httpd/conf.d/sarg.conf
%config %{_sysconfdir}/sarg/exclude_codes
%config %{_sysconfdir}/cron.*/sarg

%dir %{htmloutputdir}
%dir %{sysconfdir}
%dir %{sysconfdir}/fonts
%dir %{sysconfdir}/images
%dir %{sysconfdir}/languages
%dir %{htmloutputdir}/ONE-SHOT
%dir %{htmloutputdir}/daily
%dir %{htmloutputdir}/weekly
%dir %{htmloutputdir}/monthly
%dir %{bindir}
%doc %{mandir}/*

%{bindir}/*
%{sysconfdir}/fonts/*
%{sysconfdir}/images/*
%{sysconfdir}/languages/*
%{htmloutputdir}/index.html
%{htmloutputdir}/sarg.css



%changelog
* Thu May 18 2006 Bernard 'Tux' Lheureux <tux at portalinux dot org> 2.2.1
- Update to 2.2.1
- Built for RHEL4/CentOS4

* Sun Mar 19 2006 Bernard 'Tux' Lheureux <tux at portalinux dot org> 2.1.1
- Update to 2.1.1
- Fix the build errors with the datafile.patch
- Rebuilt for RHEL4/CentOS4

* Tue Jun 21 2005 Petr Kri¹tof <Petr|Kristof_CZ> 2.0.8-1
- Update to 2.0.8
- Rebuild on FC-4

* Mon Apr 04 2005 Neculai Macarie <mack at mack.ro>
- Misc fixes (cron scripts, sort and manpage patches) from Bronislav Bronsky <admin at gorefield.net> 
- Applied latest patches

* Mon Mar 28 2005 Neculai Macarie <mack at mack.ro>
- Fixed weekly and monthly scripts
- Make the index.html file standards compliant

* Tue Mar 22 2005 Neculai Macarie <mack at mack.ro>
- Rebuilt for 2.0.5

* Mon Mar 14 2005 lonely wolf (wolfy at pcnet.ro)
- merged spec file from dag (http://dag.wieers.com/packages/sarg/sarg.spec) and mack (http://mack.ro/linux/sarg/)

* Tue Mar 10 2005 lonely wolf (wolfy at pcnet.ro)
- Compile for Centos 3.4

* Tue Mar 01 2005 Neculai Macarie <mack at mack.ro>
- Added patch for segmentation fault

* Thu Feb 24 2005 Neculai Macarie <mack at mack.ro>
- Rebuilt for 2.0.4

* Thu Nov 4 2004 Neculai Macarie <mack at mack.ro>
- Initial package for sarg 2, with ideas from Dag Wiers
-------------- next part --------------
%define sarg_ver      2.1
%define sysconfdir    /etc/sarg
%define bindir        /usr/bin
%define mandir        /usr/share/man/man1
%define htmloutputdir %{_localstatedir}/www/sarg
%define debug_package %{nil}

Summary: Squid usage report generator per user/ip/name
Name: sarg
Version: %{sarg_ver}
Release: 1
License: GPL
Group: Applications/Network
URL: http://sarg.sf.net/sarg.php

Source0: http://dl.sf.net/sarg/sarg-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}

Patch0: datafile.patch

BuildRequires: perl, gd-devel
Requires: bash, coreutils, squid, httpd, gzip, gd >= 1.8
Obsoletes: sqrmgrlog

%description
Squid Analysis Report Generator is a tool that allows you to view "where"
your users are going to on the Internet. Sarg generate reports in html
showing users, IP Addresses, bytes, sites and times.


%prep
%setup -q -n %{name}-%{sarg_ver}

%patch0 -p0 -b .manpage

# Fix dir permissions
chmod 755 sarg-php/locale

%{__perl} -pi.orig -e '
                s|^#(access_log) (.+)$|#$1 $2\n$1 %{_localstatedir}/log/squid/access.log|;
                s|^#(output_dir) (.+)$|#$1 $2\n$1 %{htmloutputdir}/ONE-SHOT|;
                s|^#(resolve_ip) (.+)$|#$1 $2\n$1 yes|;
                s|^#(show_successful_message) (.+)$|#$1 $2\n$1 no|;
                s|^#(mail_utility) (.+)$|#$1 $2\n$1 mail|;
                s|^#(external_css_file) (.+)$|#$1 $2\n$1 %{htmloutputdir}/sarg.css|;
		
        ' sarg.conf


%{__cat} <<'EOF' >sarg.daily
#!/bin/bash
exec %{_bindir}/sarg \
          -o %{htmloutputdir}/daily \
          -d "$(date --date "1 day ago" +%d/%m/%Y)"  > /dev/null 2>&1

exit 0
EOF


%{__cat} <<'EOF' >sarg.weekly
#!/bin/bash
LOG_FILES=
if [[ -s %{_localstatedir}/log/squid/access.log.1.gz ]]; then
    LOG_FILES="$LOG_FILES -l %{_localstatedir}/log/squid/access.log.1.gz"
fi
if [[ -s %{_localstatedir}/log/squid/access.log ]]; then
    LOG_FILES="$LOG_FILES -l %{_localstatedir}/log/squid/access.log"
fi

# Get yesterday's date
YESTERDAY=$(date --date "1 days ago" +%d/%m/%Y)

# Get one week ago date
WEEKAGO=$(date --date "7 days ago" +%d/%m/%Y)

exec %{_bindir}/sarg \
	$LOG_FILES \
        -o %{htmloutputdir}/weekly \
	-d $WEEKAGO-$YESTERDAY > /dev/null 2>&1

exit 0
EOF


%{__cat} <<'EOF' >sarg.monthly
#!/bin/bash
LOG_FILES=
if [[ -s %{_localstatedir}/log/squid/access.log.4.gz ]]; then
    LOG_FILES="$LOG_FILES -l %{_localstatedir}/log/squid/access.log.4.gz"
fi
if [[ -s %{_localstatedir}/log/squid/access.log.3.gz ]]; then
    LOG_FILES="$LOG_FILES -l %{_localstatedir}/log/squid/access.log.3.gz"
fi
if [[ -s %{_localstatedir}/log/squid/access.log.2.gz ]]; then
    LOG_FILES="$LOG_FILES -l %{_localstatedir}/log/squid/access.log.2.gz"
fi
if [[ -s %{_localstatedir}/log/squid/access.log.1.gz ]]; then
    LOG_FILES="$LOG_FILES -l %{_localstatedir}/log/squid/access.log.1.gz"
fi
if [[ -s %{_localstatedir}/log/squid/access.log ]]; then
    LOG_FILES="$LOG_FILES -l %{_localstatedir}/log/squid/access.log"
fi


# Get yesterday's date
YESTERDAY=$(date --date "1 day ago" +%d/%m/%Y)

# Get 1 month ago date
MONTHAGO=$(date --date "1 month ago" +%d/%m/%Y)

exec %{_bindir}/sarg \
        $LOG_FILES \
        -o %{htmloutputdir}/monthly \
	-d $MONTHAGO-$YESTERDAY  > /dev/null 2>&1

exit 0
EOF


%{__cat} <<EOF >sarg-index.html
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
        <title>Squid User's Access Report</title>
	<style type="text/css">
		#content         { width:20em; margin-left:auto; margin-right:auto; }
		h1               { color:green; font-size:1.2em; text-align:center; }
		table#reports    { border-collapse:collapse; width:20em; margin-left:auto; margin-right:auto; font-size:0.8em; }
		table#reports td { padding:2px; background-color:#f5f5dc; border:solid white 1px; }
		table#reports th { background-color:#feebcd; border:solid white 1px; color:#00008b; }
	</style>
</head>
<body>

<div id="content">
	<h1>Squid User's Access Report</h1>

	<table summary="" id="reports">
	<tbody>
	<tr>
		<th>DIRECTORY</th>
		<th>DESCRIPTION</th>
	</tr>
	<tr>
		<td><a href="ONE-SHOT/index.html">ONE-SHOT</a></td>
		<td>One shot reports</td>
	</tr>
	<tr>
		<td><a href="daily/index.html">daily</a></td>
		<td>Daily reports</td>
	</tr>
	<tr>
		<td><a href="weekly/index.html">weekly</a></td>
		<td>Weekly reports</td>
	</tr>
	<tr>
		<td><a href="monthly/index.html">monthly</a></td>
		<td>Monthly reports</td>
	</tr>
	</tbody>
	</table>
</div>
</body>
</html>
EOF

%{__cat} <<EOF >sarg-http.conf
Alias /sarg %{htmloutputdir}

<Directory %{htmloutputdir}>
    DirectoryIndex index.html
    Order deny,allow
    Deny from all
    Allow from 127.0.0.1
    Allow from ::1
    # Allow from your-workstation.com
</Directory>
EOF



%build
%configure \
	--enable-bindir=%{bindir} \
	--enable-sysconfdir=%{sysconfdir} \
	--enable-mandir=%{mandir} \
	--enable-htmldir=%{htmloutputdir}

%{__make} %{?_smp_mflags}


%install
%{__rm} -rf %{buildroot}
%{__install} -d -m0755 %{buildroot}%{sysconfdir} \
		    %{buildroot}%{bindir} \
		    %{buildroot}%{mandir} \
		    %{buildroot}%{htmloutputdir}

%{__install} -d -m0755 %{buildroot}/%{htmloutputdir}/{ONE-SHOT,daily,weekly,monthly}/
%{__install} -D -m0644 sarg-http.conf %{buildroot}%{_sysconfdir}/httpd/conf.d/sarg.conf
%{__install} -D -m0755 sarg.daily %{buildroot}%{_sysconfdir}/cron.daily/sarg
%{__install} -D -m0755 sarg.weekly %{buildroot}%{_sysconfdir}/cron.weekly/sarg
%{__install} -D -m0755 sarg.monthly %{buildroot}%{_sysconfdir}/cron.monthly/sarg
%{__install} -D -m0644 sarg-index.html %{buildroot}/%{htmloutputdir}/index.html
%{__install} -D -m0644 css.tpl %{buildroot}/%{htmloutputdir}/sarg.css

%{__install} -m0755 -d %{buildroot}/%{htmloutputdir}
%{__install} -m0755 -d %{buildroot}%{bindir}
%{__install} -m0755 sarg %{buildroot}%{bindir}
%{__install} -m0755 -d %{buildroot}%{sysconfdir}
%{__install} -m0644 sarg.conf %{buildroot}%{sysconfdir}/sarg.conf
%{__install} -m0644 exclude_codes %{buildroot}%{sysconfdir}/exclude_codes
%{__install} -m0644 sarg.1 %{buildroot}%{mandir}

cp -r ./images %{buildroot}%{sysconfdir}/images
cp -r ./languages %{buildroot}%{sysconfdir}/languages
cp -r ./fonts %{buildroot}%{sysconfdir}/fonts
rm -rf %{buildroot}%{sysconfdir}/languages/.new


%clean
%{__rm} -rf %{buildroot}


%files
%defattr(-, root, root, 0755)
%doc ChangeLog CONTRIBUTORS COPYING README DONATIONS
%config(noreplace) %{_sysconfdir}/sarg/sarg.conf
%config(noreplace) %{_sysconfdir}/httpd/conf.d/sarg.conf
%config %{_sysconfdir}/sarg/exclude_codes
%config %{_sysconfdir}/cron.*/sarg

%dir %{htmloutputdir}
%dir %{sysconfdir}
%dir %{sysconfdir}/fonts
%dir %{sysconfdir}/images
%dir %{sysconfdir}/languages
%dir %{htmloutputdir}/ONE-SHOT
%dir %{htmloutputdir}/daily
%dir %{htmloutputdir}/weekly
%dir %{htmloutputdir}/monthly
%dir %{bindir}
%doc %{mandir}/*

%{bindir}/*
%{sysconfdir}/fonts/*
%{sysconfdir}/images/*
%{sysconfdir}/languages/*
%{htmloutputdir}/index.html
%{htmloutputdir}/sarg.css



%changelog
* Sun May 18 2006 Bernard 'Tux' Lheureux <tux at portalinux dot org> 2.1.1
- Update to 2.1.1
- Rebuilt for RHEL4/CentOS4

* Tue Jun 21 2005 Petr Kri¹tof <Petr|Kristof_CZ> 2.0.8-1
- Update to 2.0.8
- Rebuild on FC-4

* Mon Apr 04 2005 Neculai Macarie <mack at mack.ro>
- Misc fixes (cron scripts, sort and manpage patches) from Bronislav Bronsky <admin at gorefield.net> 
- Applied latest patches

* Mon Mar 28 2005 Neculai Macarie <mack at mack.ro>
- Fixed weekly and monthly scripts
- Make the index.html file standards compliant

* Tue Mar 22 2005 Neculai Macarie <mack at mack.ro>
- Rebuilt for 2.0.5

* Mon Mar 14 2005 lonely wolf (wolfy at pcnet.ro)
- merged spec file from dag (http://dag.wieers.com/packages/sarg/sarg.spec) and mack (http://mack.ro/linux/sarg/)

* Tue Mar 10 2005 lonely wolf (wolfy at pcnet.ro)
- Compile for Centos 3.4

* Tue Mar 01 2005 Neculai Macarie <mack at mack.ro>
- Added patch for segmentation fault

* Thu Feb 24 2005 Neculai Macarie <mack at mack.ro>
- Rebuilt for 2.0.4

* Thu Nov 4 2004 Neculai Macarie <mack at mack.ro>
- Initial package for sarg 2, with ideas from Dag Wiers


More information about the users mailing list