Add changes from 3.0.6-2, 3.0.6-3 and several unreleased changes
[privoxy.git] / debian / init.d
1 #! /bin/sh
2
3 ### BEGIN INIT INFO
4 # Provides:          privoxy
5 # Required-Start:    $local_fs $remote_fs $network $time
6 # Required-Stop:     $local_fs $remote_fs $network $time
7 # Default-Start:     2 3 4 5
8 # Default-Stop:      0 1 6
9 # Short-Description: Privacy enhancing HTTP Proxy
10 # Description:       Privoxy is a web proxy with advanced filtering
11 #                    capabilities for protecting privacy, filtering
12 #                    web page content, managing cookies, controlling
13 #                    access, and removing ads, banners, pop-ups and
14 #                    other obnoxious Internet junk.
15 ### END INIT INFO
16
17 PATH=/sbin:/bin:/usr/sbin:/usr/bin
18 DAEMON=/usr/sbin/privoxy
19 NAME=privoxy
20 DESC="filtering proxy server"
21 OWNER=privoxy
22 CONFIGFILE=/etc/privoxy/config
23 PIDFILE=/var/run/$NAME.pid
24
25 test -f $DAEMON || exit 0
26
27 set -e
28
29 case "$1" in
30   start)
31         echo -n "Starting $DESC: "
32         start-stop-daemon --oknodo --start --quiet --pidfile $PIDFILE \
33             --exec $DAEMON -- --pidfile $PIDFILE --user $OWNER $CONFIGFILE \
34             2>> /var/log/privoxy/errorfile
35         echo "$NAME."
36         ;;
37
38   stop)
39         echo -n "Stopping $DESC: "
40         start-stop-daemon --oknodo --stop --quiet --pidfile $PIDFILE \
41                 --exec $DAEMON
42         rm -f $PIDFILE
43         echo "$NAME."
44         ;;
45
46   restart|force-reload)
47         echo -n "Restarting $DESC: "
48         start-stop-daemon --oknodo --stop --quiet --pidfile $PIDFILE \
49                 --exec $DAEMON
50         sleep 1
51         start-stop-daemon --oknodo --start --quiet --pidfile $PIDFILE \
52             --exec $DAEMON -- --pidfile $PIDFILE --user $OWNER $CONFIGFILE \
53             2>> /var/log/privoxy/errorfile
54         echo "$NAME."
55         ;;
56
57   status)
58         echo -n "Status of $DESC: "
59         if [ ! -r "$PIDFILE" ]; then
60                 echo "$NAME is not running."
61                 exit 3
62         fi
63         if read pid < "$PIDFILE" && ps -p "$pid" > /dev/null 2>&1; then
64                 echo "$NAME is running."
65                 exit 0
66         else
67                 echo "$NAME is not running but $PIDFILE exists."
68                 exit 1
69         fi
70         ;;
71
72   *)
73         N=/etc/init.d/$NAME
74         echo "Usage: $N {start|stop|restart|force-reload|status}" >&2
75         exit 1
76         ;;
77 esac
78
79 exit 0