blob: 932dcc0c8e022ba7d4fa63b71eca0cf836085e8c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
#!/bin/sh
# ********************************************************************
RETVAL=1
PRIVOXY_PRG="privoxy"
PRIVOXY_BIN="/usr/sbin/$PRIVOXY_PRG"
PRIVOXY_CONF="/etc/privoxy/config"
PRIVOXY_USER="privoxy"
PRIVOXY_GROUP="privoxy"
PRIVOXY_PID="/var/run/$PRIVOXY_PRG/$PRIVOXY_PRG.pid"
declare -i check
check=(`/bin/ps -e|/bin/grep $PRIVOXY_PRG|/usr/bin/wc -l`)
# some checks for us
if [ ! -x $PRIVOXY_BIN ] ; then exit 0 ;fi
if [ ! -f $PRIVOXY_CONF ] ; then exit 0 ;fi
# See how we were called.
PRIVOXY="$PRIVOXY_BIN $PRIVOXY_CONF"
start () {
# start daemon
echo -n $"Starting $PRIVOXY_PRG: "
if [ ! -f $PRIVOXY_PID ]; then
( $PRIVOXY --user $PRIVOXY_USER.$PRIVOXY_GROUP --pidfile $PRIVOXY_PID -c $PRIVOXY_CONF 2>/dev/tty9 ) \
&& echo " OK" \
&& /bin/touch /var/lock/$PRIVOXY_PRG \
&& RETVAL=0
elif [ $check -lt 3 ]; then
echo "Zombie lock file found"
/bin/rm -f /var/lock/$PRIVOXY_PRG $PRIVOXY_PID
echo "Retrying..."
start
else
echo "Already running"
fi
echo
}
stop () {
# stop daemon
echo -n $"Stopping $PRIVOXY_PRG: "
if [ -f $PRIVOXY_PID ]; then
/bin/kill `/bin/cat $PRIVOXY_PID` \
&& /bin/rm -f /var/lock/$PRIVOXY_PRG $PRIVOXY_PID \
&& echo " OK" \
&& RETVAL=0
echo
else
echo " Not Running"
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
reload)
if [ -f $PRIVOXY_PID ] ; then
/bin/kill -HUP `cat $PRIVOXY_PID` \
&& RETVAL=0
fi
;;
restart)
stop
start
;;
kill)
echo "Kill all Privoxy"
/bin/rm -f /var/lock/$PRIVOXY_PRG $PRIVOXY_PID
/bin/killall $PRIVOXY
;;
condrestart)
# restart only if already running
if [ -f $PRIVOXY_PID ] ; then
stop
start
fi
;;
status)
/bin/ps ax|/bin/grep $PRIVOXY_PRG|/bin/grep -v 'grep\|init\.d\|rc\.d'
RETVAL=0
;;
top)
if [ -f $PRIVOXY_PID ]; then
a=""
for i in `/sbin/pidof $PRIVOXY_PRG` ; do
a="$a -p $i"
done
/usr/bin/top $a
fi
;;
*)
echo $"Usage: $PRIVOXY_PRG {start|stop|reload|restart|condrestart|status|top|kill}"
exit 1
esac
exit $RETVAL
|