Skip to content

Instantly share code, notes, and snippets.

@emerleite
Created September 24, 2010 15:48
Show Gist options
  • Save emerleite/595580 to your computer and use it in GitHub Desktop.
Save emerleite/595580 to your computer and use it in GitHub Desktop.
#!/bin/bash
### BEGIN INFO
# Provides: OSX BandWidth Limitator
# Author: Emerson Macedo - http://github.com/emerleite - http://codificando.com
# Description: Limit bandwidth to test player in slow situations. Tested on OSX
### END INFO
usuage() {
echo "Usuage: sudo ./limit-bandwidth.sh <action> [width]
action {add|remove}
width (when adding) Ex: 25KByte/s" >&2
echo ""
exit 1
}
echo ""
case "$1" in
add)
if [ -z $2 ]
then
usuage
fi
BANDWIDTH=$2
echo "Adding bandwidth limitor ${BANDWIDTH} to ports 80 and 1935"
sudo ipfw pipe 1 config bw $BANDWIDTH
sudo ipfw add 1 pipe 1 src-port 80
sudo ipfw add 2 pipe 1 src-port 1935
;;
remove)
echo "Removing bandwidth limitor ${BANDWIDTH} to ports 80 and 1935"
sudo ipfw delete 1
sudo ipfw delete 2
;;
*)
usuage
;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment