#!/sbin/openrc-run
# Copyright 2021 Hyperbola Project
# Distributed under the terms of the GNU General Public License v2

description="Privoxy service"

command_background="yes"
pidfile="/var/run/privoxy.pid"
conffile="/etc/privoxy/config"

depend() {
	need net
}

start() {
	if [ ! -f "${conffile}" ]; then
		eerror "Configuration file ${conffile} not found!"
		return 1
	fi

	ebegin "Starting privoxy"
	start-stop-daemon --start --quiet --exec /usr/sbin/privoxy \
		--pidfile "${pidfile}" \
		-- \
		--pidfile "${pidfile}" \
		--user privoxy.privoxy "${conffile}"
	eend $?
}

stop() {
	ebegin "Stopping privoxy"
	start-stop-daemon --stop --quiet --pidfile "${pidfile}"
	eend $?
}