New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script to copy hosts database over to VMs on OS X #28

Closed
htmled opened this Issue Sep 21, 2011 · 6 comments

Comments

Projects
None yet
3 participants
@htmled

htmled commented Sep 21, 2011

It would be nice for OS X users if a script could be run to copy any IPs and hostnames (used for local development) in /etc/hosts over to C:/Windows/System32/drivers/etc/hosts across all VMs. Not sure if this is even possible, but it would save a lot of time.

@drewreece

This comment has been minimized.

Show comment
Hide comment
@drewreece

drewreece Sep 23, 2011

What is required to get the VM's to see the hosts running locally?
Is it just a hostname & IP in the hosts file?
I'd love to get this working, & automation with ievms would be great.

drewreece commented Sep 23, 2011

What is required to get the VM's to see the hosts running locally?
Is it just a hostname & IP in the hosts file?
I'd love to get this working, & automation with ievms would be great.

@drewreece

This comment has been minimized.

Show comment
Hide comment
@drewreece

drewreece Sep 24, 2011

After a little digging…
I have a script ;^)

It is standalone to ievms because you may need to update the VM hosts without doing a rebuild of the VM. It looks like it could integrate with ievms, but I really can't tell if ievms is setting up the guest additions, they seem disabled initially? Perhaps I'm needlessly reinstalling them.

The script relies on your hosts file being set up in a particular way (e.g. using 127.0.0.1 addresses for local domain names). The VM in question also needs to be running.

The script creates a batch file to add the hosts to the host file on the VM. The batch file means that the original can be appended to or overwritten. The default is to overwrite - it suits my purpose but may be unwise for a novice user?

It's full of comments so hack away at it, I use Mac OS 10.6.8 to make it, copying to the Vista & Win 7 versions that ievms uses.

I'm sticking it in my Dropbox for now.
http://dl.dropbox.com/u/59660/hosts-to-vm.zip

Try hosts-to-vm.sh IE7 IE8 IE9 in your Terminal.

PS
I guess it would be nice to add bookmarks for the hostnames but I can't be bothered to figure that out :) It's probably easier to maintain a list in an index.html on the host machine.

drewreece commented Sep 24, 2011

After a little digging…
I have a script ;^)

It is standalone to ievms because you may need to update the VM hosts without doing a rebuild of the VM. It looks like it could integrate with ievms, but I really can't tell if ievms is setting up the guest additions, they seem disabled initially? Perhaps I'm needlessly reinstalling them.

The script relies on your hosts file being set up in a particular way (e.g. using 127.0.0.1 addresses for local domain names). The VM in question also needs to be running.

The script creates a batch file to add the hosts to the host file on the VM. The batch file means that the original can be appended to or overwritten. The default is to overwrite - it suits my purpose but may be unwise for a novice user?

It's full of comments so hack away at it, I use Mac OS 10.6.8 to make it, copying to the Vista & Win 7 versions that ievms uses.

I'm sticking it in my Dropbox for now.
http://dl.dropbox.com/u/59660/hosts-to-vm.zip

Try hosts-to-vm.sh IE7 IE8 IE9 in your Terminal.

PS
I guess it would be nice to add bookmarks for the hostnames but I can't be bothered to figure that out :) It's probably easier to maintain a list in an index.html on the host machine.

@drewreece

This comment has been minimized.

Show comment
Hide comment
@drewreece

drewreece commented Sep 24, 2011

Here is a gist of the script
https://gist.github.com/1239489

@xdissent

This comment has been minimized.

Show comment
Hide comment
@xdissent

xdissent Sep 29, 2011

Owner

It's hard to make VirtualBox automatically install the Guest Additions, so ievms simply mounts the ISO upon first boot to make it easier/remind you to do it. It's really a chicken-or-egg type scenario since we could install Guest Additions via ievms... but only if Guest Additions are already installed LOL.

Thanks for the gist though - it looks very useful if we can make sure it gets run correctly.

Owner

xdissent commented Sep 29, 2011

It's hard to make VirtualBox automatically install the Guest Additions, so ievms simply mounts the ISO upon first boot to make it easier/remind you to do it. It's really a chicken-or-egg type scenario since we could install Guest Additions via ievms... but only if Guest Additions are already installed LOL.

Thanks for the gist though - it looks very useful if we can make sure it gets run correctly.

@drewreece

This comment has been minimized.

Show comment
Hide comment
@drewreece

drewreece Sep 29, 2011

Personally I think the hosts-to-vm is a nice add on it ievms, but since it takes the host's IP & inserts that in to the Windows hosts file it could be fragile for people who use VM's in a different mode, eg internal or bridged networking. The dependance on the guest additions is a pain that means it can't really run without user intervention.

The only solution I can think of is to have a post-setup script to install the hosts & any other tweaks such as removing the guest additions disk from the VM, & maybe adding local host bookmarks & links to relevant IE debugger tools the Windows desktop, basically anything to avoid using Windows :)

Feel free to tweak it, or add it alongside ievms if you want. The comments in the script are overkill, but I was too lazy to move it out to a read me.

Cheers for the handy tool.

drewreece commented Sep 29, 2011

Personally I think the hosts-to-vm is a nice add on it ievms, but since it takes the host's IP & inserts that in to the Windows hosts file it could be fragile for people who use VM's in a different mode, eg internal or bridged networking. The dependance on the guest additions is a pain that means it can't really run without user intervention.

The only solution I can think of is to have a post-setup script to install the hosts & any other tweaks such as removing the guest additions disk from the VM, & maybe adding local host bookmarks & links to relevant IE debugger tools the Windows desktop, basically anything to avoid using Windows :)

Feel free to tweak it, or add it alongside ievms if you want. The comments in the script are overkill, but I was too lazy to move it out to a read me.

Cheers for the handy tool.

@xdissent

This comment has been minimized.

Show comment
Hide comment
@xdissent

xdissent Jun 1, 2012

Owner

SO IMPOSSIBLE. I really would love to provide improvements on the VMs by MS, but it's just not feasible. You must log in before Guest Additions can be installed, and therefore we can't customize anything pre-flight. Sorry.

Owner

xdissent commented Jun 1, 2012

SO IMPOSSIBLE. I really would love to provide improvements on the VMs by MS, but it's just not feasible. You must log in before Guest Additions can be installed, and therefore we can't customize anything pre-flight. Sorry.

@xdissent xdissent closed this Jun 1, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment