Skip to content

Instantly share code, notes, and snippets.

@smoitra87
Created November 7, 2013 01:59
Show Gist options
  • Save smoitra87/7347687 to your computer and use it in GitHub Desktop.
Save smoitra87/7347687 to your computer and use it in GitHub Desktop.
Toggle gmail in /etc/hosts
#!/bin/sh
if [ -n "$(grep gmail /etc/hosts)" ]
then
echo "Gmail found : $(grep gmail /etc/hosts)"
echo "Removing gmail"
sed '/gmail/d' /etc/hosts > /tmp/gmailtoggle
sudo cp /tmp/gmailtoggle /etc/hosts
else
echo "Gmail not found, Adding gmail"
sudo echo -e "127.0.0.1\twww.gmail.com" >> /etc/hosts
fi
# Restarting network
sudo /etc/init.d/networking restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment