Rewrite of list library. Now has seperate header and list_entry
[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.8  2001/06/28 13:50:36  sarantis
37 #     swap ?$ with $?; remove bogus ";;"
38 #
39 #     Revision 1.7  2001/06/28 13:40:26  sarantis
40 #     remove single quotes from $JB; it was not expanded.
41 #
42 #     Revision 1.6  2001/06/28 13:38:42  sarantis
43 #     formatting changes; individual return values are returned from the init script.
44 #
45 #     Revision 1.5  2001/06/11 11:37:40  sarantis
46 #     Minor editing changes.
47 #
48 #     Revision 1.4  2001/06/09 09:14:11  swa
49 #     shamelessly adapted RPM stuff from the newest rpm that
50 #     RedHat provided for the JB.
51 #
52 #     Revision 1.3  2001/05/25 10:12:44  oes
53 #     Fixed default case in switch statement (# -> *)
54 #
55 #     Revision 1.2  2001/05/24 07:52:24  swa
56 #     added header. removed ^M.
57 #
58
59 # ********************************************************************/
60
61 # This is file /etc/rc.d/init.d/junkbuster and was put here 
62 # by the junkbuster rpm
63 #
64 # chkconfig: 235 84 09
65 #
66 # description: This shell script takes care of starting and stopping \
67 #             junkbuster.
68 #
69
70 # Source function library.
71 . /etc/rc.d/init.d/functions
72
73 . /etc/sysconfig/network
74
75 #  Check that networking is up.
76 [ ${NETWORKING} = "no" ] && exit 0
77
78 JB_BIN="/usr/sbin/junkbuster"
79 JB_CONF="/etc/junkbuster/config"
80 JB_USER="junkbuster"
81
82 # some checks for us
83 [ -x $JB_BIN  ] || exit 0
84 [ -f $JB_CONF ] || exit 0
85
86 # See how we were called.
87
88 JB="$JB_BIN $JB_CONF &"
89
90 start () {
91         # start daemon
92         echo -n $"Starting junkbuster: "
93         daemon --user $JB_USER $JB 
94         RETVAL=$?
95         echo
96         [ $RETVAL = 0 ] && touch /var/lock/subsys/junkbuster
97         return $RETVAL
98 }
99
100 stop () {
101         # stop daemon
102         echo -n $"Stopping junkbuster: "
103         killproc junkbuster && rm -f /var/lock/subsys/junkbuster
104         RETVAL=$?
105         echo
106         return $RETVAL
107 }
108
109 case "$1" in
110   start)
111         start   
112         ;;
113   stop)
114         stop    
115         ;;
116   reload|restart)
117         stop
118         start
119         RETVAL=$?
120         ;;
121   condrestart)
122         # restart only if already running
123         if [ -f /var/lock/subsys/junkbuster ] ; then
124                 stop
125                 start
126                 RETVAL=$?
127         fi 
128         ;;
129   status)
130         status junkbuster
131         RETVAL=$?
132         ;;
133   *)
134         echo $"Usage: junkbuster {start|stop|reload|restart|condrestart|status}"
135         exit 1
136 esac
137
138 exit $RETVAL