forked from aslanpour/faasHouse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
btmux.sh
executable file
·74 lines (52 loc) · 1.33 KB
/
btmux.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/bash
#delete leftovers
tmux kill-session -t mysession
# create a new tmux session
tmux new-session -d -s mysession
# create 4 rows
tmux split-window -v
tmux split-window -v
tmux split-window -v
tmux split-window -v
#split first row to 2 rows
tmux select-pane -t 0
tmux split-window -v
#now, there are 5 rows and 2 columns.
#select each row first pane, and split it in 2 columns
tmux select-pane -t 0
tmux split-window -h
# tmux resize-pane -y 5
tmux select-pane -t 2
tmux split-window -h
# tmux resize-pane -y 5
tmux select-pane -t 4
tmux split-window -h
# tmux resize-pane -y 5
tmux select-pane -t 6
tmux split-window -h
# tmux resize-pane -y 5
tmux select-pane -t 8
tmux split-window -h
# tmux resize-pane -y 5
#run commands in each pane
for i in {0..9}
do
#select pane
tmux select-pane -t $i
#run ssh
tmux send-key "ssh [email protected]$i" Enter
#if no argument passed, kill hedgi and re-run it, monitor it
if [ "$#" -eq 0 ]; then
#kill hedgi
tmux send-key "kill -9 \$(ps -aux |grep hedgi | awk '{print \$2}')" Enter
#run hedgi
tmux send-key "python3 hedgi.py" Enter
#else if arguemtn is passed and it is tail, observe logs
else
tmux send-key "tail -F /home/ubuntu/logs/hedgi.log" Enter
fi
done
# attach to the new session
tmux attach-session -t mysession
#to close
#tmux kill-session -t mysession