Skip to content

Instantly share code, notes, and snippets.

@danielbeardsley

danielbeardsley/README.md

Last active Dec 20, 2015
Embed
What would you like to do?
A bash script to temporarily slow down your intertubes on MacOS.

slow-it-down

Simulate a slow network connection with one command.

Turn on:

$> sudo ./slow-it-down
Your tubes are now filled with molasses

Oh snap, the internet is like 1998, turn it off:

$> sudo ./slow-it-down
Your tubes will be unclogged:
Are you sure? [yn] y

Flushed all rules.
#!/bin/sh
if [[ "$1" == -h* ]]; then
echo "Slows down your internet connection to approx 800kbps."
echo "Usage: sudo $0"
echo " Each invocation toggles the state of the slowdown on or off."
echo "Note: you'll likely have to sudo this this script"
exit 1
fi
output=$(ipfw show 2>&1)
if [ "$?" != 0 ]; then
echo "Got this error when running ipfw:"
echo $output
echo "You likely have to use sudo this script: sudo $0"
exit 1
fi
echo "$output" | grep 00100 >/dev/null
found=$?
if [ "$found" = 0 ]; then
echo "Your tubes will be unclogged:"
ipfw flush
else
echo "Your tubes are now filled with molasses"
ipfw add pipe 1 all from any to any >/dev/null
ipfw pipe 1 config bw 800Kbit/s >/dev/null
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment