summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xlib/container/list31
1 files changed, 29 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