| @@ -1,36 +1,41 @@ | | | @@ -1,36 +1,41 @@ |
1 | #!@RCD_SCRIPTS_SHELL@ | | 1 | #!@RCD_SCRIPTS_SHELL@ |
2 | # | | 2 | # |
3 | # $NetBSD: squid.sh,v 1.20 2008/01/31 20:01:13 adam Exp $ | | 3 | # $NetBSD: squid.sh,v 1.21 2008/03/11 15:46:41 taca Exp $ |
4 | # | | 4 | # |
5 | | | 5 | |
6 | # PROVIDE: squid | | 6 | # PROVIDE: squid |
7 | # REQUIRE: DAEMON | | 7 | # REQUIRE: DAEMON |
8 | # KEYWORD: shutdown | | 8 | # KEYWORD: shutdown |
9 | | | 9 | |
10 | conf_file="@PKG_SYSCONFDIR@/squid.conf" | | 10 | if [ -f /etc/rc.subr ]; then |
| | | 11 | . /etc/rc.subr |
| | | 12 | fi |
| | | 13 | |
| | | 14 | : ${squid_conf:=@PKG_SYSCONFDIR@/squid.conf} |
11 | | | 15 | |
12 | name="squid" | | 16 | name="squid" |
13 | rcvar=$name | | 17 | rcvar=$name |
14 | command="@PREFIX@/sbin/${name}" | | 18 | command="@PREFIX@/sbin/${name}" |
15 | pidfile="@VARBASE@/run/${name}.pid" | | 19 | pidfile="@VARBASE@/run/${name}.pid" |
16 | required_files="${conf_file} @PKG_SYSCONFDIR@/mime.conf" | | 20 | required_files="${squid_conf} @PKG_SYSCONFDIR@/mime.conf" |
17 | command_args="-Y -f $conf_file" | | 21 | command_args="-Y -f ${squid_conf}" |
18 | | | 22 | |
19 | stop_cmd="stop_nicely" | | 23 | stop_cmd="stop_nicely" |
20 | kill_command="${command} -k shutdown" | | 24 | kill_command="${command} ${squid_flags} ${command_args} -k shutdown" |
21 | reload_cmd="${command} -k reconfigure" | | 25 | reload_cmd="${command} ${squid_flags} ${command_args} -k reconfigure" |
22 | rotate_cmd="${command} -k rotate" | | 26 | rotate_cmd="${command} ${squid_flags} ${command_args} -k rotate" |
23 | createdirs_cmd="squid_createdirs" | | 27 | createdirs_cmd="${command} ${squid_flags} ${command_args} -z" |
| | | 28 | extra_commands="createdirs reload rotate" |
24 | | | 29 | |
25 | #### end of configuration section #### | | 30 | #### end of configuration section #### |
26 | | | 31 | |
27 | # XXX Shouldn't the default stop_cmd be this patient too? | | 32 | # XXX Shouldn't the default stop_cmd be this patient too? |
28 | # | | 33 | # |
29 | stop_nicely () | | 34 | stop_nicely () |
30 | { | | 35 | { |
31 | if [ -f ${pidfile} ] ; then | | 36 | if [ -f ${pidfile} ] ; then |
32 | DAEMON_PID=`sed 1q ${pidfile}` | | 37 | DAEMON_PID=`sed 1q ${pidfile}` |
33 | @ECHO@ -n "Stopping ${name}" | | 38 | @ECHO@ -n "Stopping ${name}" |
34 | ${kill_command} | | 39 | ${kill_command} |
35 | if [ ${DAEMON_PID} -ne 0 ]; then | | 40 | if [ ${DAEMON_PID} -ne 0 ]; then |
36 | @ECHO@ -n '[' | | 41 | @ECHO@ -n '[' |
| @@ -41,58 +46,49 @@ stop_nicely () | | | @@ -41,58 +46,49 @@ stop_nicely () |
41 | @ECHO@ -n '.' | | 46 | @ECHO@ -n '.' |
42 | test $WAIT -lt 15 || kill ${DAEMON_PID} | | 47 | test $WAIT -lt 15 || kill ${DAEMON_PID} |
43 | else | | 48 | else |
44 | break | | 49 | break |
45 | fi | | 50 | fi |
46 | done | | 51 | done |
47 | @ECHO@ '].' | | 52 | @ECHO@ '].' |
48 | unset WAIT | | 53 | unset WAIT |
49 | fi | | 54 | fi |
50 | unset DAEMON_PID | | 55 | unset DAEMON_PID |
51 | fi | | 56 | fi |
52 | } | | 57 | } |
53 | | | 58 | |
54 | # create the squid cache directories | | 59 | if [ -f /etc/rc.subr -a -f /etc/rc.conf -a -f /etc/rc.d/DAEMON ]; then |
55 | squid_createdirs() | | | |
56 | { | | | |
57 | ${command} -z | | | |
58 | } | | | |
59 | | | | |
60 | if [ -f /etc/rc.subr -a -d /etc/rc.d -a -f /etc/rc.d/DAEMON ]; then | | | |
61 | . /etc/rc.subr | | | |
62 | . /etc/rc.conf | | | |
63 | | | | |
64 | extra_commands="createdirs reload rotate" | | | |
65 | load_rc_config $name | | 60 | load_rc_config $name |
66 | run_rc_command "$1" | | 61 | run_rc_command "$1" |
67 | | | | |
68 | else # old NetBSD, Solaris, Linux, etc... | | 62 | else # old NetBSD, Solaris, Linux, etc... |
69 | | | 63 | if [ -f /etc/rc.conf ]; then |
| | | 64 | . /etc/rc.conf |
| | | 65 | fi |
70 | case $1 in | | 66 | case $1 in |
71 | start) | | 67 | start) |
72 | if [ -x ${command} -a -f ${conf_file} ] ; then | | 68 | start_cmd="${command} ${squid_flags} ${command_args}" |
| | | 69 | if [ -x ${command} -a -f ${squid_conf} ] ; then |
73 | eval ${start_cmd} && @ECHO@ -n " ${name}" | | 70 | eval ${start_cmd} && @ECHO@ -n " ${name}" |
74 | fi | | 71 | fi |
75 | ;; | | 72 | ;; |
76 | stop) | | 73 | stop) |
77 | ${stop_cmd} | | 74 | ${stop_cmd} |
78 | ;; | | 75 | ;; |
79 | createdirs) | | 76 | createdirs) |
80 | squid_createdirs | | 77 | ${createdirs_cmd} |
81 | ;; | | 78 | ;; |
82 | reload) | | 79 | reload) |
83 | if [ -f ${pidfile} ] ; then | | 80 | if [ -f ${pidfile} ] ; then |
84 | ${reload_cmd} | | 81 | ${reload_cmd} |
85 | fi | | 82 | fi |
86 | ;; | | 83 | ;; |
87 | rotate) | | 84 | rotate) |
88 | if [ -f ${pidfile} ] ; then | | 85 | if [ -f ${pidfile} ] ; then |
89 | ${rotate_cmd} | | 86 | ${rotate_cmd} |
90 | fi | | 87 | fi |
91 | ;; | | 88 | ;; |
92 | *) | | 89 | *) |
93 | @ECHO@ "Usage: $0 {start|stop|reload|createdirs}" 1>&2 | | 90 | @ECHO@ "Usage: $0 {start|stop|reload|createdirs}" 1>&2 |
94 | exit 64 | | 91 | exit 64 |
95 | ;; | | 92 | ;; |
96 | esac | | 93 | esac |
97 | | | | |
98 | fi | | 94 | fi |