Remove davical upgrade log on package removal.
[davical.git] / testing / watch-port-80.sh
blob7ec7e856d5398dd3716fc60b2b7ce1845228956e
1 #!/bin/sh
3 PORT=${1:-"80"}
4 IFACE=${2:-"any"}
5 IP=${3:-""}
7 # Only include packets that contain data
8 NOTSYNFIN=" and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)"
9 DUMP="tcp port ${PORT}"
11 IPCLAUSE=""
12 if [ "${IFACE}" != "any" ]; then
13 if [ -z "${IP}" ]; then
14 IP="`ip addr show dev ${IFACE} | grep ' inet ' | tr -s ' ' | cut -f3 -d' ' | cut -f1 -d'/'`"
16 IPCLAUSE=" and ((src host ${IP} and src port ${PORT}) or (dst host ${IP} and dst port ${PORT}))"
19 DUMPFILE="dumps/`date '+%FT%T'`.dump"
21 # touch "${DUMPFILE}"
22 sudo tcpdump -i $IFACE -s0 -l -n -q -A "${DUMP}${NOTSYNFIN}${IPCLAUSE}" >"${DUMPFILE}" 2>&1 &
23 DUMPPID="$!"
25 less "${DUMPFILE}"
27 sudo kill "${DUMPPID}"
29 if [ "`stat --format='%s' \"${DUMPFILE}\"`" -le 230 ] ; then
30 rm "${DUMPFILE}"