Skip to content

Instantly share code, notes, and snippets.

@therobot
Forked from afgomez/lets.sh
Created December 23, 2010 14:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save therobot/753068 to your computer and use it in GitHub Desktop.
Save therobot/753068 to your computer and use it in GitHub Desktop.
#!/bin/bash
# lets. A productivity booster
# based on ideas from https://gist.github.com/605292
#
# Copy your /etc/hosts to /etc/hosts.play and create a new one called /etc/hosts.work with a list of blocked sites
# Usage: sudo lets [play|work]
if [ $# = 0 ]
then
echo "Don't know what I must do!" >&2
exit 1
fi
if [ $UID -ne 0 ]
then
echo "Use me with sudo!" >&2
exit 2
fi
HOSTS=/etc/hosts
ORIGIN="$HOSTS.$1"
if [ -e $ORIGIN ]
then # Let's do something!!
if [ `uname` = Darwin ]
then
FLUSH="$(which dscacheutil) -flushcache"
fi
rm $HOSTS && cp $ORIGIN $HOSTS && echo "Let's $1!"
$FLUSH
else
echo "Ooops, don't know how to do $1!"
exit 3
fi
@therobot
Copy link
Author

Creo que en linux sólo hay que limpiarla si hay un servidor de cache instalado. Habría que comprobar eso.

http://www.ubuntugeek.com/howto-clearflush-dns-cache-in-ubuntu.html

Por otro lado, recuerdo que había alguien que había hecho ya esto, pero ahora no encuentro en enlace.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment