File: php4-cli.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 (57 lines) | stat: -rw-r--r-- 2,062 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
#!/bin/sh

set -e

#DEBHELPER#

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

phpini="/etc/php4/cli/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.cli $phpini
		fi
	fi
fi
# END LEGACY SUPPORT
ucf /usr/share/php4/php.ini-dist.cli $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

update-alternatives \
	--install /usr/bin/php php /usr/bin/php4 40 \
	--slave /usr/share/man/man1/php.1.gz php.1.gz /usr/share/man/man1/php4.1.gz

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

exit 0