From cd363635a9f92151b77cde1a91b1a48cb750f3fe Mon Sep 17 00:00:00 2001 From: Daniel McSorley Date: Mon, 18 Jan 2016 15:40:42 -0500 Subject: [PATCH] bash functions for docker-machine cluster management, issue #7 --- src/docker-machines | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/docker-machines b/src/docker-machines index 9ba804e..86f0c70 100755 --- a/src/docker-machines +++ b/src/docker-machines @@ -6,21 +6,25 @@ grep_docker_machine_names() { docker-machine ls | grep $1 | awk '{print $1}' } -# only try to run a command on all found machines if not sourced -if [ "$SOURCED" != "sourced" ]; then -if [ "${1}" = "" ]; then -echo "Arguments required" -exit 1 -fi - +on_all_docker_machines() { PATTERN=$1 shift -echo $PATTERN for machine in `grep_docker_machine_names $PATTERN`; do echo $machine eval "$(docker-machine env $machine)" $@ done +} + +# only try to run a command on all found machines if not sourced +if [ "$SOURCED" != "sourced" ]; then +if [ "${1}" = "" ]; then +echo "Arguments required" +exit 1 +fi + +on_all_docker_machines $@ + fi