forked from alvenwong/MicroBPF
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_slave.sh
43 lines (35 loc) · 814 Bytes
/
run_slave.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
#!/bash/sh
command=$1
port=$2
kill_pid () {
PIDS=$1
function=$2
PID=$(echo "$PIDS" | grep "$function" | awk '{print $2}')
if [ ! -z "$PID" ]; then
echo $PID
sudo kill -9 $PID
fi
sudo_func="sudo ""$2"
PID=$(echo "$PIDS" | grep "$sudo_func" | awk '{print $2}')
if [ ! -z "$PID" ]; then
echo $PID
sudo kill -9 $PID
fi
}
if [ "$command" = "start" ]; then
sudo rm -f /usr/local/bcc/*
cd nic
sudo python client.py &
cd ..
sudo python tcpout.py -p $port -o &
sudo python tcpin.py -p $port -o &
sudo python tcpack.py -p $port -o &
elif [ "$command" = "kill" ]; then
PIDS=$(ps -eaf)
kill_pid "$PIDS" "python client.py"
kill_pid "$PIDS" "python tcpout.py -p 80 -o"
kill_pid "$PIDS" "python tcpin.py -p 80 -o"
kill_pid "$PIDS" "python tcpack.py -p 80 -o"
else
echo "unknown command"
fi