[Pkg-php-commits] [php/debian-sid] Dynamically determine maxlifetime if possible.

Sean Finney seanius at seanius.net
Sat Jun 19 14:11:24 UTC 2010


Incorporate suggestions from #504053 to use the cmdline php if available
to determine the maxlifetime value, but retain the previous logic as well
in case php5-cli is not installed.  Also, add a Recommends on php5-cli to
libapache2-mod-php5 to make it more likely that it is installed.

Closes: #504053
Thanks: Chris Butler <chrisb at debian.org>
---
 debian/control     |    1 +
 debian/maxlifetime |   16 +++++++++++-----
 2 files changed, 12 insertions(+), 5 deletions(-)
 mode change 100644 => 100755 debian/maxlifetime

diff --git a/debian/control b/debian/control
index b295add..408cd96 100644
--- a/debian/control
+++ b/debian/control
@@ -105,6 +105,7 @@ Architecture: any
 Depends: ${shlibs:Depends}, ${misc:Depends}, mime-support, ${apache2:Depends}, php5-common (= ${binary:Version}), libmagic1, ucf, tzdata
 Conflicts: libapache2-mod-php4, libapache2-mod-php5filter
 Provides: ${php:Provides}
+Recommends: php5-cli
 Suggests: php-pear
 Description: server-side, HTML-embedded scripting language (Apache 2 module)
  This package provides the PHP5 module for the Apache 2 webserver (as
diff --git a/debian/maxlifetime b/debian/maxlifetime
old mode 100644
new mode 100755
index 21658eb..b95d6b2
--- a/debian/maxlifetime
+++ b/debian/maxlifetime
@@ -2,11 +2,17 @@
 
 max=1440
 
-for ini in /etc/php5/*/php.ini; do
-	cur=$(sed -n -e 's/^[[:space:]]*session.gc_maxlifetime[[:space:]]*=[[:space:]]*\([0-9]\+\).*$/\1/p' $ini 2>/dev/null || true);
-	[ -z "$cur" ] && cur=0
-	[ "$cur" -gt "$max" ] && max=$cur
-done
+if which php5 >/dev/null 2>&1 && [ -e /etc/php5/apache2/php.ini ]; then
+  cur=$(php5 -c /etc/php5/apache2/php.ini -r 'print ini_get("session.gc_maxlifetime");')
+  [ -z "$cur" ] && cur=0
+  [ "$cur" -gt "$max" ] && max=$cur
+else
+        for ini in /etc/php5/*/php.ini; do
+          cur=$(sed -n -e 's/^[[:space:]]*session.gc_maxlifetime[[:space:]]*=[[:space:]]*\([0-9]\+\).*$/\1/p' $ini 2>/dev/null || true);
+          [ -z "$cur" ] && cur=0
+          [ "$cur" -gt "$max" ] && max=$cur
+        done
+fi
 
 echo $(($max/60))
 
-- 
1.6.5




More information about the Pkg-php-commits mailing list