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