4
# Check for, and set up 6 windows in tmux such that:
6
# 0 - 'juju' - runs ./watch-juju-stat.sh
7
# 1 - 'hosts' - runs ./watch-hosts.sh
8
# 2 - 'nova' - runs ./watch-nova.sh
9
# 3 - 'edit' - just ensures that the window is created and named.
10
# 4 - 'run' - just ensures that the window is created and named.
11
# 5 - 'other' - just ensures that the window is created and named.
13
# Also ensures that in each of the windows the ~/novarc file has been sourced.
15
function create_if_needed {
16
local _window_number=$1
17
local _window_title=$2
18
local _line=$(tmux list-windows | egrep "^${_window_number}:")
20
if [ "xxx${_line}" == "xxx" ]; then
22
tmux new-window -t ":${_window_number}" -n ${_window_title}
24
echo "Found making sure it is named ${_window_title}"
25
tmux rename-window -t ":${_window_number}" ${_window_title}
30
# Ensure that the windows are created and that they are named correctly.
31
create_if_needed "0" "juju"
32
create_if_needed "1" "hosts"
33
create_if_needed "2" "nova"
34
create_if_needed "3" "edit"
35
create_if_needed "4" "run"
36
create_if_needed "5" "other"
38
# now ensure that all the windows have sourced ~/novarc and that the first three are running
40
NOVARC="source $HOME/novarc"
41
BEISNER_SCRIPTS="$HOME/beiser-yunk-yard/serverstack-scripts"
42
JUJU_STAT="$BEISNER_SCRIPTS/watch-juju-stat.sh"
43
NOVA="$BEISNER_SCRIPTS/watch-nova.sh"
44
HOSTS="$BEISNER_SCRIPTS/watch-hosts.sh"
46
tmux send-keys -t :0 C-c; tmux send-keys -t :0 "$NOVARC" C-m; tmux send-keys -t :0 "$JUJU_STAT" C-m
47
tmux send-keys -t :1 C-c; tmux send-keys -t :1 "$NOVARC" C-m; tmux send-keys -t :1 "$HOSTS" C-m
48
tmux send-keys -t :2 C-c; tmux send-keys -t :2 "$NOVARC" C-m; tmux send-keys -t :2 "$NOVA" C-m
50
tmux select-window -t :0