Package: squid
Version: 2.7.STABLE3-4.1
Severity: wishlist
Tags: patch
If in squid.conf the location of the pid-file is non standard, squid will not
restart and the
logrotate will not work correctly.
I propose to move some parameters form the start-stop script to
/etc/default/squid.
1. Add to /etc/default/squid:
...
NAME="squid"
SQUID_CONF="/etc/squid/squid.conf"
SQUID_ARGS="-D -YC -f ${SQUID_CONF}"
PIDFILE=$(awk '\
BEGIN { FS=" "; pidfile=sprintf("/var/run/%s.pid", NAME) }
$0 ~ /^pid_filename/ { pidfile=sprintf("%s", $2) }
END { print pidfile} ' $SQUID_CONF)
SQUID_UID=$(awk '\
BEGIN { FS=" "; squid_uid="proxy" }
$0 ~ /^cache_effective_user/ { squid_uid=sprintf("%s", $2) }
END { print squid_uid} ' $SQUID_CONF)
SQUID_GID=$(awk '\
BEGIN { FS=" "; squid_gid="proxy" }
$0 ~ /^cache_effective_group/ { squid_gid=sprintf("%s", $2) }
END { print squid_gid} ' $SQUID_CONF)
2. Change /etc/init.d/squid to
DAEMON=/usr/sbin/squid
LIB=/usr/lib/squid
[ ! -f /etc/default/squid ] || . /etc/default/squid
. /lib/lsb/init-functions
3. Change /etc/logrotate.d/squid to
...
postrotate
if [ -f "`. /etc/default/squid ; echo ${PIDFILE:-/var/run/squid.pid}`" ]
then
/usr/sbin/squid -k rotate
fi
endscript
Additional wishes:
With SQUID_UID en SQUID_GID it is possible to check permissions of the logfile,
the cache
and other files
-- System Information:
Debian Release: 5.0
APT prefers stable
APT policy: (500, 'stable')
Architecture: i386 (i686)
Kernel: Linux 2.6.26-1-686-bigmem (SMP w/8 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
Versions of packages squid depends on:
ii adduser 3.110 add and remove users and groups
ii debconf [debconf-2.0] 1.5.24 Debian configuration management sy
ii libc6 2.7-18 GNU C Library: Shared libraries
ii libcomerr2 1.41.3-1 common error description library
ii libdb4.6 4.6.21-11 Berkeley v4.6 Database Libraries [
ii libkrb53 1.6.dfsg.4~beta1-5 MIT Kerberos runtime libraries
ii libldap-2.4-2 2.4.11-1 OpenLDAP libraries
ii libpam0g 1.0.1-5 Pluggable Authentication Modules l
ii logrotate 3.7.1-5 Log rotation utility
ii lsb-base 3.2-20 Linux Standard Base 3.2 init scrip
ii netbase 4.34 Basic TCP/IP networking system
ii squid-common 2.7.STABLE3-4.1 Internet object cache (WWW proxy c
squid recommends no packages.
Versions of packages squid suggests:
pn logcheck-database <none> (no description available)
pn resolvconf <none> (no description available)
ii smbclient 2:3.2.5-4 a LanManager-like simple client fo
ii squid-cgi 2.7.STABLE3-4.1 Squid cache manager CGI program
pn squidclient <none> (no description available)
pn winbind <none> (no description available)
-- debconf information:
squid/fix_cachedir_perms: false
squid/fix_lines: true
#! /bin/sh
#
# squid Startup script for the SQUID HTTP proxy-cache.
#
# Version: @(#)squid.rc 2.20 01-Oct-2001 [email protected]
#
### BEGIN INIT INFO
# Provides: squid
# Required-Start: $local_fs $network
# Required-Stop: $local_fs $network
# Should-Start: $named
# Should-Stop: $named
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Squid HTTP Proxy
### END INIT INFO
DAEMON=/usr/sbin/squid
LIB=/usr/lib/squid
[ ! -f /etc/default/squid ] || . /etc/default/squid
. /lib/lsb/init-functions
PATH=/bin:/usr/bin:/sbin:/usr/sbin
[ -x $DAEMON ] || exit 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=${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"
}
#
# Try to increase the # of filedescriptors we can open.
#
maxfds () {
[ -n "$SQUID_MAXFD" ] || return
[ -f /proc/sys/fs/file-max ] || return 0
global_file_max=`cat /proc/sys/fs/file-max`
minimal_file_max=$(($SQUID_MAXFD + 4096))
if [ "$global_file_max" -lt $minimal_file_max ]
then
echo $minimal_file_max > /proc/sys/fs/file-max
fi
ulimit -n $SQUID_MAXFD
}
start () {
cdr=`grepconf2 cache_dir /var/spool/$NAME`
ctp=`grepconf cache_dir ufs`
case "$cdr" in
[0-9]*)
log_failure_msg "squid: squid.conf contains 2.2.5 syntax - not starting!"
log_end_msg 1
exit 1
;;
esac
#
# Create spool dirs if they don't exist.
#
if [ -d "$cdr" -a ! -d "$cdr/00" ] || [ "$ctp" = "coss" -a ! -f "$cdr" ]
then
log_warning_msg "Creating squid cache structure"
$DAEMON $SQUID_ARGS -z
fi
if [ "$CHUID" = "" ]; then
CHUID=root
fi
maxfds
umask 027
start-stop-daemon --quiet --start \
--pidfile $PIDFILE \
--chuid $CHUID \
--exec $DAEMON -- $SQUID_ARGS < /dev/null
return $?
}
stop () {
PID=`cat $PIDFILE 2>/dev/null`
start-stop-daemon --stop --quiet --pidfile $PIDFILE --name squid
#
# Now we have to wait until squid has _really_ stopped.
#
sleep 2
if test -n "$PID" && kill -0 $PID 2>/dev/null
then
log_action_begin_msg " Waiting"
cnt=0
while kill -0 $PID 2>/dev/null
do
cnt=`expr $cnt + 1`
if [ $cnt -gt 24 ]
then
log_action_end_msg 1
return 1
fi
sleep 5
log_action_cont_msg ""
done
log_action_end_msg 0
return 0
else
return 0
fi
}
case "$1" in
start)
log_daemon_msg "Starting Squid HTTP proxy" "squid"
if start ; then
log_end_msg $?
else
log_end_msg $?
fi
;;
stop)
log_daemon_msg "Stopping Squid HTTP proxy" "squid"
if stop ; then
log_end_msg $?
else
log_end_msg $?
fi
;;
reload|force-reload)
log_action_msg "Reloading Squid configuration files"
$DAEMON -k reconfigure
log_action_end_msg 0
;;
restart)
log_daemon_msg "Restarting Squid HTTP proxy" "squid"
stop
if start ; then
log_end_msg $?
else
log_end_msg $?
fi
;;
status)
status_of_proc -p "$PIDFILE" "$DAEMON" squid && exit 0 || exit $?
;;
*)
echo "Usage: /etc/init.d/$NAME {start|stop|reload|force-reload|restart|status}"
exit 3
;;
esac
exit 0