Guest User

Untitled

a guest
Mar 2nd, 2010
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.56 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3. # Usage: kktoggle reddit.com
  4. # Change kkdiz for your favorite text-to-speech synthesizer
  5.  
  6. if [ $# == 0 ]; then echo $0 '<site>'; exit 1; fi
  7.  
  8. 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}')
  9. if [[ $(echo $linha | grep $1) ]]; then kkdiz "BLOCKED: $1"; else kkdiz "UNBLOCKED: $1"; fi
  10.  
  11. temp=$(mktemp)
  12. echo $linha > $temp
  13. cat /etc/hosts | grep -v 127.0.0.1 >> $temp
  14. sudo mv $temp /etc/hosts
Advertisement
Add Comment
Please, Sign In to add comment