summaryrefslogtreecommitdiff
blob: 7b3a900c88e6d573d111f777d15254b9667b4f0e (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
#!/sbin/openrc-run
# Copyright 1999-2014 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$

[ -z "${CONF}" ] && CONF="/etc/sguil/sguild.conf"
[ -z "${AUTOCAT}" ] && AUTOCAT="/etc/sguil/autocat.conf"
[ -z "${QUERIES}" ] && QUERIES="/etc/sguil/sguild.queries"
[ -z "${USERS}" ] && USERS="/etc/sguil/sguild.users"
[ -z "${ACCESS}" ] && AUTOCAT="/etc/sguil/sguild.access"

SGUILD_OPTS="-D -c ${CONF} -u ${USERS} -A ${ACCESS}"

[ -n "${OPENSSLPATH}" ] && SGUILD_OPTS="${SGUILD_OPTS} -o -C ${OPENSSLPATH}"

depend() {
	need net
	use mysql
}

checkconfig() {
	[ -f "${CONF}" ] || return 1	
	[ -f "${AUTOCAT}" ] || return 1	
	[ -f "${QUERIES}" ] || return 1
	[ -f "${USERS}" ] || return 1
	[ -f "${ACCESS}" ] || return 1
	if [ -n "${OPENSSLPATH}" ]; then
		[ -f "${OPENSSLPATH}/sguild.key" ] || return 1
		[ -f "${OPENSSLPATH}/sguild.pem" ] || return 1
	fi
}

start() {
	checkconfig || return 1
	ebegin "Starting sguild"
	start-stop-daemon --start --quiet -c sguil --exec /usr/bin/sguild \
		-- ${SGUILD_OPTS} ${EXTRA_SGUILD_OPTS} -D -P /run/sguild.pid
	eend $?
}

stop() {
	ebegin "Stopping sguild"
	start-stop-daemon --stop --quiet --pidfile /run/sguild.pid
	eend $?
}