+ if pkg ntp-cn && pkg ntp lt 1:4.2.4p4+dfsg-8; then
+ if restore_file /etc/ntp.conf; then
+ postupgrade_reconfigure ntp-cn
+ fi
+ fi
+
+ if pkg apache2-cn && pkg apache2.2-common lt 2.2.9-10+lenny2; then
+ if restore_file /etc/apache2/ports.conf; then
+ postupgrade_reconfigure apache2-cn
+ fi
+ fi
+
+ if pkg postfix-cn && pkg sasl2-bin lt 2.1.22.dfsg1-23; then
+ if restore_file /etc/default/saslauthd; then
+ postupgrade_reconfigure postfix-cn
+ fi
+ fi
+
+ if pkg bind9-cn && pkg bind9 lt 1:9.5.1.dfsg.P1-1; then
+ if restore_file /etc/bind/named.conf.options; then
+ postupgrade_reconfigure bind9-cn
+ fi
+ fi
+
+ if pkg amavisd-cn && pkg amavisd-new lt 1:2.6.1.dfsg-1; then
+ if restore_file /etc/cron.daily/amavisd-new; then
+ rm -f /etc/cron.daily/amavisd-new.$backup_ext
+ postupgrade_reconfigure amavisd-cn
+ fi
+ fi
+
+ if pkg spamassassin-cn && pkg razor lt 1:2.85-1; then
+ if restore_file /etc/razor/razor-agent.conf; then
+ postupgrade_reconfigure spamassassin-cn
+ fi
+ fi
+
+ if pkg kernel-2.6-cn && pkg libpam-modules lt 1.0.1-5; then
+ if restore_file /etc/security/limits.conf; then
+ postupgrade_reconfigure kernel-2.6-cn
+ fi
+ fi
+
+ if pkg samba-cn && pkg samba-common lt 2:3.2.5-4lenny2; then
+ if restore_file /etc/samba/smb.conf; then
+ postupgrade_reconfigure samba-cn
+ fi
+ fi
+
+ if pkg base-files lt 5lenny2; then
+ restore_file /etc/issue
+ 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
+ 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
+ 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
+ if [ -f /etc/monit/monitrc ]; then
+ # regenerate config from template
+ hostname=$(hostname)
+ domain=$(hostname --domain)
+ config_new=$(copy_template /etc/monit/monitrc)
+ check_and_sed "@localhost" \
+ "s/@localhost/@$hostname.$domain/g" $config_new || true
+ restore_file /etc/monit/monitrc $config_new
+ rm -f $config_new
+ fi