Splitting off bind_port() call into bind_port_helper(), with
[privoxy.git] / junkbuster.init
1 #!/bin/sh
2 #  ********************************************************************
3
4 #  File        :  $Source: /cvsroot/ijbswa/current/junkbuster.init,v $
5
6 #  Purpose     :  This shell script takes care of starting and stopping
7 #                 junkbuster.
8
9 #  Copyright   :  Written by and Copyright (C) 2001 the SourceForge
10 #                 IJBSWA team.  http://ijbswa.sourceforge.net
11
12 #                 Based on the Internet Junkbuster originally written
13 #                 by and Copyright (C) 1997 Anonymous Coders and
14 #                 Junkbusters Corporation.  http://www.junkbusters.com
15
16 #                 This program is free software; you can redistribute it
17 #                 and/or modify it under the terms of the GNU General
18 #                 Public License as published by the Free Software
19 #                 Foundation; either version 2 of the License, or (at
20 #                 your option) any later version.
21
22 #                 This program is distributed in the hope that it will
23 #                 be useful, but WITHOUT ANY WARRANTY; without even the
24 #                 implied warranty of MERCHANTABILITY or FITNESS FOR A
25 #                 PARTICULAR PURPOSE.  See the GNU General Public
26 #                 License for more details.
27
28 #                 The GNU General Public License should be included with
29 #                 this file.  If not, you can view it at
30 #                 http://www.gnu.org/copyleft/gpl.html
31 #                 or write to the Free Software Foundation, Inc., 59
32 #                 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
33
34 #  Revisions   :
35 #     $Log: junkbuster.init,v $
36 #     Revision 1.11  2001/12/30 14:07:32  steudten
37 #     - Add signal handling (unix)
38 #     - Add SIGHUP handler (unix)
39 #     - Add creation of pidfile (unix)
40 #     - Add action 'top' in rc file (RH)
41 #     - Add entry 'SIGNALS' to manpage
42 #     - Add exit message to logfile (unix)
43 #
44 #     Revision 1.10  2001/11/05 21:30:23  steudten
45 #     Make JB startup without & due to be a 'real' daemon right now.
46 #     Make the script easy to change.
47 #
48 #     Revision 1.9  2001/09/15 01:53:12  steudten
49 #
50 #     Remove test for subsys flag in start. Some minor changes.
51 #
52 #     Revision 1.8  2001/06/28 13:50:36  sarantis
53 #     swap ?$ with $?; remove bogus ";;"
54 #
55 #     Revision 1.7  2001/06/28 13:40:26  sarantis
56 #     remove single quotes from $JB; it was not expanded.
57 #
58 #     Revision 1.6  2001/06/28 13:38:42  sarantis
59 #     formatting changes; individual return values are returned from the init script.
60 #
61 #     Revision 1.5  2001/06/11 11:37:40  sarantis
62 #     Minor editing changes.
63 #
64 #     Revision 1.4  2001/06/09 09:14:11  swa
65 #     shamelessly adapted RPM stuff from the newest rpm that
66 #     RedHat provided for the JB.
67 #
68 #     Revision 1.3  2001/05/25 10:12:44  oes
69 #     Fixed default case in switch statement (# -> *)
70 #
71 #     Revision 1.2  2001/05/24 07:52:24  swa
72 #     added header. removed ^M.
73 #
74
75 # ********************************************************************/
76
77 # This is file /etc/rc.d/init.d/junkbuster and was put here 
78 # by the junkbuster rpm
79 #
80 # chkconfig: 235 84 09
81 #
82 # description: This shell script takes care of starting and stopping \
83 #              junkbuster.
84 #
85
86
87 # Source function library.
88 . /etc/rc.d/init.d/functions
89
90 . /etc/sysconfig/network
91
92 #  Check that networking is up.
93 [ ${NETWORKING} = "no" ] && exit 0
94
95 JB_PRG="junkbuster"
96 JB_BIN="/usr/sbin/$JB_PRG"
97 JB_CONF="/etc/$JB_PRG/config"
98 JB_USER="junkbuster"
99 JB_PID="/etc/junkbuster"/$JB_PRG.pid
100
101 # some checks for us
102 [ -x $JB_BIN  ] || exit 0
103 [ -f $JB_CONF ] || exit 0
104
105 # See how we were called.
106
107 JB="$JB_BIN $JB_CONF"
108
109 start () {
110         # start daemon
111         echo -n $"Starting $JB_PRG: "
112         daemon --user $JB_USER $JB --pidfile $JB_PID
113         RETVAL=$?
114         echo
115         [ $RETVAL = 0 ] && touch /var/lock/subsys/$JB_PRG
116         return $RETVAL
117 }
118
119 stop () {
120         # stop daemon
121         echo -n $"Stopping $JB_PRG: "
122         killproc $JB_PRG && rm -f /var/lock/subsys/$JB_PRG $JB_PID
123         RETVAL=$?
124         echo
125         return $RETVAL
126 }
127
128 case "$1" in
129   start)
130         start   
131         ;;
132   stop)
133         stop    
134         ;;
135   reload)
136         if [ -f $JB_PID ] ; then
137                 kill -HUP `cat $JB_PID`
138                 RETVAL=$?
139         fi
140         ;;
141   restart)
142         stop
143         start
144         RETVAL=$?
145         ;;
146   condrestart)
147         # restart only if already running
148         if [ -f $JB_PID ] ; then
149                 stop
150                 start
151                 RETVAL=$?
152         fi 
153         ;;
154   status)
155         status $JB_PRG 
156         RETVAL=$?
157         ;;
158   top)
159         if [ -f $JB_PID ]; then
160                 a=""
161                 for i in `pidof $JB_PRG` ; do
162                         a="$a -p $i"
163                 done
164                 top $a
165         fi
166         ;;
167   *)
168         echo $"Usage: $JB_PRG {start|stop|reload|restart|condrestart|status|top}"
169         exit 1
170 esac
171
172 exit $RETVAL