File: apache2-common.postinst

package info (click to toggle)
apache2 2.0.54-5sarge2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 8,260 kB
  • ctags: 176
  • sloc: sh: 533; makefile: 367; python: 209; perl: 127
file content (82 lines) | stat: -rw-r--r-- 3,356 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
#!/bin/sh -e

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

# Source Debconf confmodule.
#. /usr/share/debconf/confmodule

NETSTAT=netstat

# An ugly hack, I know, but a necessarily ugly hack.
#This desperately needs debconf, soon.
if [ ! -f /etc/apache2/ports.conf ]; then
	echo "# 0 = start on boot; 1 = don't start on boot" > /etc/default/apache2
	NO_AF_INET=`$NETSTAT -lnt 2>&1 | grep 'no support for .AF INET (tcp)'` || true
	NO_PORT_80=`$NETSTAT -lnt | awk '{print $4}' | grep ':80$'` || true
	if [ -n "$NO_AF_INET" -o -n "$NO_PORT_80" ]; then
		echo "NO_START=1" >> /etc/default/apache2
		echo "Listen 80" >> /etc/apache2/ports.conf
		if [ -n "$NO_AF_INET" ]; then
			echo "netstat is unable to query the state of your listening TCP ports.  This could be because you don't have TCP support in your kernel (unlikely), or because you do not have the /proc filesystem mounted.  To be on the safe side, we're assuming that port 80 is in use."
		fi
		echo "Setting Apache2 not to start, as something else appears to be using Port 80. To allow apache2 to start, set NO_START to 0 in /etc/default/apache2. Apache2 has been set to listen on port 80 by default, so please edit /etc/apache2/ports.conf as desired. Note that the Port directive no longer works."
	else
		echo "NO_START=0" >> /etc/default/apache2
		echo "Listen 80" >> /etc/apache2/ports.conf
		echo "Setting Apache2 to Listen on port 80. If this is not desired, please edit /etc/apache2/ports.conf as desired. Note that the Port directive no longer works."
	fi
fi

# check for 2.2 kernels and set up the scoreboard.
if [ `uname -r|grep "2.2"` ]; then
	printf "#This is required for 2.2 kernels\nScoreboardFile /var/log/apache2/apache2_scoreboard\n" > /etc/apache2/conf.d/scoreboard
fi

# Make self-signed certificate
#if [ ! -f /etc/apache2/ssl/apache.pem ]
#then
#        /usr/sbin/make-ssl-cert /usr/share/ssl-cert/ssleay.cnf /etc/apache2/ssl/apache.pem
#fi

#create httpd.conf
if [ ! -e /etc/apache2/httpd.conf ]; then
cat >/etc/apache2/httpd.conf <<EOF
# This is here for backwards compatability reasons and to support
#  installing 3rd party modules directly via apxs2, rather than
#  through the /etc/apache2/mods-{available,enabled} mechanism.
#
#LoadModule mod_placeholder /usr/lib/apache2/modules/mod_placeholder.so
EOF
fi

#set up default site and dummy error and access logs
if [ "$2" = "<unknown>" -o -z "$2" ]; then
	if [ ! -L /etc/apache2/sites-enabled/000-default -a \
             ! -f /etc/apache2/sites-enabled/000-default ]; then 
		ln -s /etc/apache2/sites-available/default /etc/apache2/sites-enabled/000-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

# Make sure /var/lock/apache2 has the correct permissions
if [ -d /var/lock/apache2 ]; then
        chown www-data /var/lock/apache2
fi

#auto enable mod_userdir on upgrades and new installs, otherwise things will B-R-EAK
if dpkg --compare-versions "$2" lt 2.0.50-1; then
        a2enmod userdir
fi

#fix up ext-filter mess
rm -f /etc/apache2/mods-available/ext-filter.load || true
if [ -h "/etc/apache2/mods-enabled/ext-filter.load" ]; then
        rm -f /etc/apache2/mods-enabled/ext-filter.load || true
        a2enmod ext_filter;
fi

exit 0