Summary(pl.UTF-8): Wspólne katalogi dla różnych wersji PHP
Name: php-dirs
Version: 1.1
-Release: 5
+Release: 6
License: GPL
Group: Base
+Source0: php-session.sh
BuildRequires: rpmbuild(macros) >= 1.461
Requires(postun): /usr/sbin/groupdel
Requires(pre): /usr/bin/getgid
BuildArch: noarch
BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
-%define _tmpwatchdir /etc/tmpwatch
-
%description
Common directories for PHP version 4 and version 5.
%install
rm -rf $RPM_BUILD_ROOT
-install -d $RPM_BUILD_ROOT{%{php_data_dir}/tests,/var/run/php}
+install -d $RPM_BUILD_ROOT{%{php_data_dir}/tests,/etc/cron.hourly,/var/run/php}
install -d $RPM_BUILD_ROOT%{_docdir}/phpdoc
-install -d $RPM_BUILD_ROOT%{_tmpwatchdir}
-echo '/var/run/php 720' > $RPM_BUILD_ROOT%{_tmpwatchdir}/php.conf
+install %{SOURCE0} $RPM_BUILD_ROOT/etc/cron.hourly
%clean
rm -rf $RPM_BUILD_ROOT
# http needs only x for directory (otherwise it knows session file
# names and can read it contents)
%attr(730,root,http) %dir %verify(not group mode) /var/run/php
-%config(noreplace) %verify(not md5 mtime size) %{_tmpwatchdir}/php.conf
+%attr(755,root,root) %{_sysconfdir}/cron.hourly/php-session.sh
--- /dev/null
+#!/bin/sh
+if [ -x /usr/bin/php.cli ] ; then
+ RUNTIME5=$(/usr/bin/php.cli -r 'echo 1+(int)(ini_get("session.gc_maxlifetime")/3600);' 2> /dev/null)
+elif [ -r /etc/php/php.ini ]; then
+ RUNTIME5=$(awk -F"=" '/^session.gc_maxlifetime[[:space:]]*=/ { t=sprintf("%d", 1+($2/3600)); print t;}' /etc/php/php.ini)
+fi
+
+if [ -x /usr/bin/php4.cli ] ; then
+ RUNTIME4=$(/usr/bin/php4.cli -r 'echo 1+(int)(ini_get("session.gc_maxlifetime")/3600);' 2> /dev/null)
+elif [ -r /etc/php4/php.ini ]; then
+ RUNTIME4=$(awk -F"=" '/^session.gc_maxlifetime[[:space:]]*=/ { t=sprintf("%d", 1+($2/3600)); print t;}' /etc/php4/php.ini)
+fi
+
+[ -z "$RUNTIME5" ] && RUNTIME5="1h"
+
+if [ -n "$RUNTIME5" ]; then
+ /usr/sbin/tmpwatch ${RUNTIME5} /var/run/php
+fi
+
+if [ -n "$RUNTIME4" -a "$RUNTIME5" != "$RUNTIME4" ]; then
+ /usr/sbin/tmpwatch ${RUNTIME4} /var/run/php
+fi