summaryrefslogtreecommitdiff
blob: 55fd30d2d9a26a203a36962b1e65feeda1da33fa (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
#!/sbin/runscript
# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-p2p/btg/files/btgd-init,v 1.3 2007/11/28 17:30:53 angelos Exp $ 

depend() {
	need net
}

checkconfig() {
	if [ -z ${BTG_USER} ]; then
		eerror "BTG_USER unset, please edit /etc/conf.d/btgd first"
		return 1
	elif [ -z ${BTG_CONFIG_FILE} ]; then
		eerror "BTG_CONFIG_FILE unset, please edit /etc/conf.d/btgd first"
		return 1
	elif [ ! -f "${BTG_CONFIG_FILE}" ]; then
		eerror "Unable to find the configuration file ${BTG_CONFIG_FILE}"
		eerror "Please run btg-config first"
		return 1
	fi
}

start() {
	ebegin "Starting BTG Daemon"
	checkconfig || return 1

	start-stop-daemon --start \
		-c ${BTG_USER} --quiet -b --make-pidfile \
		--pidfile /var/run/btgdaemon.pid \
		-x /usr/bin/btgdaemon -- -n -c ${BTG_CONFIG_FILE}
	eend $?
}

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