Debian directory added.
[privoxy.git] / privoxy.init
1 #!/bin/sh
2 #  ********************************************************************
3
4 #  File        :  $Source: /cvsroot/ijbswa/current/privoxy.init,v $
5
6 #  Purpose     :  This shell script takes care of starting and stopping
7 #                 privoxy.
8
9 #  Copyright   :  Written by and Copyright (C) 2001 the SourceForge
10 #                 Privoxy team. http://www.privoxy.org/
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: privoxy.init,v $
36 #     Revision 1.5  2002/03/25 06:14:18  morcego
37 #     Removing the OPRG definition (no longer needed)
38 #
39 #     Revision 1.4  2002/03/25 04:16:48  hal9
40 #     Fix proper config file location.
41 #
42 #     Revision 1.3  2002/03/24 19:12:15  hal9
43 #     Fixed some naming conflicts.
44 #
45 #     Revision 1.2  2002/03/24 11:40:14  swa
46 #     name change
47 #
48 #     Revision 1.1  2002/03/24 11:23:44  swa
49 #     name change
50 #
51 #     Revision 1.1  2002/03/22 20:53:03  morcego
52 #     - Ongoing process to change name to JunkbusterNG
53 #     - configure/configure.in: no change needed
54 #     - GNUmakefile.in:
55 #             - TAR_ARCH = /tmp/JunkbusterNG-$(RPM_VERSION).tar.gz
56 #             - PROGRAM    = jbng@EXEEXT@
57 #             - rh-spec now references as junkbusterng-rh.spec
58 #             - redhat-upload: references changed to junkbusterng-* (package names)
59 #             - tarball-dist: references changed to JunkbusterNG-distribution-*
60 #             - tarball-src: now JunkbusterNG-*
61 #             - install: initscript now junkbusterng.init and junkbusterng (when
62 #                        installed)
63 #     - junkbuster-rh.spec: renamed to junkbusterng-rh.spec
64 #     - junkbusterng.spec:
65 #             - References to the expression ijb where changed where possible
66 #             - New package name: junkbusterng (all in lower case, acording to
67 #               the LSB recomendation)
68 #             - Version changed to: 2.9.13
69 #             - Release: 1
70 #             - Added: junkbuster to obsoletes and conflicts (Not sure this is
71 #               right. If it obsoletes, why conflict ? Have to check it later)
72 #             - Summary changed: Stefan, please check and aprove it
73 #             - Changes description to use the new name
74 #             - Sed string was NOT changed. Have to wait to the manpage to
75 #               change first
76 #             - Keeping the user junkbuster for now. It will require some aditional
77 #               changes on the script (scheduled for the next specfile release)
78 #             - Added post entry to move the old logfile to the new log directory
79 #             - Removing "chkconfig --add" entry (not good to have it automaticaly
80 #               added to the startup list).
81 #             - Added preun section to stop the service with the old name, as well
82 #               as remove it from the startup list
83 #             - Removed the chkconfig --del entry from the conditional block on
84 #               the preun scriptlet (now handled on the %files section)
85 #     - junkbuster.init: renamed to junkbusterng.init
86 #     - junkbusterng.init:
87 #             - Changed JB_BIN to jbng
88 #             - Created JB_OBIN with the old value of JB_BIN (junkbuster), to
89 #               be used where necessary (config dir)
90 #
91 #     Aditional notes:
92 #     - The config directory is /etc/junkbuster yet. Have to change it on the
93 #     specfile, after it is changes on the code
94 #     - The only files that got renamed on the cvs tree were the rh specfile and
95 #     the init file. Some file references got changes on the makefile and on the
96 #     rh-spec (as listed above)
97 #
98 #     Revision 1.15  2002/03/09 15:05:58  swa
99 #     wrong user.group
100 #
101 #     Revision 1.14  2002/03/06 06:13:40  hal9
102 #     Adapted for Andreas' changes for --user and --pidfile.
103 #
104 #     Revision 1.13  2002/03/05 05:10:10  oes
105 #     Changed pidfile path to conform with FHS
106 #
107 #     Revision 1.12  2002/03/04 20:44:36  oes
108 #     Changed to new cmdline syntax
109 #
110 #     Revision 1.11  2001/12/30 14:07:32  steudten
111 #     - Add signal handling (unix)
112 #     - Add SIGHUP handler (unix)
113 #     - Add creation of pidfile (unix)
114 #     - Add action 'top' in rc file (RH)
115 #     - Add entry 'SIGNALS' to manpage
116 #     - Add exit message to logfile (unix)
117 #
118 #     Revision 1.10  2001/11/05 21:30:23  steudten
119 #     Make JB startup without & due to be a 'real' daemon right now.
120 #     Make the script easy to change.
121 #
122 #     Revision 1.9  2001/09/15 01:53:12  steudten
123 #
124 #     Remove test for subsys flag in start. Some minor changes.
125 #
126 #     Revision 1.8  2001/06/28 13:50:36  sarantis
127 #     swap ?$ with $?; remove bogus ";;"
128 #
129 #     Revision 1.7  2001/06/28 13:40:26  sarantis
130 #     remove single quotes from $JB; it was not expanded.
131 #
132 #     Revision 1.6  2001/06/28 13:38:42  sarantis
133 #     formatting changes; individual return values are returned from the init script.
134 #
135 #     Revision 1.5  2001/06/11 11:37:40  sarantis
136 #     Minor editing changes.
137 #
138 #     Revision 1.4  2001/06/09 09:14:11  swa
139 #     shamelessly adapted RPM stuff from the newest rpm that
140 #     RedHat provided for the JB.
141 #
142 #     Revision 1.3  2001/05/25 10:12:44  oes
143 #     Fixed default case in switch statement (# -> *)
144 #
145 #     Revision 1.2  2001/05/24 07:52:24  swa
146 #     added header. removed ^M.
147 #
148
149 # ********************************************************************/
150
151 # This is file /etc/rc.d/init.d/privoxy and was put here 
152 # by the privoxy rpm
153 #
154 # chkconfig: 235 84 09
155 #
156 # description: This shell script takes care of starting and stopping \
157 #              privoxy.
158 #
159
160
161 # Source function library.
162 . /etc/rc.d/init.d/functions
163
164 . /etc/sysconfig/network
165
166 #  Check that networking is up.
167 [ ${NETWORKING} = "no" ] && exit 0
168
169 JB_PRG="privoxy"
170 JB_BIN="/usr/sbin/$JB_PRG"
171 JB_CONF="/etc/$JB_PRG/config"
172 JB_USER="privoxy"
173 JB_PID=/var/run/$JB_PRG.pid
174 JB_LOCK=/var/lock/subsys/$JB_PRG
175 JB="$JB_BIN --user $JB_USER.$JB_USER --pidfile $JB_PID $JB_CONF"
176
177 # some checks for us
178 ! [ -x $JB_BIN  ] && echo "Can't find $JB_BIN, exit." && exit 0
179 ! [ -f $JB_CONF ] && echo "Can't find $JB_CONF, exit." && exit 0
180
181 # See how we were called.
182
183 start () {
184         # start daemon
185         echo -n $"Starting $JB_PRG: "
186      if [ -f $JB_PID ]; then 
187         killproc $JB_PRG && rm -f $JB_LOCK $JB_PID
188         RETVAL=$?
189         [ $RETVAL != 0 ] && return $RETVAL
190      fi
191         daemon $JB 
192         RETVAL=$?
193         echo
194         [ $RETVAL = 0 ] && touch $JB_LOCK
195         return $RETVAL
196 }
197
198 stop () {
199         # stop daemon
200         echo -n $"Stopping $JB_PRG: "
201         killproc $JB_PRG && rm -f $JB_LOCK $JB_PID
202         RETVAL=$?
203         echo
204         return $RETVAL
205 }
206
207 case "$1" in
208   start)
209         start   
210         ;;
211   stop)
212         stop
213         ;;
214   reload)
215         if [ -f $JB_PID ] ; then
216         kill -HUP `cat $JB_PID`
217         RETVAL=$?
218      fi
219         ;;
220   restart)
221         stop
222         start
223         RETVAL=$?
224         ;;
225   condrestart)
226         # restart only if already running
227         if [ -f $JB_PID ] ; then
228         stop
229         start
230         RETVAL=$?
231         fi 
232         ;;
233   status)
234         status $JB_PRG 
235         RETVAL=$?
236         ;;
237   top)
238      if [ -f $JB_PID ]; then
239                 a=""
240                 for i in `pidof $JB_PRG` ; do
241                         a="$a -p $i"
242                 done
243                 top $a
244      fi
245         ;;
246   *)
247         echo $"Usage: $JB_PRG {start|stop|reload|restart|condrestart|status|top}"
248         exit 1
249 esac
250
251 exit $RETVAL