-
-
Save boltronics/2626013 to your computer and use it in GitHub Desktop.
Vagrant fix for instances getting stuck on boot due to DHCP failure.
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 | |
# | |
# Adam Bolte <[email protected]> | |
# | |
# Description: | |
# Run this if Vagrant gets stuck bringing up an instance due to DHCP failure. | |
declare -r fix_instance=$(basename $(pwd)) | |
for instance in $(VBoxManage list runningvms | grep ${fix_instance} | \ | |
sed -e 's/^"\([^"]*\)".*/\1/') | |
do | |
if [ "${fix_instance}" = "${instance%_*}" ] | |
then | |
echo -n "Fixing '${instance}'... " | |
VBoxManage guestcontrol ${instance} exec "/usr/bin/sudo" \ | |
--username vagrant --password vagrant --wait-stdout \ | |
dhclient -- eth0 | |
if [ "${?}" -eq 0 ] | |
then | |
echo "OK." | |
else | |
echo "FAIL." | |
fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment