-
Notifications
You must be signed in to change notification settings - Fork 5
/
trafficgen-server-stop
executable file
·57 lines (52 loc) · 1.11 KB
/
trafficgen-server-stop
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
#!/bin/bash
exec >trafficgen-server-stop-stderrout.txt
exec 2>&1
. /usr/bin/trafficgen-base || (echo "/usr/bin/trafficgen-base not found"; exit 1)
# Defaults
switch_type="testpmd"
# Options processing
re='^(--[^=]+)=([^=]+)'
while [ $# -gt 0 ]; do
if [[ "$1" =~ $re ]]; then
arg="${BASH_REMATCH[1]}"
val="${BASH_REMATCH[2]}"
shift
else
arg="$1"
shift
val="$1"
shift
fi
case "$arg" in
--switch-type)
switch_type="$val" # Can be "testpmd" or "null"
;;
esac
done
case "${switch_type}" in
"testpmd")
echo "Stopping testpmd"
if [ -e trafficgen-server.pid ]; then
pid=`cat trafficgen-server.pid`
echo "Going to kill pid $pid"
kill -15 $pid
sleep 3
if [ -e /proc/$pid ]; then
echo "PID $pid still exists, trying kill -9"
kill -9 $pid
fi
else
echo "trafficgen-server.pid not found"
echo "PWD: `/bin/pwd`"
echo "LS: `/bin/ls`"
exit 1
fi
;;
"null")
echo "Null switch type, nothing to do"
;;
*)
echo "ERROR: Unknown switch type '${switch_type}'"
exit 1
;;
esac