summaryrefslogtreecommitdiff
path: root/net-proxy/havp/files/havp.initd
blob: 1c42fca33a508825574734249e09eda6eca24c23 (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
#!/sbin/openrc-run
# Copyright 1999-2016 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

depend() {
	need net
	use clamd \
		squid apache2 bfilter mman junkbuster oops polipo privoxy tinyproxy wwwoffled
	#havp could be used in conjuction with any parent proxies enumerated above
}

get_havp_opt() {
	eval HAVP_$1=`awk '/^[ \t]*'$1'[ \t]+/ { print $2; }' < /etc/havp/havp.config`
}

checkconfig() {
	if [ ! -f /etc/havp/havp.config ] ; then
		eerror "No /etc/havp/havp.config file exists!"
		return 1
	fi

	local HAVP_USER
	get_havp_opt USER
	if [ -n "${HAVP_USER}" ] && ! getent passwd ${HAVP_USER} > /dev/null ; then
		eerror "${HAVP_USER} user is missing!"
		return 1
	fi
	local HAVP_GROUP
	get_havp_opt GROUP
	if [ -n "${HAVP_GROUP}" ] && ! getent group ${HAVP_GROUP} > /dev/null ; then
		eerror "${HAVP_GROUP} group is missing!"
		return 1
	fi
}


start() {
	checkconfig || return 1
	
	checkpath --directory \
		--owner "${HAVP_USER:-havp}:${HAVP_GROUP:-havp}" --mode 0755 /run/havp
	checkpath --directory \
		--owner "${HAVP_USER:-havp}:${HAVP_GROUP:-havp}" --mode 0700 /var/log/havp
	checkpath --directory \
		--owner "${HAVP_USER:-havp}:${HAVP_GROUP:-havp}" --mode 0750 /var/tmp/havp
	
	ebegin "Starting HTTP AntiVirus Proxy"
	start-stop-daemon --start --exec /usr/sbin/havp > /dev/null
	eend $?
}

stop() {
	local HAVP_PIDFILE
	get_havp_opt PIDFILE

	ebegin "Stopping HTTP AntiVirus Proxy"
	start-stop-daemon --stop --pidfile=${HAVD_PIDFILE:-/var/run/havp/havp.pid}
	eend $?
}