Created
May 9, 2017 16:14
-
-
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
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 | |
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