summaryrefslogtreecommitdiff
path: root/irqbalance.init
blob: 1c7ffd03561c6fd7865c3d846550f274cff529ca (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
65
66
67
68
69
70
71
72
73
74
#!/bin/sh
# $Id$
#
# irqbalance:	Balancing of IRQs between multiple CPUs
#
#
# chkconfig:	2345 01 99
# description:	irqbalance
#
# config:	/etc/sysconfig/irqbalance

# useless on UP
if [ "$(LC_ALL=C grep "^processor.*:.*[0-9]" /proc/cpuinfo | wc -l)" -lt 2 ]; then
	exit 0
fi

# Source function library
. /etc/rc.d/init.d/functions

# Get service config
if [ -f /etc/sysconfig/irqbalance ]; then
	. /etc/sysconfig/irqbalance
fi

is_yes "$IRQBALANCE_ONE_SHOT" && IRQBALANCE_OPT="${IRQBALANCE_OPT} oneshot"

start() {
	# Check if service is already running?
	if [ ! -f /var/lock/subsys/irqbalance ]; then
		msg_starting irqbalance
		daemon irqbalance ${IRQBALANCE_OPT}
		RETVAL=$?
		[ $RETVAL -eq 0 ] && ! is_yes "$IRQBALANCE_ONE_SHOT" && touch /var/lock/subsys/irqbalance
	else
		msg_already_running irqbalance
	fi
}

stop() {
	if ! is_yes "$IRQBALANCE_ONE_SHOT"; then
		if [ -f /var/lock/subsys/irqbalance ]; then
			msg_stopping irqbalance
			killproc irqbalance
			rm -f /var/lock/subsys/irqbalance
		else
			msg_not_running irqbalance
		fi
	fi
}

RETVAL=0
# See how we were called.
case "$1" in
  start)
  	start
	;;
  stop)
  	stop
	;;
  status)
  	status irqbalance
	RETVAL=$?
	;;
  restart|force-reload)
	stop
	start
	;;
  *)
	msg_usage "$0 {start|stop|restart|force-reload|status}"
	exit 3
esac

exit $RETVAL
# vim:ts=4:sw=4