#!/bin/sh

start() {
	echo -n "Starting aoebridge: "

	start-stop-daemon -S -q -b \
		-x taskset f /bin/sh \
		--  -c "/usr/bin/aoebridge -D hw:0,0 >/var/log/aoebridge.log 2>&1"
#		--  -c "chrt -f 1 /usr/bin/aoebridge -D hw:0,0 >/var/log/aoebridge.log 2>&1"

	echo "OK"
}

stop() {
	echo -n "Stopping aoe: "
	for pid in `pgrep '^aoebridge'`; do kill $pid; done >/dev/null 2>&1
	echo "OK"
}

case "$1" in
	start)
		start
		;;
	stop)
		stop
		;;
	restart|reload)
		stop
		start
		;;
	*)
		echo "Usage: $0 {start|stop|restart}"
		exit 1
esac
