forked from navarrothiago/upf-bpf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start_session
executable file
·107 lines (89 loc) · 3.59 KB
/
start_session
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/bin/bash
# ==============================================
# Author: Thiago Navarro
# email: [email protected]
#
# Script for testbed.
# Run the server and client on remote servers.
# Run control plane on dut.
#
# Packages required: tmux
#
# TODO:
#=============================================
#Create remote session with panes
initialize() {
echo "Initializing on session "${session_name}"..."
# Initialize windowns and panes
tmux kill-session -t $session_name -n testbed 2>/dev/null
# Create window 0
tmux -2 new-session -d -s $session_name
tmux rename-window -t 0 'Testbed'
# Create window 1
tmux new-window -d -t $session_name -n 'Local'
# Create window 2
tmux new-window -d -t $session_name -n 'Trex Server'
# Create window 3
tmux new-window -d -t $session_name -n 'SSH Tunnel'
# Configure layout
tmux split-window -t $session_name:0.0 -h
tmux split-window -t $session_name:0.1 -v
tmux split-window -t $session_name:0.1 -v
tmux resize-pane -t $session_name:0.0 -L 10
# Select window 0 pane 2
tmux select-pane -t "$session_name":0.2
tmux send-keys -t $session_name:2.0 ""${dirname}"/install_trex_remote" C-m
tmux send-keys -t $session_name:2.0 ""${dirname}"/deploy_trex_config" C-m
tmux send-keys -t $session_name:2.0 ""${dirname}"/run_trex_server" C-m "${SERVER_PASSWORD}" C-m
tmux send-keys -t $session_name:2.0 ""${SERVER_PASSWORD}"" C-m
tmux send-keys -t $session_name:0.1 "ssh "${DUT_NAME}"" C-m
tmux send-keys -t $session_name:0.2 "ssh "${DUT_NAME}"" C-m
tmux send-keys -t $session_name:0.3 "ssh "${DUT_NAME}"" C-m
tmux send-keys -t $session_name:3.0 "ssh -L "${LOCAL_HTTP_SSH_PORT_FORWARDING}":"${DUT_IP}":"${API_HTTP_PORT}" -L "${LOCAL_TREX_SYNC_SSH_PORT_FORWARDING}":"${TREX_SERVER_IP}":"${TREX_SERVER_SYNC_PORT}" -L "${LOCAL_TREX_ASYNC_SSH_PORT_FORWARDING}":"${TREX_SERVER_IP}":"${TREX_SERVER_ASYNC_PORT}" -N "${JUMP_SERVER_NAME}" -v -v" C-m
# Wait the trex server startup for 5s.
tmux send-keys -t $session_name:0.0 "sleep 15; cd "${dirname}"/../trex/"${TREX_VERSION}"; ./trex-console --port "${LOCAL_TREX_SYNC_SSH_PORT_FORWARDING}" --async_port "${LOCAL_TREX_ASYNC_SSH_PORT_FORWARDING}"" C-m
# tmux send-keys -t $session_name:0.1 "cd "${DUT_UPLOAD_DIR}"; sudo ip link set dev enp3s0f1 xdp off; sudo ip link set dev enp3s0f0 xdp off; make dut-run" C-m "${SERVER_PASSWORD}" C-m
tmux send-keys -t $session_name:0.1 "cd "${DUT_UPLOAD_DIR}"; sudo ip link set dev enp3s0f1 xdp off; sudo ip link set dev enp3s0f0 xdp off; sudo ./bin/"${API_PROGRAM_NAME}" "${DUT_IP}" "${API_HTTP_PORT}"" C-m "${SERVER_PASSWORD}" C-m
tmux send-keys -t $session_name:0.2 "mpstat -P ALL 3" C-m
}
attach() {
echo "Attaching on session "${session_name}"..."
tmux select-pane -t $session_name:0.0
tmux -2 attach-session -t $session_name
}
stop() {
echo "Stopping on session "${session_name}"..."
}
force_kill() {
echo "Killing on session "${session_name}"..."
sleep 2
tmux kill-session -t $session_name 2>/dev/null
}
main() {
# set -o errexit
set -o pipefail
set -o nounset
# set -x
local -r dirname="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
local -r filename="${dirname}/$(basename "${BASH_SOURCE[0]}")"
local -r session_name="upf-bpf"
source "${dirname}"/../../env.sh
# if [[ $# != 4 ]]; then
# echo >&2 "TODO!! "
# echo >&2 "e.g. ./vms-session epc 127.0.0.1 enodeb 127.0.0.2"
# exit 1
# fi
echo -n "Enter the server admin password:"
echo
read -s SERVER_PASSWORD
# echo -n "Enter the local password:"
# echo
# read -s LOCAL_PASSWORD
# Enable nested tmux session.
unset TMUX
initialize
attach
stop
force_kill
}
main "$@"