#! /bin/sh
# /etc/init.d/lxc
#

# Some things that run always
touch /var/lock/lxc
. /etc/lxc.conf

# Carry out specific functions when asked to by the system
case "$1" in
  start)
    echo -n "Starting containers: "
    for i in $CONTAINERS; do
	echo -n "$i "
	lxc-start -n $i -f $CONT_DIR/$i/config -d
    done
    echo "... all started!"
    ;;
  stop)
    echo "Stopping containers: "
    for i in $CONTAINERS; do
        echo -n "$i "
	lxc-stop -n $i
    done
    echo "... all stopped!"
    ;;
  destroy)
    echo "Destroying containers: "
    for i in $CONTAINERS; do
        echo -n "$i "
	lxc-destroy -n $i
    done
    echo "... all destroyed!"
    ;;
  freeze)
    echo "Freezing containers: "
    for i in $CONTAINERS; do
        echo -n "$i "
	lxc-freeze -n $i
    done
    echo "... all freezed!"
    ;;
  unfreeze)
    echo "Unfreezing containers: "
    for i in $CONTAINERS; do
        echo -n "$i "
	lxc-unfreeze -n $i
    done
    echo "... all unfreezed!"
    ;;
  info)
    echo "Containers status: "
    for i in $CONTAINERS; do
        lxc-info -n $i
    done
    ;;

  *)
    echo "Usage: /etc/init.d/lxc {start|stop|destroy|freeze|unfreeze|info}"
    exit 1
    ;;
esac

exit 0

