Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #
- # Usage: kktoggle reddit.com
- # Change kkdiz for your favorite text-to-speech synthesizer
- if [ $# == 0 ]; then echo $0 '<site>'; exit 1; fi
- linha=$(cat /etc/hosts | awk -v alvo="$1" '/127.0.0.1/ {frase=$1;for (i=2;i<=NF;i++) if ($i !~ alvo) frase=frase " " $i;else{apareceu=1}}; END{if (!apareceu) frase=frase " "alvo" www."alvo; print frase}')
- if [[ $(echo $linha | grep $1) ]]; then kkdiz "BLOCKED: $1"; else kkdiz "UNBLOCKED: $1"; fi
- temp=$(mktemp)
- echo $linha > $temp
- cat /etc/hosts | grep -v 127.0.0.1 >> $temp
- sudo mv $temp /etc/hosts
Advertisement
Add Comment
Please, Sign In to add comment