#!/bin/bash
#
# Clears all traffic shapping

DEFDEV=eth0

TEMP=`getopt -o d: -n '$0' -- "$@"`
if [ $? -ne 0 ]; then
	echo "usage: $0 [-d dev]"
	exit 1
fi

eval set -- "$TEMP"

DEV=""

while true; do
	case "$1" in
		-d) DEV=$2; echo "using device $DEV"; shift 2;;
		--) shift; break;;
		*)  echo "Internal error. Help, i don't know what to do!!!"; 
		   exit 1;;
	esac
done

if [ "$DEV" == "" ]; then
	DEV=$DEFDEV
	echo "using default device $DEV"
fi

echo -n "clearing all traffic shaping on device $DEV..."
tc qdisc del dev $DEV root htb
if [ $? -ne 0 ]; then
	echo "Error: I apologize. I could not clear traffic shaping on device $DEV :("
	exit 1
else
	echo "done."
fi
