Excluded text/plain objects from filtering. This fixes a
[privoxy.git] / privoxy.init
1 #!/bin/sh
2 #
3 # This is file /etc/rc.d/init.d/privoxy and was put here 
4 # by the privoxy rpm
5 #
6 # chkconfig: 2345 84 09
7 #
8 # description: Web proxy with advanced filtering capabilities \
9 #              such as filtering web page content, managing \
10 #              cookies and removing ads
11 #
12
13 #  ********************************************************************
14
15 #  File        :  $Source: /cvsroot/ijbswa/current/privoxy.init,v $
16
17 #  Purpose     :  This shell script takes care of starting and stopping
18 #                 privoxy.
19
20 #  Copyright   :  Written by and Copyright (C) 2001 the SourceForge
21 #                 Privoxy team. http://www.privoxy.org/
22
23 #                 Based on the Internet Junkbuster originally written
24 #                 by and Copyright (C) 1997 Anonymous Coders and
25 #                 Junkbusters Corporation.  http://www.junkbusters.com
26
27 #                 This program is free software; you can redistribute it
28 #                 and/or modify it under the terms of the GNU General
29 #                 Public License as published by the Free Software
30 #                 Foundation; either version 2 of the License, or (at
31 #                 your option) any later version.
32
33 #                 This program is distributed in the hope that it will
34 #                 be useful, but WITHOUT ANY WARRANTY; without even the
35 #                 implied warranty of MERCHANTABILITY or FITNESS FOR A
36 #                 PARTICULAR PURPOSE.  See the GNU General Public
37 #                 License for more details.
38
39 #                 The GNU General Public License should be included with
40 #                 this file.  If not, you can view it at
41 #                 http://www.gnu.org/copyleft/gpl.html
42 #                 or write to the Free Software Foundation, Inc., 59
43 #                 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
44
45 #  Revisions   :
46 #     $Log: privoxy.init,v $
47 #     Revision 1.8.2.2  2002/08/05 08:42:13  kick_
48 #     same permissions, same runlevels as all the other initscripts
49 #
50 #     Revision 1.8.2.1  2002/07/12 09:14:26  kick_
51 #     don't use ghost files for rcX.d/*, chkconfig is available to do this job. Enable translation of error messge
52 #
53 #     Revision 1.8  2002/04/09 02:51:31  hal9
54 #     Changed $JB to $PRIVOXY.
55 #
56 #     Revision 1.7  2002/04/08 14:54:51  morcego
57 #     Moved the chkconfig comments to the begining of the file, couse Linuxconf
58 #     was getting confused with it where it was.
59 #
60 #     Revision 1.6  2002/03/26 22:29:55  swa
61 #     we have a new homepage!
62 #
63 #     Revision 1.5  2002/03/25 06:14:18  morcego
64 #     Removing the OPRG definition (no longer needed)
65 #
66 #     Revision 1.4  2002/03/25 04:16:48  hal9
67 #     Fix proper config file location.
68 #
69 #     Revision 1.3  2002/03/24 19:12:15  hal9
70 #     Fixed some naming conflicts.
71 #
72 #     Revision 1.2  2002/03/24 11:40:14  swa
73 #     name change
74 #
75 #     Revision 1.1  2002/03/24 11:23:44  swa
76 #     name change
77 #
78 #     Revision 1.1  2002/03/22 20:53:03  morcego
79 #     - Ongoing process to change name to JunkbusterNG
80 #     - configure/configure.in: no change needed
81 #     - GNUmakefile.in:
82 #             - TAR_ARCH = /tmp/JunkbusterNG-$(RPM_VERSION).tar.gz
83 #             - PROGRAM    = jbng@EXEEXT@
84 #             - rh-spec now references as junkbusterng-rh.spec
85 #             - redhat-upload: references changed to junkbusterng-* (package names)
86 #             - tarball-dist: references changed to JunkbusterNG-distribution-*
87 #             - tarball-src: now JunkbusterNG-*
88 #             - install: initscript now junkbusterng.init and junkbusterng (when
89 #                        installed)
90 #     - junkbuster-rh.spec: renamed to junkbusterng-rh.spec
91 #     - junkbusterng.spec:
92 #             - References to the expression ijb where changed where possible
93 #             - New package name: junkbusterng (all in lower case, acording to
94 #               the LSB recomendation)
95 #             - Version changed to: 2.9.13
96 #             - Release: 1
97 #             - Added: junkbuster to obsoletes and conflicts (Not sure this is
98 #               right. If it obsoletes, why conflict ? Have to check it later)
99 #             - Summary changed: Stefan, please check and aprove it
100 #             - Changes description to use the new name
101 #             - Sed string was NOT changed. Have to wait to the manpage to
102 #               change first
103 #             - Keeping the user junkbuster for now. It will require some aditional
104 #               changes on the script (scheduled for the next specfile release)
105 #             - Added post entry to move the old logfile to the new log directory
106 #             - Removing "chkconfig --add" entry (not good to have it automaticaly
107 #               added to the startup list).
108 #             - Added preun section to stop the service with the old name, as well
109 #               as remove it from the startup list
110 #             - Removed the chkconfig --del entry from the conditional block on
111 #               the preun scriptlet (now handled on the %files section)
112 #     - junkbuster.init: renamed to junkbusterng.init
113 #     - junkbusterng.init:
114 #             - Changed JB_BIN to jbng
115 #             - Created JB_OBIN with the old value of JB_BIN (junkbuster), to
116 #               be used where necessary (config dir)
117 #
118 #     Aditional notes:
119 #     - The config directory is /etc/junkbuster yet. Have to change it on the
120 #     specfile, after it is changes on the code
121 #     - The only files that got renamed on the cvs tree were the rh specfile and
122 #     the init file. Some file references got changes on the makefile and on the
123 #     rh-spec (as listed above)
124 #
125 #     Revision 1.15  2002/03/09 15:05:58  swa
126 #     wrong user.group
127 #
128 #     Revision 1.14  2002/03/06 06:13:40  hal9
129 #     Adapted for Andreas' changes for --user and --pidfile.
130 #
131 #     Revision 1.13  2002/03/05 05:10:10  oes
132 #     Changed pidfile path to conform with FHS
133 #
134 #     Revision 1.12  2002/03/04 20:44:36  oes
135 #     Changed to new cmdline syntax
136 #
137 #     Revision 1.11  2001/12/30 14:07:32  steudten
138 #     - Add signal handling (unix)
139 #     - Add SIGHUP handler (unix)
140 #     - Add creation of pidfile (unix)
141 #     - Add action 'top' in rc file (RH)
142 #     - Add entry 'SIGNALS' to manpage
143 #     - Add exit message to logfile (unix)
144 #
145 #     Revision 1.10  2001/11/05 21:30:23  steudten
146 #     Make JB startup without & due to be a 'real' daemon right now.
147 #     Make the script easy to change.
148 #
149 #     Revision 1.9  2001/09/15 01:53:12  steudten
150 #
151 #     Remove test for subsys flag in start. Some minor changes.
152 #
153 #     Revision 1.8  2001/06/28 13:50:36  sarantis
154 #     swap ?$ with $?; remove bogus ";;"
155 #
156 #     Revision 1.7  2001/06/28 13:40:26  sarantis
157 #     remove single quotes from $JB; it was not expanded.
158 #
159 #     Revision 1.6  2001/06/28 13:38:42  sarantis
160 #     formatting changes; individual return values are returned from the init script.
161 #
162 #     Revision 1.5  2001/06/11 11:37:40  sarantis
163 #     Minor editing changes.
164 #
165 #     Revision 1.4  2001/06/09 09:14:11  swa
166 #     shamelessly adapted RPM stuff from the newest rpm that
167 #     RedHat provided for the JB.
168 #
169 #     Revision 1.3  2001/05/25 10:12:44  oes
170 #     Fixed default case in switch statement (# -> *)
171 #
172 #     Revision 1.2  2001/05/24 07:52:24  swa
173 #     added header. removed ^M.
174 #
175
176 # ********************************************************************/
177
178
179 # Source function library.
180 . /etc/rc.d/init.d/functions
181
182 . /etc/sysconfig/network
183
184 #  Check that networking is up.
185 [ ${NETWORKING} = "no" ] && exit 0
186
187 PRIVOXY_PRG="privoxy"
188 PRIVOXY_BIN="/usr/sbin/$PRIVOXY_PRG"
189 PRIVOXY_CONF="/etc/$PRIVOXY_PRG/config"
190 PRIVOXY_USER="privoxy"
191 PRIVOXY_PID=/var/run/$PRIVOXY_PRG.pid
192 PRIVOXY_LOCK=/var/lock/subsys/$PRIVOXY_PRG
193 PRIVOXY="$PRIVOXY_BIN --user $PRIVOXY_USER.$PRIVOXY_USER --pidfile $PRIVOXY_PID $PRIVOXY_CONF"
194
195 # some checks for us
196 ! [ -x $PRIVOXY_BIN  ] && echo $"Can't find $PRIVOXY_BIN, exit." && exit 0
197 ! [ -f $PRIVOXY_CONF ] && echo $"Can't find $PRIVOXY_CONF, exit." && exit 0
198
199 # See how we were called.
200
201 start () {
202         # start daemon
203         echo -n $"Starting $PRIVOXY_PRG: "
204      if [ -f $PRIVOXY_PID ]; then 
205         killproc $PRIVOXY_PRG && rm -f $PRIVOXY_LOCK $PRIVOXY_PID
206         RETVAL=$?
207         [ $RETVAL != 0 ] && return $RETVAL
208      fi
209         daemon $PRIVOXY
210         RETVAL=$?
211         echo
212         [ $RETVAL = 0 ] && touch $PRIVOXY_LOCK
213         return $RETVAL
214 }
215
216 stop () {
217         # stop daemon
218         echo -n $"Stopping $PRIVOXY_PRG: "
219         killproc $PRIVOXY_PRG && rm -f $PRIVOXY_LOCK $PRIVOXY_PID
220         RETVAL=$?
221         echo
222         return $RETVAL
223 }
224
225 case "$1" in
226   start)
227         start   
228         ;;
229   stop)
230         stop
231         ;;
232   reload)
233         if [ -f $PRIVOXY_PID ] ; then
234         kill -HUP `cat $PRIVOXY_PID`
235         RETVAL=$?
236      fi
237         ;;
238   restart)
239         stop
240         start
241         RETVAL=$?
242         ;;
243   condrestart)
244         # restart only if already running
245         if [ -f $PRIVOXY_PID ] ; then
246         stop
247         start
248         RETVAL=$?
249         fi 
250         ;;
251   status)
252         status $PRIVOXY_PRG 
253         RETVAL=$?
254         ;;
255   top)
256      if [ -f $PRIVOXY_PID ]; then
257                 a=""
258                 for i in `pidof $PRIVOXY_PRG` ; do
259                         a="$a -p $i"
260                 done
261                 top $a
262      fi
263         ;;
264   *)
265         echo $"Usage: $PRIVOXY_PRG {start|stop|reload|restart|condrestart|status|top}"
266         exit 1
267 esac
268
269 exit $RETVAL