summaryrefslogtreecommitdiff
blob: 5d4000322d204683fcd71bed3a4aaa6220eba321 (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
58
59
60
61
62
63
64
#!/sbin/runscript

opts="start stop restart slow fast"

depend() {
	need net
}

start() {
	ebegin "Starting mldonkey"
	if [ ! -d ${MLHOME}/${MLDIR} ]
	then
		einfo "Directory ${MLHOME}/${MLDIR} not existing, trying to create..."
		su ${MLUSER} -c "mkdir ${MLHOME}/${MLDIR}" 
		if [ ! -d ${MLHOME}/${MLDIR} ]
		then
			eerror "Directory ${MLHOME}/${MLDIR} could not be created!"
			return 1
		fi
		einfo "...ok!"
	fi
	cd ${MLHOME}/${MLDIR}/
	start-stop-daemon --quiet --start -c ${MLUSER}  \
	-x /usr/bin/mlnet &>${MLLOG} &
	sleep 5
	renice ${MLNICE} -u ${MLUSER} >/dev/null
	eend $?
}

stop() {
	ebegin "Stopping mldonkey - please wait"
	wget --spider http://$DONKSRV:4080/submit?q=close_fds -q 
	wget --spider http://$DONKSRV:4080/submit?q=save -q 
	wget --spider http://$DONKSRV:4080/submit?q=kill -q 
	sleep 10
	start-stop-daemon --oknodo --stop -x /usr/bin/mlnet 
	eend $?
}

restart() {
	svc_stop
	sleep 5
	svc_start
}

slow() {
	ebegin "Reducing bandwidth to ${MLLOWDOWN}k/${MLLOWUP}k"

	wget --spider http://localhost:${MLPORT}/submit?q=set+max_hard_download_rate+${MLLOWDOWN} -q 

	wget --spider http://localhost:${MLPORT}/submit?q=set+max_hard_upload_rate+${MLLOWUP} -q 

	eend $?
}

fast() {
	ebegin "Increasing bandwidth to ${MLHIGHDOWN}k/${MLHIGHUP}k"

	wget --spider http://localhost:${MLPORT}/submit?q=set+max_hard_download_rate+${MLHIGHDOWN} -q 

	wget --spider http://localhost:${MLPORT}/submit?q=set+max_hard_upload_rate+${MLHIGHUP} -q 

	eend $?
}