~ubuntu-branches/ubuntu/quantal/lxc/quantal-201205292108

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/sh

set -e

_PROGRAM="${1}"

if [ -n "${_PROGRAM}" ]
then
	shift
else
	echo "Usage: ${0} PROGRAM CONTAINER"
	exit 1
fi

if [ ! -x "$(which lxc-${_PROGRAM} 2>/dev/null)" ]
then
	echo "E: lxc-${_PROGRAM} - no such program" >&2
	exit 1
fi

_CONTAINER="${1}"

if [ -n "${_CONTAINER}" ]
then
	shift

	if ! lxc-ls | grep -qs ^${_CONTAINER}$
	then
		echo "E: ${_CONTAINER} - no such container" >&2
		exit 1
	fi

	_OPTIONS="--name ${_CONTAINER}"
else
	case "${_PROGRAM}" in
		backup|list|restore)
			;;

		*)
			echo "Usage: ${0} PROGRAM CONTAINER"
			exit 1
			;;
	esac
fi

lxc-${_PROGRAM} ${_OPTIONS} ${@}