Created
April 8, 2016 15:41
-
-
Save checco/39907741fa9e8bc8a7133f969ecbaf1b to your computer and use it in GitHub Desktop.
Script that return a list of running Vagrant machine (IP HOSTNAME), so you can copy and paste it on your /etc/hosts
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
#!/bin/bash | |
interface="eth0" | |
hosts=`vagrant status | grep running | awk '{print $1}'` | |
if [ `echo ${hosts} | wc -w` -gt '0' ] | |
then | |
for host in ${hosts} | |
do | |
ip=`echo "ip a sh dev ${interface} | grep 'inet ' | sed 's/\// /g'" | vagrant ssh ${host} | awk '{print $2}'` | |
echo -e "${ip}\t ${host}" | |
done | |
else | |
echo "There are no machines running" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment