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