summaryrefslogtreecommitdiff
blob: c178ecfbdd629f40c508cbe20ed8f38b6c9b5b1b (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
#!/sbin/runscript
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sci-biology/foldingathome/files/init-5.0.2-r3,v 1.1 2005/02/06 01:02:39 lostlogic Exp $

opts="${opts} unitinfo"

do_config() {
	if [ -z "${CPU}" ] || [ "${CPU}" == "0" ]; then
		if [ -r /proc/cpuinfo ]; then
			CPU=`grep "^processor[[:space:]]*:" /proc/cpuinfo | wc -l`
			if (( $CPU > 8 )); then
				CPU=8
			fi
		else
			CPU=1
		fi
	fi
}

unitinfo() {
	do_config
	for (($CPU; CPU > 0; CPU--)); do
		einfo "CPU ${CPU} $(head -n1 /opt/foldingathome/client${CPU}/unitinfo.txt):"
		sed -e '1,2d' /opt/foldingathome/client${CPU}/unitinfo.txt
	done
}

start() {
	do_config
	su foldingathome -c /opt/foldingathome/copy_client_config
	for (($CPU; CPU > 0; CPU--)); do
		ebegin "Starting Folding@Home on CPU ${CPU}"
		cd /opt/foldingathome/client${CPU}/
		nice -n 20 su foldingathome -c "/opt/foldingathome/client${CPU}/foldingathome ${FOLD_OPTS}" &>/dev/null &
		eend $?
	done
}

stop() {
	do_config
	for (($CPU; CPU > 0; CPU--)); do
		ebegin "Stopping Folding@Home on CPU ${CPU}"
		cd /opt/foldingathome/client${CPU}/
                for I in FahCore*.exe; do
                        if ps ax|grep $I > /dev/null 2>&1; then
				killall -q $I > /dev/null 2>&1
			fi
                done
		sleep 1
		if ps ax|grep '[/]opt[/]foldingathome/client${CPU}/' > /dev/null 2>&1; then
			eend 1
		else
			eend 0
		fi
        done
}