-
Notifications
You must be signed in to change notification settings - Fork 11
/
run.sh
executable file
·56 lines (45 loc) · 1.21 KB
/
run.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
#!/bin/sh
set -x
# FIX: since tshark wont write to a directory that is not owned by the user
# executing the command
chown root:root /data
INTERFACE=""
BUFFEROPTS=""
for INTERFACE in $IFACE;
do
INTERFACES="$INTERFACES -i $INTERFACE"
done
# -b filesize:
# max file size (creates new file counting up, unit 1 = 1,000
# bytes))
# files: max number of created files (rotating buffer since files from the
# beginning are overwritten)
# duratioin: number of seconds that a file will be kept before rotating
# -w writing the raw packets to a file rather than to stdout
if [ -n "$MAXFILESIZE" ];
then
BUFFEROPTS="$BUFFEROPTS -b filesize:${MAXFILESIZE}000"
fi
if [ -n "$MAXFILENUM" ];
then
BUFFEROPTS="$BUFFEROPTS -b files:$MAXFILENUM"
fi
# interval and duration cannot be set at the same time
if [ -n "$DURATION" ] && [ -z "$INTERVAL" ];
then
BUFFEROPTS="$BUFFEROPTS -b duration:$DURATION"
fi
if [ -n "$INTERVAL" ];
then
BUFFEROPTS="$BUFFEROPTS -b interval:$INTERVAL"
fi
if [ -n "$SNAPLENGTH" ];
then
SNAPLENGTH="-s $SNAPLENGTH"
fi
PCAPNG=""
if [ "$FORMAT" = "pcap" ];
then
PCAPNG="-P"
fi
/usr/bin/dumpcap $PCAPNG $BUFFEROPTS -w "/data/$FILENAME" -f "$FILTER" $INTERFACES $SNAPLENGTH