File: apache2.2-common.postinst

package info (click to toggle)
apache2 2.2.22-13%2Bdeb7u6
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 47,900 kB
  • sloc: ansic: 233,662; sh: 15,591; perl: 2,223; awk: 1,172; makefile: 1,081; lex: 191; python: 142; yacc: 100; xml: 36
file content (130 lines) | stat: -rw-r--r-- 4,291 bytes parent folder | download
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/bin/sh -e

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

mod_is_enabled() {
    test -L /etc/apache2/mods-enabled/$1.load
}

#set up default site and dummy error and access logs
if [ -z "$2" ]; then
        if [ ! -L /etc/apache2/sites-enabled/000-default -a \
             ! -f /etc/apache2/sites-enabled/000-default ]; then
                a2ensite -q default
        fi
        touch /var/log/apache2/error.log /var/log/apache2/access.log
        chown root:adm /var/log/apache2/error.log /var/log/apache2/access.log
        chmod 0640 /var/log/apache2/error.log /var/log/apache2/access.log
fi

# Note, this line catches new installs as well as upgrades
if dpkg --compare-versions "$2" lt 2.2.3-3.1; then
	a2enmod -q alias
	a2enmod -q autoindex
	a2enmod -q dir
	a2enmod -q env
	a2enmod -q mime
	a2enmod -q negotiation
	a2enmod -q setenvif
	a2enmod -q status
	a2enmod -q auth_basic
	a2enmod -q deflate

        # Those come from mod_auth:
	a2enmod -q authz_default
	a2enmod -q authz_user
	a2enmod -q authz_groupfile
	a2enmod -q authn_file
        
	# This comes from mod_access:
	a2enmod -q authz_host

fi

if [ -n "$2" ] && dpkg --compare-versions "$2" lt 2.2.15-4~ ; then
	echo activating new config files ...
	for a in ldap proxy_balancer proxy_ftp ; do 
		if mod_is_enabled $a && [ ! -e /etc/apache2/mods-enabled/$a.conf ] ; then
			a2enmod -q $a
		fi
	done
	echo " done."
fi

# Note, this line catches new installs as well as upgrades
if dpkg --compare-versions "$2" lt 2.2.7-1~0; then
	if [ ! -e /var/www/index.html  -a \
	     ! -h /var/www/index.html  -a \
	     ! -e /var/www/index.cgi   -a \
	     ! -e /var/www/index.pl    -a \
	     ! -e /var/www/index.php   -a \
	     ! -e /var/www/index.xhtml -a \
	     ! -e /var/www/index.htm ] ; then
		cp /usr/share/apache2/default-site/index.html /var/www/index.html
	fi
fi

# DavLockDB format change
if dpkg --compare-versions "$2" lt 2.2.14-3~; then
	rm -f /var/lock/apache2/DAVLock.dir /var/lock/apache2/DAVLock.pag
fi

# Note, this line catches new installs as well as upgrades
if dpkg --compare-versions "$2" lt 2.2.15-1~0; then
	a2enmod -q reqtimeout
fi

if [ -n "$2" ] && dpkg --compare-versions "$2" lt 2.2.22-6~ ; then
	if [ -e /etc/apache2/httpd.conf ] && [ -f /etc/apache2/httpd.conf ] ; then
		md5sum="$(md5sum /etc/apache2/httpd.conf | sed -e 's/ .*//')"
		if [ $md5sum = "d41d8cd98f00b204e9800998ecf8427e" ] ||
		   [ $md5sum = "a20c3e53dd07836481a5e64bc71e1a33" ]
		then
			echo "Remove obsolete configuration file /etc/apache2/httpd.conf"
			rm -f /etc/apache2/httpd.conf
		elif [ -d /etc/apache2/conf.d/ ] && [ ! -f /etc/apache2/conf.d/httpd.conf ] ; then
			echo "Detected legacy httpd.conf - moving file to /etc/apache2/conf.d/httpd.conf"
			mv /etc/apache2/httpd.conf /etc/apache2/conf.d/httpd.conf
		fi
	fi
	rm -f /etc/apache2/mods-enabled/version.load
fi
dpkg-maintscript-helper rm_conffile /etc/apache2/mods-available/version.load 2.2.22-6~ -- "$@"

# The definition of other_vhost_access.log has been moved.
# Disable the new definition if the admin has changed the old
# one (as determined by preinst).
if [ -e /etc/apache2/disable-other-vhost-access-log.dpkg-apache2.2-common ] ; then
	echo "Disabling /etc/apache2/conf.d/other-vhosts-access-log"
	perl -p -i -e 's/^(CustomLog.*)$/#$1/' /etc/apache2/conf.d/other-vhosts-access-log
	rm  /etc/apache2/disable-other-vhost-access-log.dpkg-apache2.2-common
fi


# Should run on upgrades from Squeeze or Testing only
# This code existed in parts 2.2.22-10 already but it wasn't complete.
# Thus, users of 2.2.22-10 (only in Sid) enter here as well. That's not
# optimal, but not a problem either.
if [ -n "$2" ] && dpkg --compare-versions "$2" lt 2.2.22-11; then
	if [ -d /var/cache/apache2/mod_disk_cache ] ; then
		echo "Purging old mod_disk_cache cache data in /var/cache/apache2/mod_disk_cache"
		if [ -d /var/cache/apache2/ ] && [ "$(stat -c '%U' /var/cache/apache2/)" = "www-data" ] ; then
			 chown root:root /var/cache/apache2/
		fi
		rm -rf /var/cache/apache2/mod_disk_cache
		install -o www-data -g www-data -d /var/cache/apache2/mod_disk_cache/
	fi
fi


rm -f /etc/apache2/ports.conf.dpkg-apache2.2-common.old
rm -f /etc/default/apache2.dpkg-apache2.2-common.old
rm -f /etc/apache2/conf.d/charset.dpkg-apache2.2-common.old


#DEBHELPER#

exit 0