From c699ddf28809a37e5133e0f66d60e3b11ae5bda7 Mon Sep 17 00:00:00 2001 From: Valentin Vidic Date: Tue, 12 May 2009 14:42:35 +0200 Subject: [PATCH] Handle php.ini upgrade. --- .../apache2/{php.ini.expect => php.ini.template} | 0 .../php5/cli/{php.ini.expect => php.ini.template} | 0 src/functions.sh | 26 +++++++++++++++++--- 3 files changed, 22 insertions(+), 4 deletions(-) rename files/etc/php5/apache2/{php.ini.expect => php.ini.template} (100%) rename files/etc/php5/cli/{php.ini.expect => php.ini.template} (100%) diff --git a/files/etc/php5/apache2/php.ini.expect b/files/etc/php5/apache2/php.ini.template similarity index 100% rename from files/etc/php5/apache2/php.ini.expect rename to files/etc/php5/apache2/php.ini.template diff --git a/files/etc/php5/cli/php.ini.expect b/files/etc/php5/cli/php.ini.template similarity index 100% rename from files/etc/php5/cli/php.ini.expect rename to files/etc/php5/cli/php.ini.template diff --git a/src/functions.sh b/src/functions.sh index ef321d6..f1b284a 100644 --- a/src/functions.sh +++ b/src/functions.sh @@ -800,7 +800,7 @@ copy_template () { # restore modified config to their package defaults # so the upgrade doesn't complain so much restore_configs () { - local hostname domain template config_new + local hostname domain config_new memtotal memlimit # restore simple configs if pkg kernel-2.6-cn && pkg procps lt 1:3.2.7-11; then @@ -863,16 +863,34 @@ restore_configs () { restore_file /etc/issue.net fi + # restore php.ini + memtotal=$(awk '$1 == "MemTotal:" { print int($2/1024) }' /proc/meminfo) + if [ $memtotal -gt 1024 ]; then + memlimit=64 + elif [ $memtotal -ge 512 ]; then + memlimit=32 + else + memlimit=16 + fi + if pkg php5-cn && pkg php5-cli lt 5.2.6.dfsg.1-1+lenny2; then - if restore_file /etc/php5/cli/php.ini; then + config_new=$(copy_template /etc/php5/cli/php.ini) + sed -i "s/^[[:space:]]*memory_limit[[:space:]]*=.*/memory_limit = ${memlimit}M/" $config_new + sed -i "s/^[[:space:]]*post_max_size[[:space:]]*=.*/post_max_size = ${memlimit}M/" $config_new + if restore_file /etc/php5/cli/php.ini $config_new; then postupgrade_reconfigure php5-cn fi + rm -f $config_new fi if pkg php5-cn && pkg libapache2-mod-php5 lt 5.2.6.dfsg.1-1+lenny2; then - if restore_file /etc/php5/apache2/php.ini; then + config_new=$(copy_template /etc/php5/apache2/php.ini) + sed -i "s/^[[:space:]]*memory_limit[[:space:]]*=.*/memory_limit = ${memlimit}M/" $config_new + sed -i "s/^[[:space:]]*post_max_size[[:space:]]*=.*/post_max_size = ${memlimit}M/" $config_new + if restore_file /etc/php5/apache2/php.ini $config_new; then postupgrade_reconfigure php5-cn fi + rm -f $config_new fi # check if monitrc is template based @@ -1027,7 +1045,7 @@ upgrade_libc () { DEBIAN_FRONTEND=noninteractive pkgadd libc6 tzdata } -# upgrade apache2 to lenny +# upgrade apache2/php5 to lenny upgrade_apache2 () { local package packages -- 1.7.10.4