Skip to content

Instantly share code, notes, and snippets.

@Darkless012
Created May 9, 2017 16:14
Show Gist options
  • Save Darkless012/04c62920c38521bca404696b870415e0 to your computer and use it in GitHub Desktop.
Save Darkless012/04c62920c38521bca404696b870415e0 to your computer and use it in GitHub Desktop.
Bash script that add simulation of delay on localhost and remove it on exit
#!/bin/bash
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m'
set -e
function cleanup {
echo -e "${RED}Removing delay from localhost"
echo -e "-----------------------------${NC}"
sudo tc qdisc del dev lo root netem
sudo tc -s qdisc
echo -e "${RED}-----------------------------${NC}"
}
trap cleanup EXIT
echo -e "${GREEN}Adding delay from localhost"
echo -e "---------------------------${NC}"
sudo tc qdisc add dev lo root netem delay 500ms
sudo tc -s qdisc
echo -e "${GREEN}---------------------------${NC}"
echo -e "Press ${RED}CTRL + C ${NC} to stop..."
while true; do sleep 1; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment