Enable FEATURE_CONNECTION_KEEP_ALIVE unconditionally. Enable FEATURE_CONNECTION_SHARI...
[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 # ********************************************************************/
46
47
48 # Source function library.
49 . /etc/rc.d/init.d/functions
50
51 . /etc/sysconfig/network
52
53 #  Check that networking is up.
54 [ ${NETWORKING} = "no" ] && exit 0
55
56 PRIVOXY_PRG="privoxy"
57 PRIVOXY_BIN="/usr/sbin/$PRIVOXY_PRG"
58 PRIVOXY_CONF="/etc/$PRIVOXY_PRG/config"
59 PRIVOXY_USER="privoxy"
60 PRIVOXY_PID=/var/run/$PRIVOXY_PRG.pid
61 PRIVOXY_LOCK=/var/lock/subsys/$PRIVOXY_PRG
62 PRIVOXY="$PRIVOXY_BIN --user $PRIVOXY_USER.$PRIVOXY_USER --pidfile $PRIVOXY_PID $PRIVOXY_CONF"
63
64 # some checks for us
65 ! [ -x $PRIVOXY_BIN  ] && echo $"Can't find $PRIVOXY_BIN, exit." && exit 0
66 ! [ -f $PRIVOXY_CONF ] && echo $"Can't find $PRIVOXY_CONF, exit." && exit 0
67
68 # See how we were called.
69
70 start () {
71         # start daemon
72         echo -n $"Starting $PRIVOXY_PRG: "
73      if [ -f $PRIVOXY_PID ]; then 
74         killproc $PRIVOXY_PRG && rm -f $PRIVOXY_LOCK $PRIVOXY_PID
75         RETVAL=$?
76         [ $RETVAL != 0 ] && return $RETVAL
77      fi
78         daemon $PRIVOXY
79         RETVAL=$?
80         echo
81         [ $RETVAL = 0 ] && touch $PRIVOXY_LOCK
82         return $RETVAL
83 }
84
85 stop () {
86         # stop daemon
87         echo -n $"Stopping $PRIVOXY_PRG: "
88         killproc $PRIVOXY_PRG && rm -f $PRIVOXY_LOCK $PRIVOXY_PID
89         RETVAL=$?
90         echo
91         return $RETVAL
92 }
93
94 case "$1" in
95   start)
96         start   
97         ;;
98   stop)
99         stop
100         ;;
101   reload)
102         if [ -f $PRIVOXY_PID ] ; then
103         kill -HUP `cat $PRIVOXY_PID`
104         RETVAL=$?
105      fi
106         ;;
107   restart)
108         stop
109         start
110         RETVAL=$?
111         ;;
112   condrestart)
113         # restart only if already running
114         if [ -f $PRIVOXY_PID ] ; then
115         stop
116         start
117         RETVAL=$?
118         fi 
119         ;;
120   status)
121         status $PRIVOXY_PRG 
122         RETVAL=$?
123         ;;
124   top)
125      if [ -f $PRIVOXY_PID ]; then
126                 a=""
127                 for i in `pidof $PRIVOXY_PRG` ; do
128                         a="$a -p $i"
129                 done
130                 top $a
131      fi
132         ;;
133   *)
134         echo $"Usage: $PRIVOXY_PRG {start|stop|reload|restart|condrestart|status|top}"
135         exit 1
136 esac
137
138 exit $RETVAL