Created
September 10, 2024 02:54
-
-
Save grahamhelton/6cef7df2cc059078ae0702492b6b9f1f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This script compiles tcpdump as a static binary | |
# Useful for running in pods or other places you shouldn't be | |
GREEN=$(tput setaf 2) | |
NOCOLOR=$(tput sgr0) | |
TICK="$NOCOLOR[$GREEN+$NOCOLOR] " | |
spin() { | |
local pid=$! | |
local spin='|/-\' | |
local i=0 | |
while kill -0 $pid 2>/dev/null; do | |
i=$(((i + 1) % 4)) | |
printf "\r${spin:$i:1}" | |
sleep .1 | |
done | |
printf " \r" | |
} | |
echo $TICK"Building tcpdump, please wait...." | |
docker run -v $PWD:/out --rm alpine sh -c ' | |
apk add --update alpine-sdk git libpcap libpcap-dev 1> /dev/null | |
cd /tmp; git clone https://github.com/eldadru/ksniff 1> /dev/null; cd ksniff | |
TCPDUMP_VERSION=4.99.4 | |
make static-tcpdump 1> /dev/null | |
cp static-tcpdump /out | |
' 1> /dev/null 2> >(cat >/dev/null) & | |
spin | |
wait $! | |
echo $TICK"Done!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Picture with pretty colors: