#!/bin/bash
#
# bridgectl	This shell script takes care of starting and stopping
#		network-bridges.
#
# chkconfig: - 98 2
# description: Starts and stops network-bridges.

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

# Source networking configuration.
. /etc/sysconfig/network

prog=bridgectl
lockfile=/var/lock/subsys/$prog
brscript=/etc/xen/scripts/network-bridge-custom

start() {
	# Check that networking is up.
	[ "$NETWORKING" = "no" ] && exit 1

	[ -x $brscript ] || exit 5

        # Start daemons.
        echo -n $"Starting $prog: "

        if [ -f $lockfile -a x"$1" != "xforce" ]; then
            echo_failure
            echo
            return $?
        fi

        $brscript start
	touch $lockfile
	return 0
}

stop() {
        echo -n $"Shutting down $prog: "
	$brscript stop
        echo
	rm -f $lockfile
	return 0
}

# See how we were called.
case "$1" in
  start)
	start
	;;
  force-start)
	start force
	;;
  stop)
	stop
	;;
  restart)
	stop
	start
	;;
  status)
	$brscript status
	;;
  *)
	echo $"Usage: $0 {start|stop|restart|force-start|status}"
	exit 2
esac
