From 1d935357b0eae74e08775c5685999bb06e49ec2b Mon Sep 17 00:00:00 2001 From: Jason Smith Date: Thu, 5 Nov 2015 16:46:28 -0800 Subject: [PATCH] add tmux syncd panes for consul --- discovery/consul-ssh-sync | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 discovery/consul-ssh-sync diff --git a/discovery/consul-ssh-sync b/discovery/consul-ssh-sync new file mode 100755 index 0000000..d0f06ad --- /dev/null +++ b/discovery/consul-ssh-sync @@ -0,0 +1,24 @@ +#!/bin/bash + +DC=$1 +HOST=$2 +SSH_PARAMS=$3 +SESSION_NAME="TMUX_${HOST}" + +tmux has-session -t ${SESSION_NAME} + +if [ $? != 0 ]; then + window=1 + tmux new-session -s ${SESSION_NAME} -n ${HOST} -d + for i in `consul-list --dc $DC -H $HOST -o Node` ; do + tmux new-window -n ${HOST} -t $SESSION_NAME "ssh ${SSH_PARAMS} $i" + tmux join-pane -t 1 + tmux setw synchronize-panes + tmux select-layout even-vertical + window=$((window+1)) + done + tmux kill-window -t ${SESSION_NAME}:0 + tmux select-window -t ${SESSION_NAME}:1 +fi + +tmux attach -t ${SESSION_NAME}