-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathteardown-lte.sh
78 lines (68 loc) · 2.49 KB
/
teardown-lte.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
74
75
76
77
78
#!/bin/bash
# cellular-satcom-emulator : Multipath Cellular and Satellite Emulation Testbed
# Copyright (C) 2023 Kaushik Chavali
#
# This file is part of the cellular-satcom-emulator.
#
# cellular-satcom-emulator is free software: you can redistribute it
# and/or modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# _moon_teardown_capture()
# Stop capturing packets
function _moon_teardown_capture() {
local logged=false
for entity in cl sv; do
local session="tcpdump-${entity}"
tmux -L ${TMUX_SOCKET} has-session -t ${session} >/dev/null 2>&1
if [ "$?" -gt 0 ]; then
if [[ "$logged" == false ]]; then
log D "Stopping tcpdump"
logged=true
fi
log D "Stopping $session"
tmux -L ${TMUX_SOCKET} send-keys -t ${session} C-c
sleep $CMD_SHUTDOWN_WAIT
tmux -L ${TMUX_SOCKET} send-keys -t ${session} C-d
sleep $CMD_SHUTDOWN_WAIT
tmux -L ${TMUX_SOCKET} kill-session -t ${session} >/dev/null 2>&1
fi
done
}
# moon_teardown()
# Teardown the entire emulation environment.
function moon_teardown() {
log I "Tearing down emulation environment"
moon_teardown_moongen
sleep $CMD_SHUTDOWN_WAIT
_moon_teardown_capture
moon_teardown_namespaces
log D "Environment teared down"
}
# If script is executed directly
if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then
declare -F log >/dev/null || function log() {
local level="$1"
local msg="$2"
echo "[$level] $msg"
}
export SCRIPT_VERSION="manual"
export SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
export CONFIG_DIR="${SCRIPT_DIR}/config"
set -a
source "${CONFIG_DIR}/testbed-config.sh"
set +a
source "${SCRIPT_DIR}/teardown-moongen.sh"
source "${SCRIPT_DIR}/teardown-lte-namespaces.sh"
osnd_teardown "$@"
# Ensure all tmux sessions are closed
tmux -L ${TMUX_SOCKET} kill-server &>/dev/null
fi