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