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