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

depend() {
	need net
}

start() {
	if ! test -f "${AMULEHOME}/.aMule/amule.conf"; then
		eerror "You must start and configure amuled before launch it. Sorry."
		return 1
	fi

	if pgrep -u ${AMULEUSER} amuled >/dev/null; then
		eerror "An instance of aMule webserver is already running"
		return 1
	fi
	if [ -e /var/run/amuled.pid ]; then
		 rm /var/run/amuled.pid
	fi

	ebegin "Starting aMule Daemon"
	env HOME="${AMULEHOME}" start-stop-daemon --start \
		--quiet --background \
		--make-pidfile --pidfile /var/run/amuled.pid \
		-c ${AMULEUSER} \
		-x /usr/bin/amuled >${LOG}
	
	sleep 2
	if ! pgrep -u ${AMULEUSER} amuled > /dev/null; then
		eerror "aMule daemon can't be started! Check logfile: ${LOG}"
	fi
	eend $?
}

stop() {
	ebegin "Stopping aMule daemon -- please wait"
	start-stop-daemon --oknodo --stop --pidfile /var/run/amuled.pid &>/dev/null
	eend $?
}

restart() {
	svc_stop
	while `pgrep -u ${AMULEUSER} amuled >/dev/null`; do
		sleep 1
	done
	svc_start
}