summaryrefslogtreecommitdiff
blob: b574874b2075d0ce7e234cbad0d589b484ac599f (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
#!/sbin/openrc-run
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

depend() {
	need net
}

start() {
	basedir="${ICECREAM_BASEDIR:-'/var/cache/icecream'}"
	verbosity="${ICECREAM_VERBOSITY:-'-v'}"
	netname="${ICECREAM_NETNAME:+"-n ${ICECREAM_NETNAME}"}"
	iceccd_logfile="${ICECREAM_LOG_FILE:-'/var/log/icecream/iceccd'}"
	nice="${ICECREAM_NICE_LEVEL:+"--nice ${ICECREAM_NICE_LEVEL}"}"
	scheduler="${ICECREAM_SCHEDULER_HOST:+"-s ${ICECREAM_SCHEDULER_HOST}"}"

	if [ "$ICECREAM_RUN_SCHEDULER" = 'yes' ]; then
		sched_logfile="${ICECREAM_SCHEDULER_LOG_FILE:-'/var/log/icecream/scheduler'}"

		ebegin 'Starting Distributed Compiler Scheduler'
		start-stop-daemon -u icecream --start --quiet --exec /usr/sbin/icecc-scheduler -- -d -l "$sched_logfile" $netname $verbosity
		eend ${?}
	fi

	noremote=''
	if test "$ICECREAM_ALLOW_REMOTE" = 'no' 2> /dev/null; then
		noremote='--no-remote'
	fi

	maxjobs=''
	if [ -n "$ICECREAM_MAX_JOBS" ]; then
		if test "$ICECREAM_MAX_JOBS" -eq 0 2> /dev/null; then
			maxjobs='-m 1'
			noremote='--no-remote'
		else
			maxjobs="-m $ICECREAM_MAX_JOBS"
		fi
	fi

	ebegin 'Starting Distributed Compiler Daemon'
	start-stop-daemon --start --quiet --exec /usr/sbin/iceccd -- -d -l "$iceccd_logfile" $nice $scheduler $netname -u icecream -b "$basedir" $maxjobs $noremote $verbosity
	eend ${?}
}

stop() {
	ebegin 'Stopping Distributed Compiler Daemon'
	start-stop-daemon --stop --quiet --name iceccd
	eend ${?}

	if [ "${ICECREAM_RUN_SCHEDULER}" = 'yes' ]; then
		ebegin 'Stopping Distributed Compiler Scheduler'
		start-stop-daemon --stop --quiet --name icecc-scheduler
		eend ${?}
	fi
}