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 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235
|
#! /bin/sh
# postinst script for apache
#
# see: dh_installdeb(1)
set -e
# summary of how this script can be called:
# * <postinst> `configure' <most-recently-configured-version>
# * <old-postinst> `abort-upgrade' <new version>
# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
# <new-version>
# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
# <failed-install-package> <version> `removing'
# <conflicting-package> <version>
# for details, see /usr/doc/packaging-manual/
#
# quoting from the policy:
# Any necessary prompting should almost always be confined to the
# post-installation script, and should be protected with a conditional
# so that unnecessary prompting doesn't happen if a package's
# installation fails and the `postinst' is called with `abort-upgrade',
# `abort-remove' or `abort-deconfigure'.
if [ "$1" != configure ]
then
exit 0
fi
if [ "$2" != "" ]
then
CONFFLAGS="--update"
else
CONFFLAGS="--fullauto"
fi
# adduser stuffs moved from preinst
if [ -e /usr/sbin/adduser ]
then
if ! grep -q "^www" /etc/group;
then
echo -n "The www-data group is missing! Attempt to fix? "
read X
if [ "$X" = "Y" -o "$X" = "y" ];
then
echo "Here goes nothing ... "
addgroup --gid 33 --force-badname www-data
echo
fi
fi
if ! grep -q "^www" /etc/passwd;
then
echo -n "The www-data user is missing! Attempt to fix? "
read X
if [ "$X" = "Y" -o "$X" = "y" ];
then
adduser --system --home /var/www --no-create-home \
--uid 33 --gid 33 --disabled-password --force-badname www-data
echo
fi
fi
fi
if [ ! -e /etc/apache/conf ] && [ "$2" = "" ]
then
ln -s . /etc/apache/conf
fi
if [ -f /etc/apache/httpd.conf ] \
&& ! grep -q LoadModule: /etc/apache/httpd.conf \
&& ! grep -q ClearModuleList: /etc/apache/httpd.conf
then
echo -n "Adding magic LoadModule line to httpd.conf ... "
cat > /etc/apache/httpd.conf.dpkg-inst.$$ <<EOF
# Please keep this LoadModule: line here, it is needed for installation.
EOF
cat /etc/apache/httpd.conf >> /etc/apache/httpd.conf.dpkg-inst.$$
mv /etc/apache/httpd.conf.dpkg-inst.$$ /etc/apache/httpd.conf
echo "done."
fi
# If the 1.3.9 Debian Package's srm.conf is still around, comment out
# this directive or the newly-installed web server (currently 1.3.14)
# won't start.
if [ -f /etc/apache/srm.conf ]
then
if grep -q "^[ ]*AddDefaultCharsetName" /etc/apache/srm.conf
then
sed '/[^ ]*AddDefaultCharsetName/s/^/# Obsolete # /' < /etc/apache/srm.conf > /etc/apache/srm.conf.dpkg-inst.$$ &&
cat /etc/apache/srm.conf.dpkg-inst.$$ > /etc/apache/srm.conf
fi
fi
if [ ! -e /etc/apache/mime.types ]
then
ln -s ../mime.types /etc/apache/mime.types
fi
if ! grep -qi "^webmaster:" /etc/aliases 2> /dev/null
then
echo "Adding webmaster to /etc/aliases ..."
echo "webmaster: root" >> /etc/aliases
if [ -e /usr/sbin/newaliases ]
then
newaliases
fi
fi
update-rc.d apache defaults 91 20 > /dev/null
NEED_ECHO=0
if [ -d /etc/httpd ]
then
echo "Directory /etc/httpd is way obsolete, and should be removed."
NEED_ECHO=1
fi
if [ -d /usr/lib/httpd/cgi-bin ]
then
echo "Copying CGI files to /usr/lib/cgi-bin."
cp -ia /usr/lib/httpd/cgi-bin/* /usr/lib/cgi-bin || true
NEED_ECHO=1
fi
if [ -d /usr/lib/httpd ]
then
echo "Directory /usr/lib/httpd is now obsolete, and should be removed."
echo "(Icons are in /usr/share/apache/icons, CGI in /usr/lib/cgi-bin.)"
NEED_ECHO=1
fi
if [ -d /var/log/apache-httpd ]
then
echo 'Copying log files to their new location...'
(cd /var/log/apache-httpd; tar cf - .) |
(cd /var/log/apache; tar xpf -) && rm -rf /var/log/apache-httpd
(cd /var/log/apache; for f in `find . \( -name \*access_log\* -o \
-name \*error_log\* \) -print`; do
new=`echo $f | sed 's,_log$,.log,'`;
if [ "$new" != "$f" -a -f "$new" ]
then
tmpl=$TMPDIR/`basename $new`.$$
cat "$f" "$new" >$tmpl && mv -f "$tmpl" "$new" && rm -f "$f"
else
mv -f $f "`echo $f | sed 's,_log,.log,'`";
fi; done)
NEED_ECHO=1
fi
# Check for log files.
set -- /etc/apache/*.conf
if [ -e $1 ]; then
while [ $# -gt 0 ]; do
CONFS=${CONFS:+$CONFS }$1
set -- "$@" $(awk '$1 ~ /^\s*[Ii]nclude$/ && $2 ~ /^\// {print $2}' $1 | sort -u )
shift
done
SERVERROOT=$(awk '$1 == "ServerRoot" { print $2; exit }' $CONFS)
LOGS=$(awk '$1 ~ /^\s*[A-Za-z]*Log$/ {print $2}' $CONFS | grep -v '|' | sort -u)
BAD_LOG=0
for i in $LOGS; do
# remove quotes from log
i=$(echo $i)
# relative logs are bad
case $i in
/*) ;;
*) BAD_LOG=1; i=$SERVERROOT/$i ;;
esac
i=${i##/var/log/apache/}
case $i in
*/*) BAD_LOG=1 ;;
esac
if [ $BAD_LOG = 1 ]; then
break;
fi
done
if [ $BAD_LOG = 1 ]; then
echo Apache has switched to using logrotate. However, some of your logs
echo are stored outside the /var/log/apache directory, so you should
echo edit /etc/logrotate.d/apache to have them automatically rotated.
NEED_ECHO=1
fi
fi
if [ $NEED_ECHO = 1 ]
then
echo
fi
if [ -f /etc/cron.daily/apache ]; then
rm -f /etc/cron.daily/apache
fi
if [ -f /etc/apache/cron.conf ]; then
rm -f /etc/apache/cron.conf
fi
if grep assert-perl /usr/sbin/apacheconfig > /dev/null 2>&1 \
&& /usr/sbin/apacheconfig --assert-perl > /dev/null 2>&1
then
if ! /usr/sbin/apacheconfig $CONFFLAGS
then
echo
echo -n "Configuration failed! "
echo "Run \"apacheconfig\" to try this again later."
echo
fi
else
echo
echo ERROR: apacheconfig could not be run. It may be the wrong
echo version, or perl may not be fully configured yet. When
echo fixed, run \"dpkg --configure apache\" or \"apacheconfig\".
echo
echo -n "Press Enter to continue: "
read REPLY
echo
exit 1;
fi
# Automatically added by dh_installdocs
if [ "$1" = "configure" ]; then
if [ -d /usr/doc -a ! -e /usr/doc/apache -a -d /usr/share/doc/apache ]; then
ln -sf ../share/doc/apache /usr/doc/apache
fi
fi
/etc/init.d/apache restart || true
exit 0
#FIXME DEBHELPER#
|