| @@ -1,36 +1,46 @@ | | | @@ -1,36 +1,46 @@ |
1 | #!@RCD_SCRIPTS_SHELL@ | | 1 | #!@RCD_SCRIPTS_SHELL@ |
2 | # | | 2 | # |
3 | # $NetBSD: squid.sh,v 1.2 2014/08/29 11:13:46 tron Exp $ | | 3 | # $NetBSD: squid.sh,v 1.3 2015/10/08 10:07:10 sborrill Exp $ |
4 | # | | 4 | # |
5 | # PROVIDE: squid | | 5 | # PROVIDE: squid |
6 | # REQUIRE: DAEMON | | 6 | # REQUIRE: DAEMON |
7 | # KEYWORD: shutdown | | 7 | # KEYWORD: shutdown |
8 | | | 8 | |
9 | if [ -f /etc/rc.subr ]; then | | 9 | if [ -f /etc/rc.subr ]; then |
10 | . /etc/rc.subr | | 10 | . /etc/rc.subr |
11 | fi | | 11 | fi |
12 | | | 12 | |
13 | : ${squid_conf:=@PKG_SYSCONFDIR@/squid.conf} | | 13 | : ${squid_conf:=@PKG_SYSCONFDIR@/squid.conf} |
14 | | | 14 | |
15 | name="squid" | | 15 | name="squid" |
16 | rcvar=$name | | 16 | rcvar=$name |
17 | command="@PREFIX@/sbin/${name}" | | 17 | command="@PREFIX@/sbin/${name}" |
18 | pidfile="@VARBASE@/run/${name}.pid" | | 18 | pidfile="@VARBASE@/run/${name}.pid" |
19 | procname="squid-1" | | 19 | procname="squid-1" |
20 | required_files="${squid_conf} @PKG_SYSCONFDIR@/mime.conf" | | 20 | required_files="${squid_conf} @PKG_SYSCONFDIR@/mime.conf" |
21 | command_args="-Y -f ${squid_conf}" | | 21 | command_args="-Y -f ${squid_conf}" |
22 | | | 22 | |
23 | start_precmd='ulimit -n 4096' | | 23 | start_precmd='setproclimits' |
| | | 24 | |
| | | 25 | setproclimits() |
| | | 26 | { |
| | | 27 | local climit |
| | | 28 | climit=`ulimit -n` |
| | | 29 | if [ "$climit" -lt 4096 ]; then |
| | | 30 | ulimit -n 4096 |
| | | 31 | fi |
| | | 32 | } |
| | | 33 | |
24 | # Note: 'shutdown' waits 30 seconds, while 'interrupt' stops immediately | | 34 | # Note: 'shutdown' waits 30 seconds, while 'interrupt' stops immediately |
25 | reload_cmd="${command} ${squid_flags} ${command_args} -k reconfigure" | | 35 | reload_cmd="${command} ${squid_flags} ${command_args} -k reconfigure" |
26 | rotate_cmd="${command} ${squid_flags} ${command_args} -k rotate" | | 36 | rotate_cmd="${command} ${squid_flags} ${command_args} -k rotate" |
27 | createdirs_cmd="${command} ${squid_flags} ${command_args} -z" | | 37 | createdirs_cmd="${command} ${squid_flags} ${command_args} -z" |
28 | extra_commands="createdirs reload rotate" | | 38 | extra_commands="createdirs reload rotate" |
29 | | | 39 | |
30 | if [ -f /etc/rc.subr -a -f /etc/rc.conf -a -f /etc/rc.d/DAEMON ]; then | | 40 | if [ -f /etc/rc.subr -a -f /etc/rc.conf -a -f /etc/rc.d/DAEMON ]; then |
31 | load_rc_config $name | | 41 | load_rc_config $name |
32 | run_rc_command "$1" | | 42 | run_rc_command "$1" |
33 | else | | 43 | else |
34 | if [ -f /etc/rc.conf ]; then | | 44 | if [ -f /etc/rc.conf ]; then |
35 | . /etc/rc.conf | | 45 | . /etc/rc.conf |
36 | fi | | 46 | fi |