#!/bin/sh -
#
# lxc-net Start/Stop LXC Networking
#
# chkconfig: 345 98 01
# description: Starts/Stops LXC Network Bridge
#
### BEGIN INIT INFO
# Provides: lxc-net
# Default-Start: 2 3 4 5
# Default-Stop: 1
# Short-Description: Bring up/down LXC Network Bridge
# Description: Bring up/down LXC Network Bridge
### END INIT INFO

sysconfdir="/etc"

# Source function library.
test ! -r "$sysconfdir"/rc.d/init.d/functions ||
        . "$sysconfdir"/rc.d/init.d/functions

# provide action() fallback
if ! type action >/dev/null 2>&1; then
    # Real basic fallback for sysvinit "action" verbage.
    action() {
        echo -n "$1	"
        shift
        "$@" && echo "OK" || echo "Failed"
    }
fi

start() {
    action $"Starting LXC network bridge: " /usr/libexec/lxc/lxc-net start
}

stop() {
    action $"Stopping LXC network bridge: " /usr/libexec/lxc/lxc-net stop
}

# See how we were called.
case "$1" in
    start)
        start
    ;;

    stop)
        stop
    ;;

    restart|reload|force-reload)
        $0 stop
        $0 start
    ;;

    *)
        echo "Usage: $0 {start|stop|restart|reload|force-reload}"
        exit 2
    ;;
esac

exit $?
