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