Go to file
Chris Bednarski 394f87d739 Make sure coverage.html is generated when tests fail
This has a side effect of making vet and lint run even if tests fail,
which maybe undesirable.
2015-03-21 20:23:37 -07:00
cmd/hostess Deleted tons of things; also changed env HOSTESS_FILE to HOSTESS_PATH 2015-03-21 02:25:44 -07:00
.gitignore Fixed gox builds 2015-02-24 01:43:33 -08:00
.travis.yml Added travis ci 2015-02-04 21:18:29 -08:00
commands.go Added some comments so golint is happy 2015-03-21 03:01:41 -07:00
hostfile_test.go Changed TestTrimWS to use Diff for output 2015-03-21 20:22:32 -07:00
hostfile.go Changed format to use byte arrays 2015-03-21 17:18:54 -07:00
hostlist_test.go Added MakeSurrogateIP to help with sorting 2015-03-21 18:11:09 -07:00
hostlist.go Added MakeSurrogateIP to help with sorting 2015-03-21 18:11:09 -07:00
hostname_test.go Added tests for hostname formatting 2015-03-21 20:22:44 -07:00
hostname.go Fixed a sort bug and added some more tests 2015-03-02 01:46:12 -08:00
LICENSE Initial commit 2015-01-17 00:57:53 -08:00
Makefile Make sure coverage.html is generated when tests fail 2015-03-21 20:23:37 -07:00
README.md Deleted tons of things; also changed env HOSTESS_FILE to HOSTESS_PATH 2015-03-21 02:25:44 -07:00

hostess

An idempotent command-line utility for managing your /etc/hosts file.

Usage

hostess add domain ip   # Add or change a hosts entry for this domain pointing to this IP
hostess add -off domain ip  # Add in a disabled state (if it already exists, disable it)
hostess del domain      # Remove a domain from your hosts file
hostess has domain      # exit code 0 or 1 if the domain is in your hostfile
hostess off domain      # Disable a domain (but don't remove it completely)
hostess on domain       # Re-enable a domain that was disabled
hostess ls              # List domains, target ips, and on/off status
hostess fix             # Read your hosts file and show warnings if there are bumps
hostess dump            # Dump your hostfile as json
hostess apply           # Add entries from a json file

Flags

-n   # Dry run. Show what will happen but don't do it; output to stdout
-f   # Forcibly rewrite the hostfile, even if there are errors or conflicts
-4   # Limit operation to ipv4 entries
-6   # Limit operation to ipv6 entries

hostess may mangle your hosts file. In general it will probably look like this, with domains pointing at the same IP grouped together and disabled domains commented out.

127.0.0.1 localhost hostname2 hostname3
127.0.1.1 machine.name
# 10.10.20.30 some.host

IPv4 and IPv6

Your hosts file can contain overlapping entries where the same hostname points to both an IPv4 and IPv6 IP. In this case, hostess commands will apply to both entries. Typically you won't have this kind of overlap and the default behavior is OK. However, if you need to be more granular you can use -4 or -6 to limit operations to entries associated with that type of IP.

Installation

Grab a release or download the code and run make install (building probably requires go 1.4).

Configuration

By default, hostess will read / write to /etc/hosts. You can use the HOSTESS_PATH environment variable to provide an alternate path (for testing).

Disclaimer

hostess uses readme-driven-development and may not actually do any of the things listed above. When in doubt, pass the -n flag to try hostess without changing your system.