2000-07-05 14:37:06 +02:00
|
|
|
#!/bin/sh
|
2004-01-16 22:18:20 +01:00
|
|
|
#
|
|
|
|
# $FreeBSD$
|
|
|
|
#
|
2004-09-02 08:44:14 +02:00
|
|
|
# --begin rcng
|
2004-01-16 22:18:20 +01:00
|
|
|
# PROVIDE: squid
|
|
|
|
# REQUIRE: NETWORKING SERVERS
|
|
|
|
# BEFORE: DAEMON
|
2004-07-25 18:30:43 +02:00
|
|
|
# KEYWORD: FreeBSD shutdown
|
2004-01-16 22:18:20 +01:00
|
|
|
#
|
|
|
|
# Note:
|
2004-09-02 08:44:14 +02:00
|
|
|
# Set "squid_enable=yes" in either /etc/rc.conf, /etc/rc.conf.local or
|
2004-01-16 22:18:20 +01:00
|
|
|
# /etc/rc.conf.d/squid to make this script actually do something. There
|
|
|
|
# you can also set squid_chdir, squid_user, and squid_flags.
|
|
|
|
#
|
|
|
|
# Please see squid(8), rc.conf(5) and rc(8) for further details.
|
2004-09-02 08:44:14 +02:00
|
|
|
#
|
|
|
|
# --end rcng
|
2000-07-05 14:37:06 +02:00
|
|
|
|
2004-09-02 08:44:14 +02:00
|
|
|
name=squid
|
2004-01-16 22:18:20 +01:00
|
|
|
command=%%PREFIX%%/sbin/squid
|
2004-09-02 08:44:14 +02:00
|
|
|
# --begin rcng
|
2004-01-16 22:18:20 +01:00
|
|
|
extra_commands=reload
|
|
|
|
reload_cmd="${command} -k reconfigure"
|
2004-09-02 08:44:14 +02:00
|
|
|
# --end rcng
|
2004-10-13 11:43:48 +02:00
|
|
|
stop_cmd="squid_stop"
|
2004-06-10 17:40:44 +02:00
|
|
|
squid_chdir=${squid_chdir:-%%PREFIX%%/squid/logs}
|
2004-07-25 18:30:43 +02:00
|
|
|
squid_enable=${squid_enable:-"NO"}
|
2004-07-28 04:10:54 +02:00
|
|
|
squid_flags=${squid_flags-"-D"}
|
2004-07-25 18:30:43 +02:00
|
|
|
squid_user=${squid_user:-%%SQUID_UID%%}
|
2004-01-16 22:18:20 +01:00
|
|
|
default_config=%%PREFIX%%/etc/squid/squid.conf
|
2000-07-05 14:37:06 +02:00
|
|
|
|
2004-10-13 11:43:48 +02:00
|
|
|
# --begin rcold
|
|
|
|
squid_stop() {
|
|
|
|
echo -n " ${name}"
|
|
|
|
${command} -k shutdown
|
|
|
|
while ps -xcU ${squid_user} | grep -q squid; do
|
|
|
|
sleep 2
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
# --end rcold
|
2004-09-02 08:44:14 +02:00
|
|
|
# --begin rcng
|
2004-10-13 11:43:48 +02:00
|
|
|
squid_stop() {
|
|
|
|
${command} -k shutdown
|
2004-09-02 08:44:14 +02:00
|
|
|
run_rc_command poll
|
|
|
|
}
|
|
|
|
|
|
|
|
. %%RC_SUBR%%
|
|
|
|
rcvar=`set_rcvar`
|
|
|
|
load_rc_config ${name}
|
|
|
|
|
|
|
|
# squid(8) will not start if ${default_config} is not present so try
|
|
|
|
# to catch that beforehand via ${required_files} rather than make
|
|
|
|
# squid(8) crash.
|
|
|
|
# If you remove the default configuration file make sure to add
|
|
|
|
# '-f /path/to/your/squid.conf' to squid_flags
|
|
|
|
|
|
|
|
if [ -z "${squid_flags}" ]; then
|
|
|
|
required_files=${default_config}
|
2004-01-16 22:18:20 +01:00
|
|
|
fi
|
2004-09-02 08:44:14 +02:00
|
|
|
required_dirs=${squid_chdir}
|
|
|
|
run_rc_command "$1"
|
|
|
|
# --end rcng
|
|
|
|
# --begin rcold
|
|
|
|
case $1 in
|
|
|
|
start)
|
|
|
|
if [ -x "${command}" -a \
|
|
|
|
\( -f "${default_config}" -o "${squid_flags}" \) ]; then
|
|
|
|
echo -n " ${name}"
|
|
|
|
(cd ${squid_chdir} && exec su -fm ${squid_user} -c \
|
|
|
|
"${command} ${squid_flags}")
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
if [ -x "${command}" ]; then
|
|
|
|
${stop_cmd}
|
|
|
|
fi
|
|
|
|
;;
|
2004-10-13 11:43:48 +02:00
|
|
|
*)
|
2004-09-02 08:44:14 +02:00
|
|
|
echo "usage: ${0##*/} {start|stop}" >&2
|
|
|
|
exit 64
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
exit 0
|
|
|
|
# --end rcold
|