shamelessly adapted RPM stuff from the newest rpm that
[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.3  2001/05/25 10:12:44  oes
40 #     Fixed default case in switch statement (# -> *)
41 #
42 #     Revision 1.2  2001/05/24 07:52:24  swa
43 #     added header. removed ^M.
44 #
45
46 # ********************************************************************/
47
48 # This is file /etc/rc.d/init.d/junkbuster and was put here 
49 # by the junkbuster rpm
50 #
51 # chkconfig: 235 84 09
52 #
53 # description: This shell script takes care of starting and stopping \
54 #             junkbuster.
55 #
56
57 # Source function library.
58 . /etc/rc.d/init.d/functions
59
60 [ -f /usr/sbin/junkbuster ] || exit 0
61
62 [ -f /etc/junkbuster/config ] || exit 0
63
64 # See how we were called.
65
66 JB="/usr/sbin/junkbuster /etc/junkbuster/config & "
67 start () {
68         # start daemon
69         [ -f /var/lock/subsys/junkbuster ] && exit 0
70         echo -n $"Starting junkbuster: "
71         daemon --user junkbust $JB 
72         RETVAL=$?
73         echo
74         [ $RETVAL = 0 ] && touch /var/lock/subsys/junkbuster
75         return $RETVAL
76 }
77
78 stop () {
79         # stop daemon
80         echo -n $"Stopping junkbuster: "
81         killproc junkbuster && rm -f /var/lock/subsys/junkbuster
82         RETVAL=?$
83         echo
84 }
85
86 case "$1" in
87         start)
88                 start   
89         ;;
90
91         stop)
92                 stop    
93         ;;
94
95         restart)
96                 stop
97                 start
98                 ;;
99         condrestart)
100                 [ -f /var/lock/subsys/junkbuster ] && restart || : 
101         ;;
102         status)
103                 status junkbuster
104         ;;
105         *)
106                 echo $"Usage: junkbuster {start|stop|restart|condrestart|status}"
107                 exit 1
108 esac
109
110 exit 0