updated on Thu Jan 26 16:09:46 UTC 2012
[aur-mirror.git] / privoxy-cvs / privoxy
blob754453de5247bf5869525c580c2a24ac2adc8932
1 #!/bin/bash
3 . /etc/rc.conf
4 . /etc/rc.d/functions
6 # source application-specific settings
7 [ -f /etc/conf.d/privoxy ] && . /etc/conf.d/privoxy
9 # read logdir and logfile from privoxy config
10 prld=`grep ^logdir "$PRIVOXY_CONF" 2>/dev/null | cut -d' ' -f2`
11 [ -n "$prld" ] || prld=/var/log/privoxy
12 prlf=`grep ^logfile "$PRIVOXY_CONF" 2>/dev/null | cut -d' ' -f2`
13 [ -n "$prlf" ] || prlf=logfile
15 PID=`pidof -o %PPID /usr/sbin/privoxy`
17 case "$1" in
18 start)
19 stat_busy "Starting Privoxy"
20 # create missing logdir and logfile
21 [ -d "$prld" ] || mkdir -p "$prld"
22 if [ ! -f "$prlf" ]; then
23 touch "$prld/$prlf" && chgrp "${PRIVOXY_GROUP}" "$prld/$prlf" && \
24 chmod 0660 "$prld/$prlf"
26 [ -z "$PID" ] && /usr/sbin/privoxy --user ${PRIVOXY_USER}.${PRIVOXY_GROUP} \
27 ${PRIVOXY_ARGS} ${PRIVOXY_CONF}
28 if [ $? -gt 0 ]; then
29 stat_fail
30 else
31 add_daemon privoxy
32 stat_done
35 stop)
36 stat_busy "Stopping Privoxy"
37 [ ! -z "$PID" ] && kill $PID &> /dev/null
38 if [ $? -gt 0 ]; then
39 stat_fail
40 else
41 rm_daemon privoxy
42 stat_done
45 restart)
46 $0 stop
47 sleep 1
48 $0 start
51 echo "usage: $0 {start|stop|restart}"
52 esac
53 exit 0