Harald Welte | e057146 | 2018-02-14 15:42:14 +0100 | [diff] [blame^] | 1 | #!/bin/sh |
| 2 | |
| 3 | PIDFILE=/tmp/tcpdump.pid |
| 4 | TESTCASE=$1 |
| 5 | |
| 6 | if [ "z$TTCN3_PCAP_PATH" = "z" ]; then |
| 7 | TTCN3_PCAP_PATH=/tmp |
| 8 | fi |
| 9 | |
| 10 | if [ -e $PIDFILE ]; then |
| 11 | kill "$(cat "$PIDFILE")" |
| 12 | rm $PIDFILE |
| 13 | fi |
| 14 | |
| 15 | # NOTE: This requires you to be root or something like |
| 16 | # "laforge ALL=NOPASSWD: /usr/sbin/tcpdump, /bin/kill" in your sudoers file |
| 17 | if [ "$(id -u)" = "0" ]; then |
| 18 | CMD=/usr/sbin/tcpdump |
| 19 | else |
| 20 | CMD="sudo /usr/sbin/tcpdump" |
| 21 | fi |
| 22 | $CMD -s 0 -n -i any -w "$TTCN3_PCAP_PATH/$TESTCASE.pcap" >/dev/null 2>&1 & |
| 23 | PID=$! |
| 24 | echo $PID > $PIDFILE |