From ca6495519c4c98b192998c639818a39cdfe41e15 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 18 May 2016 15:44:44 +0200 Subject: Adjusting output of additional IP addresses in container list command. Signed-off-by: Daniel Baumann --- lib/container/list | 54 ++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 48 insertions(+), 6 deletions(-) (limited to 'lib/container') diff --git a/lib/container/list b/lib/container/list index 5ab5755..8b55e09 100755 --- a/lib/container/list +++ b/lib/container/list @@ -94,7 +94,7 @@ case "${FORMAT}" in NORMAL="$(tput sgr0)" cat << EOF -Container IPv4 Address Status +Container IPv4 Address(es) Status -------------------------------------------------------------------------------- EOF @@ -118,9 +118,9 @@ do if [ -e "${MACHINES}/${CONTAINER}/etc/network/interfaces" ] then - ADDRESS="$(awk '/address/ { print $2 }' ${MACHINES}/${CONTAINER}/etc/network/interfaces)" + ADDRESSES="$(awk '/address/ { print $2 }' ${MACHINES}/${CONTAINER}/etc/network/interfaces)" else - ADDRESS="n/a" + ADDRESSES="n/a" fi case "${STATE}" in @@ -142,7 +142,21 @@ do ;; full) - printf "%-72s %-29s %-7s\n" "${BLUE}${CONTAINER}${NORMAL}" "${YELLOW}${ADDRESS}${NORMAL}" "${STATUS}" + FIRST_LINE="true" + + for ADDRESS in ${ADDRESSES} + do + case "${FIRST_LINE}" in + true) + FIRST_LINE="false" + printf "%-69s %-29s %-7s\n" "${BLUE}${CONTAINER}${NORMAL}" "${YELLOW}${ADDRESS}${NORMAL}" " ${STATUS}" + ;; + + *) + printf "%-54s %-29s\n" "" "${ADDRESS}" + ;; + esac + done ;; esac ;; @@ -156,7 +170,21 @@ do ;; full) - printf "%-72s %-29s %-7s\n" "${BLUE}${CONTAINER}${NORMAL}" "${YELLOW}${ADDRESS}${NORMAL}" "${STATUS}" + FIRST_LINE="true" + + for ADDRESS in ${ADDRESSES} + do + case "${FIRST_LINE}" in + true) + FIRST_LINE="false" + printf "%-69s %-29s %-7s\n" "${BLUE}${CONTAINER}${NORMAL}" "${YELLOW}${ADDRESS}${NORMAL}" " ${STATUS}" + ;; + + *) + printf "%-54s %-29s\n" "" "${ADDRESS}" + ;; + esac + done ;; esac ;; @@ -175,7 +203,21 @@ do ;; full) - printf "%-72s %-29s %-7s\n" "${BLUE}${CONTAINER}${NORMAL}" "${YELLOW}${ADDRESS}${NORMAL}" "${STATUS}" + FIRST_LINE="true" + + for ADDRESS in ${ADDRESSES} + do + case "${FIRST_LINE}" in + true) + FIRST_LINE="false" + printf "%-69s %-29s %-7s\n" "${BLUE}${CONTAINER}${NORMAL}" "${YELLOW}${ADDRESS}${NORMAL}" " ${STATUS}" + ;; + + *) + printf "%-54s %-29s\n" "" "${ADDRESS}" + ;; + esac + done ;; esac ;; -- cgit v1.2.3