Last active
October 8, 2015 16:32
-
-
Save thogg4/2130953fde46b5d32ac5 to your computer and use it in GitHub Desktop.
This file contains 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
name=${PWD##*/} | |
if docker-machine ls | grep -q "^$name\s" ; then | |
echo 'machine found' | |
else | |
echo 'machine not found. creating...' | |
docker-machine create --driver virtualbox $name | |
docker-machine ssh $name "sudo curl -o /var/lib/boot2docker/bootsync.sh https://gist.githubusercontent.com/thogg4/81de781d4a21382d1c11/raw/9b342537b42e1b7c595a9e1e112c2a131322fb51/bootsync.sh" | |
docker-machine restart $name | |
fi | |
echo 'setting up env' | |
eval "$(docker-machine env $name)" | |
ip=$(docker-machine ip $name) | |
hosts_count=$( grep -ic "$ip $name" /etc/hosts ) | |
if [ $hosts_count -eq 0 ]; then | |
sudo sed -in "/$name/d" /etc/hosts | |
echo "setting ip address to $name in /etc/hosts" | |
sudo bash -c "echo '$ip $name' >> /etc/hosts" | |
echo "ip written to hosts file" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment