summaryrefslogtreecommitdiff
blob: 21cfddeda8c3c5d3fc4a57ccac81864b1e155218 (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
#!/sbin/openrc-run
# Copyright 1999-2013 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"}

	[[ ! -d /var/log/icecream/ ]] && mkdir -p /var/log/icecream/ && chown icecream:icecream /var/log/icecream/
	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/icecc-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 icecc-scheduler
		eend ${?}
	fi
}