From 90e9e7032a19e331332765495057d177ef4fde78 Mon Sep 17 00:00:00 2001 From: Monocots Date: Tue, 25 Oct 2022 15:33:10 +0000 Subject: [PATCH] shell utility functions: add, improve Add a function to open 4 common osmo vtys and make sure these tmux functions don't open new sessions if the session already exists --- .../templates/rccn-functions.sh.erb | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/modules/rhizo_base/templates/rccn-functions.sh.erb b/modules/rhizo_base/templates/rccn-functions.sh.erb index 00427c7..b083c6d 100644 --- a/modules/rhizo_base/templates/rccn-functions.sh.erb +++ b/modules/rhizo_base/templates/rccn-functions.sh.erb @@ -79,6 +79,11 @@ o() { } f() { + tmux has-session -t SIP 2>/dev/null + if [ $? -eq 0 ] ; then + tmux a -t SIP + return + fi tmux new-session -n SIP "sudo sngrep -d any" \; splitw -p 60 "fs_cli -r" \; select-window -t SIP \; } @@ -110,8 +115,41 @@ b<%= index %>() { } <% end -%> +vt () +{ + tmux has-session -t vtys 2>/dev/null + if [ $? -eq 0 ] ; then + tmux a -t vtys + return + fi + tmux start-server; + tmux new -s vtys -d -n VTY "vty bsc $*"; + for vty in msc mgw hlr; + do + if [ "$vty" == "msc" ]; then + pane=0; + fi; + if [ "$vty" == "hlr" ]; then + pane=2; + fi; + if [ "$vty" == "mgw" -o "$vty" == "hlr" ]; then + split=h; + else + split=v; + fi; + tmux split-window -t $pane -$split "vty $vty $*"; + done; + tmux select-pane -t:.0 + tmux attach -t vtys ; +} + bA() { source /home/rhizomatica/bin/vars.sh + tmux has-session -t bts 2>/dev/null + if [ $? -eq 0 ] ; then + tmux a -t bts + return + fi tmux start-server tmux new -s bts -d -n BTS0 "source /etc/profile.d/rccn-functions.sh ; b0 $*" # This won't look great for more than 4 windows, but