name change
[privoxy.git] / junkbusterng.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.15  2002/03/09 15:05:58  swa
37 #     wrong user.group
38 #
39 #     Revision 1.14  2002/03/06 06:13:40  hal9
40 #     Adapted for Andreas' changes for --user and --pidfile.
41 #
42 #     Revision 1.13  2002/03/05 05:10:10  oes
43 #     Changed pidfile path to conform with FHS
44 #
45 #     Revision 1.12  2002/03/04 20:44:36  oes
46 #     Changed to new cmdline syntax
47 #
48 #     Revision 1.11  2001/12/30 14:07:32  steudten
49 #     - Add signal handling (unix)
50 #     - Add SIGHUP handler (unix)
51 #     - Add creation of pidfile (unix)
52 #     - Add action 'top' in rc file (RH)
53 #     - Add entry 'SIGNALS' to manpage
54 #     - Add exit message to logfile (unix)
55 #
56 #     Revision 1.10  2001/11/05 21:30:23  steudten
57 #     Make JB startup without & due to be a 'real' daemon right now.
58 #     Make the script easy to change.
59 #
60 #     Revision 1.9  2001/09/15 01:53:12  steudten
61 #
62 #     Remove test for subsys flag in start. Some minor changes.
63 #
64 #     Revision 1.8  2001/06/28 13:50:36  sarantis
65 #     swap ?$ with $?; remove bogus ";;"
66 #
67 #     Revision 1.7  2001/06/28 13:40:26  sarantis
68 #     remove single quotes from $JB; it was not expanded.
69 #
70 #     Revision 1.6  2001/06/28 13:38:42  sarantis
71 #     formatting changes; individual return values are returned from the init script.
72 #
73 #     Revision 1.5  2001/06/11 11:37:40  sarantis
74 #     Minor editing changes.
75 #
76 #     Revision 1.4  2001/06/09 09:14:11  swa
77 #     shamelessly adapted RPM stuff from the newest rpm that
78 #     RedHat provided for the JB.
79 #
80 #     Revision 1.3  2001/05/25 10:12:44  oes
81 #     Fixed default case in switch statement (# -> *)
82 #
83 #     Revision 1.2  2001/05/24 07:52:24  swa
84 #     added header. removed ^M.
85 #
86
87 # ********************************************************************/
88
89 # This is file /etc/rc.d/init.d/junkbuster and was put here 
90 # by the junkbuster rpm
91 #
92 # chkconfig: 235 84 09
93 #
94 # description: This shell script takes care of starting and stopping \
95 #              junkbuster.
96 #
97
98
99 # Source function library.
100 . /etc/rc.d/init.d/functions
101
102 . /etc/sysconfig/network
103
104 #  Check that networking is up.
105 [ ${NETWORKING} = "no" ] && exit 0
106
107 JB_OPRG="junkbuster"
108 JB_PRG="jbng"
109 JB_BIN="/usr/sbin/$JB_PRG"
110 JB_CONF="/etc/$JB_OPRG/config"
111 JB_USER="junkbuster"
112 JB_PID=/var/run/$JB_PRG.pid
113 JB_LOCK=/var/lock/subsys/$JB_PRG
114 JB="$JB_BIN --user $JB_USER.$JB_USER --pidfile $JB_PID $JB_CONF"
115
116 # some checks for us
117 ! [ -x $JB_BIN  ] && echo "Can't find $JB_BIN, exit." && exit 0
118 ! [ -f $JB_CONF ] && echo "Can't find $JB_CONF, exit." && exit 0
119
120 # See how we were called.
121
122 start () {
123         # start daemon
124         echo -n $"Starting $JB_PRG: "
125      if [ -f $JB_PID ]; then 
126         killproc $JB_PRG && rm -f $JB_LOCK $JB_PID
127         RETVAL=$?
128         [ $RETVAL != 0 ] && return $RETVAL
129      fi
130         daemon $JB 
131         RETVAL=$?
132         echo
133         [ $RETVAL = 0 ] && touch $JB_LOCK
134         return $RETVAL
135 }
136
137 stop () {
138         # stop daemon
139         echo -n $"Stopping $JB_PRG: "
140         killproc $JB_PRG && rm -f $JB_LOCK $JB_PID
141         RETVAL=$?
142         echo
143         return $RETVAL
144 }
145
146 case "$1" in
147   start)
148         start   
149         ;;
150   stop)
151         stop
152         ;;
153   reload)
154         if [ -f $JB_PID ] ; then
155         kill -HUP `cat $JB_PID`
156         RETVAL=$?
157      fi
158         ;;
159   restart)
160         stop
161         start
162         RETVAL=$?
163         ;;
164   condrestart)
165         # restart only if already running
166         if [ -f $JB_PID ] ; then
167         stop
168         start
169         RETVAL=$?
170         fi 
171         ;;
172   status)
173         status $JB_PRG 
174         RETVAL=$?
175         ;;
176   top)
177      if [ -f $JB_PID ]; then
178                 a=""
179                 for i in `pidof $JB_PRG` ; do
180                         a="$a -p $i"
181                 done
182                 top $a
183      fi
184         ;;
185   *)
186         echo $"Usage: $JB_PRG {start|stop|reload|restart|condrestart|status|top}"
187         exit 1
188 esac
189
190 exit $RETVAL