File: libapache2-mod-php4.postinst

package info (click to toggle)
php4 6%3A4.4.4-8%2Betch6
  • links: PTS
  • area: main
  • in suites: etch
  • size: 35,068 kB
  • ctags: 39,148
  • sloc: ansic: 340,486; php: 34,786; cpp: 10,150; sh: 9,010; lex: 2,180; yacc: 1,712; xml: 1,335; makefile: 559; awk: 466; java: 455; perl: 154
file content (77 lines) | stat: -rw-r--r-- 2,558 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/sh

set -e

#DEBHELPER#

if [ "$1" != "configure" ]; then
    exit 0
fi

phpini="/etc/php4/apache2/php.ini"
# LEGACY SUPPORT
# previous versions of php did not ship $phpini as a conffile nor did
# they use anything like ucf.  as a result, we need to help transition
# those files into ucf a little more easily by updating unmodified
# ini files before registering them
#
# if we're upgrading from a pre-ucf version of php:
if dpkg --compare-versions "$2" le-nl "4:4.4.4-3"; then
	# if the SAPI config file already exists and is unmodified
	if [ -f "$phpini" ]; then
		oldmd5=`md5sum $phpini | cut -d' ' -f1`
		if [ "$oldmd5" = "c887b67c2c6c77bc49480480d291d22f" ] ||
		   [ "$oldmd5" = "21d8e6d4734bbb3eb9c2ab0873f4e0b4" ]; then 
			# then silently update it before registering via ucf
			cp /usr/share/php4/php.ini-dist $phpini
		fi
	fi
fi
# END LEGACY SUPPORT
ucf /usr/share/php4/php.ini-dist $phpini

if dpkg --compare-versions "$2" lt "4:4.3.9-1"; then
    if grep -q "^[[:space:]]*session.gc_probability[[:space:]]*=[[:space:]]*[[:digit:]]*" $phpini; then
        if grep -q "^[[:space:]]*session.save_path[[:space:]]*=[[:space:]]*/var/lib/php4" $phpini; then
            sed -i -e "s/^[[:space:]]*session.save_path.*$/;session.save_path = \\/var\\/lib\\/php4/" $phpini
            sed -i -e "s/^[[:space:]]*session.gc_probability.*$/;session.gc_probability = 0/" $phpini
        fi
        if ! grep -q "^[[:space:]]*session.save_path" $phpini; then
            sed -i -e "s/^[[:space:]]*session.gc_probability.*$/;session.gc_probability = 0/" $phpini
        fi
    fi
    if grep -q "^[[:space:]]*session.save_handler[[:space:]]*=[[:space:]]*mm" $phpini; then
        sed -i -e "s/^[[:space:]]*session.save_handler.*$/;session.save_handler = files/" $phpini
    fi
fi

reload_apache()
{
	if apache2ctl configtest 2>/dev/null; then
		invoke-rc.d apache2 force-reload || true
	else
		echo "Your apache2 configuration is broken, so we're not restarting it for you."
	fi
}

if [ -n "$2" ]; then
# we're upgrading. test if we're enabled, and if so, restart to reload the module.
	if [ -e /etc/apache2/mods-enabled/php4.load ]; then
		reload_apache
	fi
        exit 0
fi

if [ -e /etc/apache2/apache2.conf ]; then
# Enable the module, but hide a2enmod's misleading message about apachectl
# and force-reload the thing ourselves.
        a2enmod php4 >/dev/null || true
	reload_apache
fi

if [ ! -L /usr/share/doc/libapache2-mod-php4 ]; then
	rm -rf /usr/share/doc/libapache2-mod-php4
	ln -s php4-common /usr/share/doc/libapache2-mod-php4
fi

exit 0