#!/bin/sh

# only (re-)start on ifup
[ "$ACTION" = "ifup" ] || exit 0
# only start if boot_delay is done
[ -f /tmp/privoxy.hotplug ] || exit 0

PIDFILE=/var/run/privoxy.pid

_PID=$(cat $PIDFILE 2>/dev/null)
kill -1 $_PID 2>/dev/null
if [ $? -eq 0 ]; then
	# only restart if already running
	logger -p daemon.info -t "privoxy[$_PID]" \
		"Restart request due to '$ACTION' of interface '$INTERFACE'"
	/etc/init.d/privoxy restart
else
	# only start if enabled
	/etc/init.d/privoxy enabled && /etc/init.d/privoxy start
fi