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

depend() {
        need net
}

start() {
	local basedir=${ICECREAM_BASEDIR:-"/var/cache/icecream"}
	local netname=${ICECREAM_NETNAME:+"-n ${ICECREAM_NETNAME}"}
	local logfile=${ICECREAM_LOG_FILE:+"-l ${ICECREAM_LOG_FILE}"}
	local nice=${ICECREAM_NICE_LEVEL:+"--nice ${ICECREAM_NICE_LEVEL}"}
	local scheduler=${ICECREAM_SCHEDULER_HOST:+"-s ${ICECREAM_SCHEDULER_HOST}"}
	local maxjobs=${ICECREAM_MAX_JOBS:+"-m ${ICECREAM_MAX_JOBS}"}
	local verbosity=${ICECREAM_VERBOSITY:-"-v"}
	
	if [[ "${ICECREAM_RUN_SCHEDULER}" == "yes" ]]; then
		local slogfile=${ICECREAM_SCHEDULER_LOG_FILE:-"/var/log/icecc_scheduler"}
		touch ${slogfile} && chown icecream:icecream ${slogfile}
		slogfile=${slogfile:+"-l ${slogfile}"}
		ebegin "Starting Distributed Compiler Scheduler"
		start-stop-daemon -u icecream --start --quiet --exec /usr/sbin/scheduler -- -d ${slogfile} ${netname} ${verbosity}
		eend ${?}
	fi

	[[ ! -d ${basedir} ]] && mkdir -p ${basedir} && chown icecream:icecream ${basedir}
	ebegin "Starting Distributed Compiler Daemon"
	start-stop-daemon --start --quiet --exec /usr/sbin/iceccd -- -d ${logfile} ${nice} ${scheduler} ${netname} -u icecream -b "${basedir}" ${maxjobs} ${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 scheduler
		eend ${?}
	fi
}