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
|
#! /bin/sh
# Source debconf library.
. /usr/share/debconf/confmodule
db_version 2.0
grepconf () {
w=" " # space tab
sq=/etc/squid/squid.conf
# sed is cool.
res=`sed -ne '
s/^'$1'['"$w"']\+\([^'"$w"']\+\).*$/\1/p;
t end;
d;
:end q' < $sq`
[ -n "$res" ] || res=$2
echo "$res"
}
grepconf2 () {
w=" " # space tab
sq=/etc/squid/squid.conf
# sed is cool.
res=`sed -ne '
s/^'$1'['"$w"']\+[^'"$w"']\+['"$w"']\+\([^'"$w"']\+\).*$/\1/p;
t end;
d;
:end q' < $sq`
[ -n "$res" ] || res=$2
echo "$res"
}
#
# Fix old style "cache_dir /var/spool/squid 100 16 256"
# to include "ufs" (Unix File System) after "cache_dir".
#
conf_fix_cache_dir () {
# get value for squid/fix_lines
db_get squid/fix_lines
# handle it!
if [ "$RET" = "true" ] ; then
sed -e 's/^cache_dir\(.*\)$/cache_dir ufs\1/' \
-e 's/^\(dns_children.*\)$/#NOT IN 2.3#\1/' \
-e 's/^\(dns_defnames.*\)$/#NOT IN 2.3#\1/' \
-e 's/^\(cache_dns_program.*\)$/#NOT IN 2.3#\1/' \
< /etc/squid/squid.conf > /etc/squid/squid.conf.TMP && \
mv /etc/squid/squid.conf.TMP /etc/squid/squid.conf
fi
}
#
# The http_anonymizer option doesn't exist anymore.
# Warn the user through debconf.
#
conf_fix_anonymizer () {
w=" " # space tab
if grep -q "^http_anonymizer[$w]*" /etc/squid/squid.conf
then
db_text high squid/http_anonymizer || true
db_go
fi
}
#
# The anonymize_headers and fake_user_agent options don't exist anymore.
# Warn the user through debconf.
#
conf_fix_anonymizer2 () {
w=" " # space tab
if grep -q "^anonymize_headers[$w]*" /etc/squid/squid.conf || grep -q "^fake_user_agent[$w]*" /etc/squid/squid.conf
then
db_text high squid/anonymize_headers || true
db_go
fi
}
#
# We moved from /etc/cron.d/squid to /etc/logrotate.d/squid
#
conf_fix_logrotate () {
c=/etc/cron.daily/squid
if [ -f $c ]
then
##db_text high squid/logrotate || true
##db_go
cp -a $c $c.disabled
( head -1 $c
echo "#"
echo "# DISABLED - squid now uses /etc/logrotate.d/squid"
echo "# please remove this file."
echo "#"
) > $c.disabled
tail +2 $c >> $c.disabled
rm -f $c
fi
}
#
# The authenticate_program option doesn't exist anymore.
# Warn the user through debconf.
#
conf_fix_auth_param () {
w=" " # space tab
if grep -q "^authenticate_program[$w]*" /etc/squid/squid.conf
then
db_text high squid/authenticate_program || true
db_go
fi
}
#
#
#
conf_fix_http_port () {
w=" " # space tab
if ! grep -q "^http_port[$w]*" /etc/squid/squid.conf
then
if grep -q "^# http_port[$w]*" /etc/squid/squid.conf
then
sed -e 's/^# http_port\(.*\)$/http_port\1/' \
< /etc/squid/squid.conf > /etc/squid/squid.conf.TMP && \
mv /etc/squid/squid.conf.TMP /etc/squid/squid.conf
else
echo >> /etc/squid/squid.conf
echo "http_port 3128" >> /etc/squid/squid.conf
fi
fi
}
case "$1" in
configure)
if [ -e /etc/squid/conffile-moved ] ; then
rm /etc/squid/conffile-moved
fi
if [ ! -f /etc/squid/squid.conf ]; then
cp /usr/share/doc/squid/examples/squid.conf \
/etc/squid/squid.conf
chmod 0600 /etc/squid/squid.conf
fi
# Check for old incompatible configs
case "$2" in
2.[12].*)
conf_fix_cache_dir
FIXLINES="$RET"
;;
esac
conf_fix_anonymizer
conf_fix_anonymizer2
conf_fix_logrotate
conf_fix_auth_param
conf_fix_http_port
#
# Chown the directories.
#
dir=`grepconf2 cache_dir /var/spool/squid`
usr=`grepconf cache_effective_user proxy`
grp=`grepconf cache_effective_group proxy`
if [ "$FIXLINES" = "false" ]; then
echo "squid.conf contains 2.2.5 syntax - not doing anything!"
else
if [ "$(/usr/bin/stat -c %U $dir)" != "$usr" ] || [ "$(/usr/bin/stat -c %G $dir)" != "$grp" ] ; then
db_get "squid/fix_cachedir_perms"
if [ "$RET" = "true" ] ; then
chown $usr:$grp $dir -R
fi
db_reset "squid/fix_cachedir_perms"
fi
if [ "$(/usr/bin/stat -c %U /var/log/squid)" != "$usr" ] || [ "$(/usr/bin/stat -c %G /var/log/squid)" != "$grp" ] ; then
# Check if there is an override of ownership
if [ "$(/usr/sbin/dpkg-statoverride --list /var/log/squid)" = "" ] ; then
chown $usr:$grp /var/log/squid -R
fi
fi
fi
#
# Create spool dirs if they don't exist.
#
if [ -d "$dir" -a ! -d "$dir/00" ]
then
echo "Creating squid spool directory structure"
/usr/sbin/squid -z
fi
#
# Install /etc/default/squid file if it doesn't
# exist yet.
#
if [ ! -f /etc/default/squid ]
then
cp /usr/share/doc/squid/examples/default.squid \
/etc/default/squid
chmod 644 /etc/default/squid
fi
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
*)
#
# Unknown action - do nothing.
#
exit 0
;;
esac
db_stop
#
# Update links if needed and start squid.
#
update-rc.d squid defaults 30 >/dev/null
cd /
if [ "$FIXLINES" = "false" ]; then
echo "squid.conf contains 2.2.5 syntax - cache_dir directive - not starting "
echo "Run 'dpkg-reconfigure -plow squid' to fix this automatically,"
echo "or fix the 'cache_dir'-entry in your squid.conf manually."
echo "See documentation in /usr/share/doc/squid for nearer instructions."
else
invoke-rc.d squid restart
fi
|