#!/bin/sh

# irqbalance init script
# August 2003
# Eric Dorland
 
# Based on spamassassin init script
 
PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/irqbalance
NAME=irqbalance
SNAME=irqbalance
DESC="SMP IRQ Balancer"
PIDFILE="/var/run/$NAME.pid"
PNAME="irqbalance"
DOPTIONS=""

# Defaults - don't touch, edit /etc/default/
ENABLED=0
OPTIONS=""
ONE_SHOT=0

test -x $DAEMON || exit 0

test -f /etc/default/irqbalance && . /etc/default/irqbalance
             
test "$ENABLED" != "0" || exit 0

if test "$ONESHOT" != "0"; then
    DOPTIONS="--oneshot"
fi

case "$1" in
  start)
        echo -n "Starting $DESC: "
        start-stop-daemon --start --pidfile $PIDFILE \
        	--name $PNAME --oknodo --startas $DAEMON \
            -- $OPTIONS $DOPTIONS
        
        echo "$NAME."
        ;;
  stop)
        echo -n "Stopping $DESC: "
        
        start-stop-daemon --stop --pidfile $PIDFILE --name $PNAME --oknodo
        
        echo "$NAME."
        ;;
  restart|force-reload)
        echo -n "Restarting $DESC: "
        start-stop-daemon --stop --pidfile $PIDFILE --name $PNAME \
            --retry 5 --oknodo
        start-stop-daemon --start --pidfile $PIDFILE \
            --name $PNAME --oknodo --startas $DAEMON \
            -- $OPTIONS $DOPTIONS
        
        echo "$NAME."
        ;;
  *)
        N=/etc/init.d/$SNAME
        echo "Usage: $N {start|stop|restart|force-reload}" >&2
        exit 1
        ;;
esac

exit 0
