04bdfded2e420aa5b8135749ad6898afb9775e53
[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 #                 This works only correctly if the user `nobody' is allowed
9 #                 to be in the directory where this file is called 
10 #                 (for example: /root is NOT ok)
11
12 #  Copyright   :  Written by and Copyright (C) 2001 the SourceForge
13 #                 IJBSWA team.  http://ijbswa.sourceforge.net
14
15 #                 Based on the Internet Junkbuster originally written
16 #                 by and Copyright (C) 1997 Anonymous Coders and
17 #                 Junkbusters Corporation.  http://www.junkbusters.com
18
19 #                 This program is free software; you can redistribute it
20 #                 and/or modify it under the terms of the GNU General
21 #                 Public License as published by the Free Software
22 #                 Foundation; either version 2 of the License, or (at
23 #                 your option) any later version.
24
25 #                 This program is distributed in the hope that it will
26 #                 be useful, but WITHOUT ANY WARRANTY; without even the
27 #                 implied warranty of MERCHANTABILITY or FITNESS FOR A
28 #                 PARTICULAR PURPOSE.  See the GNU General Public
29 #                 License for more details.
30
31 #                 The GNU General Public License should be included with
32 #                 this file.  If not, you can view it at
33 #                 http://www.gnu.org/copyleft/gpl.html
34 #                 or write to the Free Software Foundation, Inc., 59
35 #                 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
36
37 #  Revisions   :
38 #     $Log: junkbuster.init,v $
39 #     Revision 1.6  2001/06/28 13:38:42  sarantis
40 #     formatting changes; individual return values are returned from the init script.
41 #
42 #     Revision 1.5  2001/06/11 11:37:40  sarantis
43 #     Minor editing changes.
44 #
45 #     Revision 1.4  2001/06/09 09:14:11  swa
46 #     shamelessly adapted RPM stuff from the newest rpm that
47 #     RedHat provided for the JB.
48 #
49 #     Revision 1.3  2001/05/25 10:12:44  oes
50 #     Fixed default case in switch statement (# -> *)
51 #
52 #     Revision 1.2  2001/05/24 07:52:24  swa
53 #     added header. removed ^M.
54 #
55
56 # ********************************************************************/
57
58 # This is file /etc/rc.d/init.d/junkbuster and was put here 
59 # by the junkbuster rpm
60 #
61 # chkconfig: 235 84 09
62 #
63 # description: This shell script takes care of starting and stopping \
64 #             junkbuster.
65 #
66
67 # Source function library.
68 . /etc/rc.d/init.d/functions
69
70 . /etc/sysconfig/network
71
72 #  Check that networking is up.
73 [ ${NETWORKING} = "no" ] && exit 0
74 [ -f /usr/sbin/junkbuster ] || exit 0
75
76 [ -f /etc/junkbuster/config ] || exit 0
77
78 # See how we were called.
79
80 JB="/usr/sbin/junkbuster /etc/junkbuster/config & "
81 start () {
82         # start daemon
83         [ -f /var/lock/subsys/junkbuster ] && exit 0
84         echo -n $"Starting junkbuster: "
85         daemon --user junkbust $JB 
86         RETVAL=$?
87         echo
88         [ $RETVAL = 0 ] && touch /var/lock/subsys/junkbuster
89         return $RETVAL
90 }
91
92 stop () {
93         # stop daemon
94         echo -n $"Stopping junkbuster: "
95         killproc junkbuster && rm -f /var/lock/subsys/junkbuster
96         RETVAL=?$
97         echo
98         return $RETVAL
99 }
100
101 case "$1" in
102   start)
103         start   
104         ;;
105   stop)
106         stop    
107         ;;
108   reload|restart)
109         stop
110         start
111         RETVAL=$?
112         ;;
113   condrestart)
114         # restart only if already running
115         if [ -f /var/lock/subsys/junkbuster ] ; then
116                 stop
117                 start
118                 RETVAL=$?
119                 ;;
120         fi 
121         ;;
122   status)
123         status junkbuster
124         RETVAL=$?
125         ;;
126   *)
127         echo $"Usage: junkbuster {start|stop|reload|restart|condrestart|status}"
128         exit 1
129 esac
130
131 exit $RETVAL