aboutsummaryrefslogtreecommitdiffstats
path: root/main/tinyproxy/tinyproxy.initd
blob: 6d6b2fcfe612afbb92bcd8b98bf350a87e74fe7e (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
#!/sbin/openrc-run
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-proxy/tinyproxy/files/tinyproxy.initd,v 1.1 2008/02/16 07:11:25 mrness Exp $

CONFFILE="/etc/tinyproxy/${SVCNAME}.conf"

depend() {
	use logger dns
	need net
	after firewall
}

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

	PIDFILE=$(sed -n -e 's/^[[:space:]]*PidFile[[:space:]]\+"\(.*\)"[[:space:]]*$/\1/p' "${CONFFILE}")
	return 0
}

start() {
	checkconfig || return 1
	checkpath --directory --owner tinyproxy:tinyproxy /var/run/tinyproxy
	ebegin "Starting tinyproxy"
	if [ -n "${PIDFILE}" ]; then
		start-stop-daemon --start --pidfile "${PIDFILE}" --startas /usr/sbin/tinyproxy -- -c "${CONFFILE}"
	else
		start-stop-daemon --start --exec /usr/sbin/tinyproxy -- -c "${CONFFILE}"
	fi
	eend $?
}

stop() {
	checkconfig || return 1

	ebegin "Stopping tinyproxy"
	if [ -n "${PIDFILE}" ]; then
		start-stop-daemon --stop --pidfile "${PIDFILE}"
	else
		start-stop-daemon --stop --exec /usr/sbin/tinyproxy
	fi
	eend $?
}