Skip to content

Latest commit

 

History

History
47 lines (29 loc) · 1.76 KB

README.md

File metadata and controls

47 lines (29 loc) · 1.76 KB

maphosts

Gem Version Circle CI

Small command line application for keeping your project hostnames in sync with /etc/hosts.

Use it within your startup script (make up, shell scripts, etc.) to provide a vagrant up-like experience so people can start coding without spending time setting up and updating /etc/hosts by hand.

Get started

gem install maphosts

Usage

maphosts {www.,static.,}example.lo

This will add www.example.lo, static.example.lo and example.lo to your /etc/hosts. The tool will only update parts of your /etc/hosts which requires the update to preserve the original formatting. When required and with your permission the tool uses sudo to write to /etc/hosts.

By default the hosts will point to 127.0.0.1 but you can provide a custom ip address with the --to option.

boot2docker

maphosts --to $(boot2docker ip) {www.,static.,}example.lo

This will do the same as above but will point these hosts to your boot2docker vm. In case you use multiple docker containers, you can use maphosts to keep your /etc/hosts file in sync with all the containers. You could add maphosts to your docker startup script so it syncs the hosts everytime you start the containers.

# Example of a docker startup script with maphosts
# Developers just run `make up` and can start hacking
up:
    maphosts --to $(boot2docker ip) {www.,static.,}example.lo
    docker start example-www
    docker start example-static

Tests

You can run the rspec suite with rake

rake spec

Contributing

Feel free to send pull requests!