/usr/lib/polipo/polipo-control is in polipo 1.0.4.1-1.2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 | #!/bin/sh
set -e
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/polipo
test -x $DAEMON || exit 0
CONFIG_FILE=/etc/polipo/config
FORBIDDEN_FILE=/etc/polipo/forbidden
NAME=polipo
PIDFILE=/var/run/$NAME/$NAME.pid
LOGFILE=/var/log/$NAME/$NAME.log
USER=proxy
GROUP=proxy
DAEMON_OPTS="-c $CONFIG_FILE pidFile=$PIDFILE daemonise=true logFile=$LOGFILE"
forbiddenFile() {
if [ -f $FORBIDDEN_FILE ] || [ -d $FORBIDDEN_FILE ]; then
echo -n $FORBIDDEN_FILE
else
echo -n /dev/null
fi
}
waitForPIDRemove() {
T=30
for i in `seq 1 $T`; do
if [ ! -f $PIDFILE ]; then return; fi
sleep 1
done
echo "Waited $T seconds and $PIDFILE did not disappear. Giving up." 2>&1
}
# Outputs the binary name of the process with PID $1, e.g. /usr/sbin/polipo
nameOfPID() {
ps -o command= -p $1 | cut -f1 '-d '
}
# Returns true if the pidfile exists, and there is a polipo process running
# with the PID therein. False otherwise.
alreadyRunning() {
if [ -r $PIDFILE ]; then
PID=`cat $PIDFILE`
if [ "`nameOfPID $PID`" = $DAEMON ]; then
return 0 # TRUE
fi
fi
return 1 # FALSE
}
# Deletes polipo's pidfile if it exists
# This is designed to remove the pidfile from a crashed polipo before
# starting a new one
removePIDFile() {
if [ -e $PIDFILE ]; then
echo -n "Removing stale pidfile"
rm $PIDFILE
echo "."
fi
}
DAEMON_OPTS="$DAEMON_OPTS forbiddenFile=`forbiddenFile`"
polipo_start() {
if alreadyRunning; then
echo "$DAEMON already running -- doing nothing"
exit
fi
removePIDFile
start-stop-daemon --start --quiet --pidfile $PIDFILE \
--chuid $USER:$GROUP --exec $DAEMON -- $DAEMON_OPTS
}
polipo_stop() {
start-stop-daemon --stop --quiet --pidfile $PIDFILE \
--oknodo --exec $DAEMON
}
case "$1" in
start)
polipo_start
;;
stop)
polipo_stop
;;
restart)
polipo_stop
waitForPIDRemove
polipo_start
;;
*)
N=polipo-control
echo "Usage: $N {start|stop}" >&2
exit 1
esac
exit 0
|