summaryrefslogtreecommitdiff
blob: 5b88d1f1b49457730b53f82d5827318c3230e422 (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
#!/sbin/runscript
# Freenet init.d-script 
# Gentoo Maintainer: Brandon Low <lostlogic@gentoo.org>
# Authors: Per Wigren <wigren@home.se>

depend() {
	need net
}

check_config() {
	if [ -z "${FREENET_NICENESS}" ] || [ -z "${JAVA_OPTIONS}" ]; then
		eerror "Please set all options in /etc/conf.d/freenet"
		return 1
	fi
	return 0
}

start() {
	JAVA="$(java-config --java)"
	check_config || return 1

	ebegin "Starting Freenet now"
	if [ ! -f /usr/lib/freenet/freenet-ext.jar ]; then
		 ewarn "freenet-ext.jar not found.  It can be downloaded from"
		 ewarn "http://freenetproject.org/snapshots/freenet-ext.jar"
		 eend 1
		 return 1
	fi
	if [ ! -f /var/freenet/seednodes.ref ]; then
		 ewarn "seednodes.ref not found, you can download some seeds"
		 ewarn "from http://hawk.freenetproject.org/~freenet4/seednodes.ref"
		 eend 1
		 return 1
	fi

	CLASSPATH=/usr/lib/freenet/freenet.jar:/usr/lib/freenet/freenet-ext.jar:$CLASSPATH 
	
	# if Sun JDK set -server option as suggested on mailing list
	if [ ! -z "`${JAVA} -help 2>&1 | grep '[-]server'`" ]; then
		JAVA_ARGS="-server"
	else
		JAVA_ARGS=""
	fi
	JAVA_ARGS="${JAVA_ARGS} ${JAVA_OPTIONS}"
	ulimit -n 4096
	start-stop-daemon --start --quiet --pidfile \
		/var/run/freenet.pid -m --background -N ${FREENET_NICENESS} \
		--exec ${JAVA} ${JAVA_ARGS} -- \
		freenet.node.Main -p /etc/freenet.conf
	eend $?
}

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