summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xlib/container/list31
-rw-r--r--share/man/container-list.1.txt3
2 files changed, 32 insertions, 2 deletions
diff --git a/lib/container/list b/lib/container/list
index 7d66da1..506340e 100755
--- a/lib/container/list
+++ b/lib/container/list
@@ -20,12 +20,13 @@ set -e
COMMAND="$(basename ${0})"
+CONFIG="/etc/container-tools/config"
MACHINES="/var/lib/machines"
Parameters ()
{
- LONG_OPTIONS="all,format:,started,stopped"
- OPTIONS="a,f:,s,t"
+ LONG_OPTIONS="all,format:,host:,started,stopped"
+ OPTIONS="a,f:,h:,s,t"
PARAMETERS="$(getopt --longoptions ${LONG_OPTIONS} --name=${COMMAND} --options ${OPTIONS} --shell sh -- ${@})"
@@ -50,6 +51,11 @@ Parameters ()
shift 2
;;
+ -h|--host)
+ HOST="${2}"
+ shift 2
+ ;;
+
-s|--started)
LIST="started"
shift 1
@@ -83,6 +89,7 @@ Parameters "${@}"
LIST="${LIST:-all}"
FORMAT="${FORMAT:-full}"
+HOST="${HOST:-$(hostname -f)}"
# Run
case "${FORMAT}" in
@@ -108,6 +115,26 @@ CONTAINERS="$(cd "${MACHINES}" 2>/dev/null && find -maxdepth 1 -type d -and -not
for CONTAINER in ${CONTAINERS}
do
+ if [ "${HOST}" != "all" ]
+ then
+ if [ -e "${CONFIG}/${CONTAINER}.conf" ]
+ then
+ AUTO="$(awk -F= '/^cnt.auto=/ { print $2 }' ${CONFIG}/${CONTAINER}.conf)"
+ AUTO="${AUTO:-false}"
+
+ case "${AUTO}" in
+ ${HOST}|true)
+ ;;
+
+ *)
+ continue
+ ;;
+ esac
+ else
+ continue
+ fi
+ fi
+
# FIXME: ignore lxc container for now
if [ -e "${MACHINES}/${CONTAINER}/rootfs" ]
then
diff --git a/share/man/container-list.1.txt b/share/man/container-list.1.txt
index 4d8bc72..77403a2 100644
--- a/share/man/container-list.1.txt
+++ b/share/man/container-list.1.txt
@@ -47,6 +47,9 @@ The following container options are available:
*-f, --format='FORMAT'*::
Use format to list container. Currently available formats are 'short' or 'full' (default).
+*-h, --host='HOSTNAME'*::
+ List only container that are enabled for automatic start on the specified hostname. Defaults to list containers of the local system only. Using 'all' shows all container regardless of any automatic start configuration.
+
*-s, --started*::
List only started container.