diff options
Diffstat (limited to 'src/manage.sh')
-rwxr-xr-x | src/manage.sh | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/src/manage.sh b/src/manage.sh index 9123cb8..d6fb813 100755 --- a/src/manage.sh +++ b/src/manage.sh @@ -57,12 +57,32 @@ deploy_all() { done } +generate_instance_list() { + machine=$1 + + rm -f "$OUTPUT_DIR/$machine.list" + touch "$OUTPUT_DIR/$machine.list" + if [ -d "$OUTPUT_DIR/$machine/managers" ]; then + for name in "$OUTPUT_DIR/$machine/managers/"*; do + name=`basename "$name"` + echo "manager $name" >> "$OUTPUT_DIR/$machine.list" + done + fi + for name in "$OUTPUT_DIR/$machine/workers/"*.xml; do + name=`basename "$name"` + name=${name%%.xml} + echo "worker $name" >> "$OUTPUT_DIR/$machine.list" + done +} + start_all() { for machine in "$OUTPUT_DIR"/*; do if [ -d "$machine" ] && [ -d "$machine/managers" ]; then machine=`basename $machine` echo " $machine (manager, worker)" - ssh -i "$SSH_KEY" -F "$SSH_CONFIG" $SSH_USER@"$machine" start + generate_instance_list $machine + ssh -i "$SSH_KEY" -F "$SSH_CONFIG" $SSH_USER@"$machine" start < "$OUTPUT_DIR/$machine.list" + rm "$OUTPUT_DIR/$machine.list" break fi done @@ -70,7 +90,9 @@ start_all() { if [ -d "$machine" ] && [ ! -d "$machine/managers" ]; then machine=`basename $machine` echo " $machine (worker)" - ssh -i "$SSH_KEY" -F "$SSH_CONFIG" $SSH_USER@"$machine" start + generate_instance_list $machine + ssh -i "$SSH_KEY" -F "$SSH_CONFIG" $SSH_USER@"$machine" start < "$OUTPUT_DIR/$machine.list" + rm "$OUTPUT_DIR/$machine.list" break fi done @@ -81,7 +103,9 @@ stop_all() { if [ -d "$machine" ] && [ ! -d "$machine/managers" ]; then machine=`basename $machine` echo " $machine (worker)" - ssh -i "$SSH_KEY" -F "$SSH_CONFIG" $SSH_USER@"$machine" stop + generate_instance_list $machine + ssh -i "$SSH_KEY" -F "$SSH_CONFIG" $SSH_USER@"$machine" stop < "$OUTPUT_DIR/$machine.list" + rm "$OUTPUT_DIR/$machine.list" break fi done @@ -89,7 +113,9 @@ stop_all() { if [ -d "$machine" ] && [ -d "$machine/managers" ]; then machine=`basename $machine` echo " $machine (manager, worker)" - ssh -i "$SSH_KEY" -F "$SSH_CONFIG" $SSH_USER@"$machine" stop + generate_instance_list $machine + ssh -i "$SSH_KEY" -F "$SSH_CONFIG" $SSH_USER@"$machine" stop < "$OUTPUT_DIR/$machine.list" + rm "$OUTPUT_DIR/$machine.list" break fi done |