#!/usr/bin/env bash

case "${1}" in
        -[Ll][Ii][Ss][Tt])
                        echo "lxc-list"
                        sleep 1
                        sudo lxc-list
                        shift
                        ;;
        -[Ss][Tt][Aa][Rr][Tt])
                        echo "lxc-start -d -n ${2}"
                        sudo lxc-start -d -n ${2}
                        sleep 1
                        sudo lxc-list
                        shift
                        shift
                        ;;
        -[Ss][Tt][Oo][Pp])
                        echo "lxc-stop -n ${2}"
                        sudo lxc-stop -n ${2}
                        sleep 1
                        sudo lxc-list
                        shift
                        shift
                        ;;
        -[Rr][Ee][Ss][Tt][Aa][Rr][Tt])
                        echo "lxc-stop -n ${2}"
                        sudo lxc-stop -n ${2}
                        sleep 1
                        sudo lxc-list
                        sleep 1
                        echo "lxc-start -n ${2}"
                        sudo lxc-start -d -n ${2}
                        sleep 1
                        sudo lxc-list
                        shift
                        shift
                        ;;
        -[Ss][Tt][Aa][Tt][Uu][Ss])
                        echo "lxc-list"
                        sudo lxc-info -n ${2}
                        shift
                        shift
                        ;;
        -[Ll][Oo][Gg][Ii][Nn])
                        echo "lxc-console -n ${2}"
                        sudo lxc-console -n ${2}
                        shift
                        shift
                        ;;
        -[Vv][Nn][Cc])
                        vncviewer -AutoSelect=0 -FullColour 10.0.3.30:1
                        shift
                        ;;
        *)
                        echo "${0} -list"
                        echo "${0} -start [ContainerName]"
                        echo "${0} -stop [ContainerName]"
                        echo "${0} -restart [ContainerName]"
                        echo "${0} -status [ContainerName]"
                        shift
                        exit 1
                        ;;
esac

