Skip to content

Commit

Permalink
bash functions for docker-machine cluster management, issue #7
Browse files Browse the repository at this point in the history
  • Loading branch information
dmcsorley committed Jan 18, 2016
1 parent b9d3330 commit cd36363
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/docker-machines
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit cd36363

Please sign in to comment.