#!/bin/sh
#=================================================================
# Begin lxc
#
# Description:	Starts/Stops all LXC containers configured for autostart.
# chkconfig:	345 99 01
#
#=================================================================

### BEGIN INIT INFO
# Provides:		lxc
# Required-Start:	$syslog
# Should-Start:		$syslog
# Required-Stop:
# Should-Stop:
# Default-Start:       3 4 5
# Default-Stop:        0 1 2 6
# Short-Description:   Starts lxc daemon.
# Description:         Starts lxc daemon.
### END INIT INFO

. /lib/lsb/init-functions

RETVAL=0
GROUP="-g onboot"
CMD="/usr/bin/lxc-autostart"

# Some functions to make the below more readable
case "$1" in
    start	)
      log_info_msg "Starting LXC autoboot containers:"
      ${CMD} ${GROUP} $1
      evaluate_retval
      ;;

    stop	)
      log_info_msg "Stopping LXC containers:"
      ${CMD} -s ${GROUP} $1
      evaluate_retval
      ;;

    restart	)
        $0 stop
        ${CMD} -r ${GROUP} $1
        $0 start
        ;;

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

