Last active
August 29, 2015 14:21
-
-
Save whitekid/ea78bb56d5bd901187dc to your computer and use it in GitHub Desktop.
automatically update boot2docker ip in /etc/hosts
This file contains hidden or 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 | |
# Usage: | |
# git clone https://gist.github.com/ea78bb56d5bd901187dc.git docker.gist | |
# mkdir ~/bin | |
# ln -s docker.gist/docker.sh ~/bin/docker | |
# export PATH=$PATH:~/bin | |
/usr/local/bin/docker "$@" | |
r=$? | |
update_boot2docker_ip() { | |
IP=`boot2docker ip` | |
if grep -q 'boot2docker$' /etc/hosts; then | |
sudo sed -i '' -E "s/^[0-9\.]+ boot2docker$/${IP/./\\.} boot2docker/" /etc/hosts | |
else | |
sudo sh -c "echo '${IP} boot2docker' >> /etc/hosts" | |
fi | |
} | |
if [ $r == "0" ]; then | |
update_boot2docker_ip | |
fi | |
exit $r |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment