#!/bin/sh

INTERFACE=$(fw_printenv -n cv_tcpdump_itf 2>/dev/null || echo "eth0")
OUTPUT=$(fw_printenv -n cv_tcpdump_outurl 2>/dev/null || echo "/data/user/B/Netdata.pcap0")

if [ "$(fw_printenv -n cv_tcpdump_atboot 2>/dev/null)" = "1" ]; then
    while [ ! -d /sys/class/net/"$INTERFACE" ]; do
        sleep 1
    done

    echo tcpdump -i "$INTERFACE" -W 1 -G 180 -w "$OUTPUT"
    tcpdump -i "$INTERFACE" -W 1 -G 180 -w "$OUTPUT" &
fi
