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