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

# Check for OpenRC/Baselayout 2 - see bug #270646
is_openrc() {
    [ -f /lib/librc.so -o -f /etc/init.d/sysfs -o -f /lib/rc/version ]
}

start() {
	ebegin "Starting FMS"
	if is_openrc; then
		start-stop-daemon -S -u freenet:freenet -d /var/freenet/fms -b -x /usr/bin/fms
		eend $?
	else
		cd /var/freenet/fms
		su -s /bin/sh -c "fms --daemon" freenet
		eend $?
	fi
}

stop() {
	ebegin "Stopping FMS"
	if is_openrc; then
		start-stop-daemon -K -u freenet:freenet -d /var/freenet/fms /usr/bin/fms
		eend $?
	else
		pkill -u freenet -f "fms --daemon"
		eend 0
	fi
	if [[ $RC_CMD == "restart" ]]; then
		ebegin "Waiting a few seconds to be sure FMS is ready for restart"
		sleep 10
		#give fms time to stop and release the nntp port
	fi
}