pkgsrc/www/squid3/files/squid.sh
sborrill 8c917608f4 Check current file descriptor limit and raise if required rather than
blindly setting to 4096 (which may in fact be lower than current limit).
Bump PKGREVISION
2015-10-08 10:07:10 +00:00

75 lines
1.5 KiB
Bash

#!@RCD_SCRIPTS_SHELL@
#
# $NetBSD: squid.sh,v 1.3 2015/10/08 10:07:10 sborrill Exp $
#
# PROVIDE: squid
# REQUIRE: DAEMON
# KEYWORD: shutdown
if [ -f /etc/rc.subr ]; then
. /etc/rc.subr
fi
: ${squid_conf:=@PKG_SYSCONFDIR@/squid.conf}
name="squid"
rcvar=$name
command="@PREFIX@/sbin/${name}"
pidfile="@VARBASE@/run/${name}.pid"
procname="squid-1"
required_files="${squid_conf} @PKG_SYSCONFDIR@/mime.conf"
command_args="-Y -f ${squid_conf}"
start_precmd='setproclimits'
setproclimits()
{
local climit
climit=`ulimit -n`
if [ "$climit" -lt 4096 ]; then
ulimit -n 4096
fi
}
# Note: 'shutdown' waits 30 seconds, while 'interrupt' stops immediately
reload_cmd="${command} ${squid_flags} ${command_args} -k reconfigure"
rotate_cmd="${command} ${squid_flags} ${command_args} -k rotate"
createdirs_cmd="${command} ${squid_flags} ${command_args} -z"
extra_commands="createdirs reload rotate"
if [ -f /etc/rc.subr -a -f /etc/rc.conf -a -f /etc/rc.d/DAEMON ]; then
load_rc_config $name
run_rc_command "$1"
else
if [ -f /etc/rc.conf ]; then
. /etc/rc.conf
fi
case $1 in
start)
start_cmd="${command} ${squid_flags} ${command_args}"
if [ -x ${command} -a -f ${squid_conf} ] ; then
${start_cmd}
fi
;;
stop)
${stop_cmd}
;;
createdirs)
${createdirs_cmd}
;;
reload)
if [ -r "${pidfile}" ] ; then
${reload_cmd}
fi
;;
rotate)
if [ -r "${pidfile}" ] ; then
${rotate_cmd}
fi
;;
*)
@ECHO@ "Usage: $0 {start|stop|reload|rotate|createdirs}" 1>&2
exit 64
;;
esac
fi