Sophie

Sophie

distrib > Mandriva > cs4.0 > i586 > by-pkgid > e4ff0e998c3c67d92639048397d6a654 > files > 3

mysqlard-1.0.0-4mdk.src.rpm

Summary:	MySQL performance logging daemon
Name:		mysqlard
Version:	1.0.0
Release:	%mkrel 4
Group:		System/Servers
License:	GPL
URL:		http://gert.sos.be/en/
Source0:	http://www.sos.be/projects/%{name}/dist/%{name}-%{version}.tar.bz2
Patch0:		mysqlard-1.0.0-mdv_conf.diff
Requires(post): rpm-helper
Requires(preun): rpm-helper
Requires(pre):	apache-mod_php apache-mod_ssl php-mysql
Requires:	apache-mod_php apache-mod_ssl php-mysql
Requires:	MySQL
Requires:	rrdtool
BuildRequires:	ImageMagick
BuildRequires:	apache-base >= 2.0.54
BuildRequires:	MySQL-devel
BuildRequires:	rrdtool
BuildRequires:	librrdtool-devel
BuildRoot:	%{_tmppath}/%{name}-%{version}-root

%description
mysqlard daemon collects MySQL(TM) performance data in a Round Robin Database.
The package also contains example graphing and php scripts.

%prep

%setup -q
%patch0 -p0

chmod 644 AUTHORS ChangeLog COPYING INSTALL NEWS README TODO

%build

%configure2_5x \
    --sysconfdir=%{_sysconfdir}/%{name} \
    --localstatedir=/var/run/%{name} \
    --datadir=/var/lib

%make

%install
[ "%{buildroot}" != "/" ] && rm -rf %{buildroot}

# don't fiddle with the initscript!
export DONT_GPRINTIFY=1

%makeinstall_std

install -d %{buildroot}%{_initrddir}
install -d %{buildroot}%{_sysconfdir}/%{name}
install -d %{buildroot}%{_sysconfdir}/cron.d
install -d %{buildroot}%{_sysconfdir}/cron.daily
install -d %{buildroot}%{_sysconfdir}/cron.weekly
install -d %{buildroot}%{_sysconfdir}/cron.monthly
install -d %{buildroot}%{_sysconfdir}/httpd/conf/webapps.d
install -d %{buildroot}/var/lib/%{name}/archive
install -d %{buildroot}/var/run/%{name}

mv %{buildroot}/var/lib/%{name}/*.cnf %{buildroot}%{_sysconfdir}/%{name}/
mv %{buildroot}/var/lib/%{name}/*.server %{buildroot}%{_initrddir}/%{name}

mv %{buildroot}/var/lib/%{name}/mysqlar.daily %{buildroot}%{_sysconfdir}/cron.daily/%{name}

mv %{buildroot}/var/lib/%{name}/mysqlar.weekly %{buildroot}%{_sysconfdir}/cron.weekly/%{name}

mv %{buildroot}/var/lib/%{name}/mysqlar.monthly %{buildroot}%{_sysconfdir}/cron.monthly/%{name}

mv %{buildroot}/var/lib/%{name}/mysqlar.php %{buildroot}/var/lib/%{name}/index.php

cat > %{name}.crond << EOF
#!/bin/sh

*/5 * * * * root hourly=1 daily=1 weekly=1 monthly=1 %{_bindir}/mysqlar_graph > /dev/null
EOF

install -m0755 %{name}.crond %{buildroot}%{_sysconfdir}/cron.d/%{name}

cat > %{buildroot}/%{_sysconfdir}/httpd/conf/webapps.d/%{name}.conf << EOF

Alias /%{name} /var/lib/%{name}

<Directory /var/lib/%{name}>
    Order Deny,Allow
    Deny from All
    Allow from 127.0.0.1
</Directory>

<LocationMatch /%{name}>
    Options FollowSymLinks
    RewriteEngine on
    RewriteCond %{SERVER_PORT} !^443$
    RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
</LocationMatch>

EOF

# install script to call the web interface from the menu.
install -d %{buildroot}%{_libdir}/%{name}/scripts
cat > %{buildroot}%{_libdir}/%{name}/scripts/%{name} <<EOF
#!/bin/sh

url='https://localhost/%{name}'
if ! [ -z "\$BROWSER" ] && ( which \$BROWSER ); then
  browser=\`which \$BROWSER\`
elif [ -x /usr/bin/mozilla-firefox ]; then
  browser=/usr/bin/mozilla-firefox
elif [ -x /usr/bin/konqueror ]; then
  browser=/usr/bin/konqueror
elif [ -x /usr/bin/lynx ]; then
  browser='xterm -bg black -fg white -e lynx'
elif [ -x /usr/bin/links ]; then
  browser='xterm -bg black -fg white -e links'
else
  xmessage "No web browser found, install one or set the BROWSER environment variable!"
  exit 1
fi
\$browser \$url
EOF
chmod 755 %{buildroot}%{_libdir}/%{name}/scripts/%{name}

# Mandriva Icons
install -d %{buildroot}%{_iconsdir}
install -d %{buildroot}%{_miconsdir}
install -d %{buildroot}%{_liconsdir}

convert src/mysql.gif -resize 16x16 %{buildroot}%{_miconsdir}/%{name}.png
convert src/mysql.gif -resize 32x32 %{buildroot}%{_iconsdir}/%{name}.png
convert src/mysql.gif -resize 48x48 %{buildroot}%{_liconsdir}/%{name}.png

# install menu entry.
install -d %{buildroot}%{_menudir}
cat > %{buildroot}%{_menudir}/%{name} << EOF
?package(%{name}): needs=X11 \
section="System/Monitoring" \
title="mysqlard" \
longtitle="mysqlard is a MySQL performance logging daemon.  Set the $BROWSER environment variable to choose your preferred browser." \
command="%{_libdir}/%{name}/scripts/%{name} 1>/dev/null 2>/dev/null" \
icon="%{name}.png"
EOF

%post
%_post_service %{name}
%_post_webapp
%update_menus

%preun
%_preun_service %{name}
%_postun_webapp
%clean_menus

%clean
[ "%{buildroot}" != "/" ] && rm -rf %{buildroot}

%files
%defattr(0755,root,root)
%doc AUTHORS ChangeLog COPYING INSTALL NEWS README TODO
%attr(0644,root,root) %config(noreplace) %{_sysconfdir}/%{name}/*.cnf
%attr(0644,root,root) %config(noreplace) %{_sysconfdir}/httpd/conf/webapps.d/%{name}.conf
%attr(0755,root,root) %{_initrddir}/mysqlard
%attr(0755,root,root) %{_sysconfdir}/cron.d/%{name}
%attr(0755,root,root) %{_sysconfdir}/cron.daily/%{name}
%attr(0755,root,root) %{_sysconfdir}/cron.weekly/%{name}
%attr(0755,root,root) %{_sysconfdir}/cron.monthly/%{name}
%{_bindir}/*
%{_sbindir}/*
/var/lib/%{name}
%dir /var/run/%{name}
%{_mandir}/man1/*
%{_mandir}/man8/*
%attr(0755,root,root) %{_libdir}/%{name}/scripts/%{name}
%{_menudir}/%{name}
%{_iconsdir}/%{name}.png
%{_miconsdir}/%{name}.png
%{_liconsdir}/%{name}.png

%changelog
* Sun May 14 2006 Oden Eriksson <oeriksson@mandriva.com> 1.0.0-4mdk
- fix a menuentry
- add mod_rewrite rules to enforce ssl connections
- fix deps

* Sat May 13 2006 Oden Eriksson <oeriksson@mandriva.com> 1.0.0-3mdk
- fix a better initscript (P0)

* Fri May 05 2006 Oden Eriksson <oeriksson@mandriva.com> 1.0.0-2mdk
- fix the cron syntax

* Wed May 03 2006 Oden Eriksson <oeriksson@mandriva.com> 1.0.0-1mdk
- initial Mandriva package