Experimental project

This is a sandbox project, which contains experimental code for developer use only.

This is a collection of drush commands to aid one in altering their hosts file, so as to avoid needing to install and configure a local DNS server. To be made in a way to be reusable as often as possible.

host.drush.inc is now where I am putting all of these commands; I advise putting this in a system wide location for drush to pick it up. See this page for some help with this.

Below is a reformat of the output of the drush help <command> for each of the commands I have in this.

drush host-add
Add to your device's host file through Drush.

Examples:

drush host-add example.com
Tries to find the host file based on the system, and adds the example.com site to point to localhost server.
drush ha example.com --host_file="/etc/hosts" --address="127.0.0.1" --reset="dscachutil -flushcache"
Uses the default values for the full option names, DNS reset command is using the OS X 10.6 command, since the 10.7 one requires sudo out of the box.
drush ha example.com --hf="/etc/hosts" --a="127.0.0.1" --res="dscachutil -flushcache"
Same as above, just using abbreviated forms of options.

Arguments:

url
The url to set in the host file.

Options:

--address
IP Address of the destination. Defaults to '127.0.0.1' if empty.
--host_file
The location of the hosts file. Should be editable without using sudo.
--reset
The command to flush the DNS cache. If you need sudo for this, then leave this be, and you'll need to do that yourself.

Aliases: ha

drush host-remove
Remove an entry from the host configuration file using Drush.

Examples:

drush host-remove example.com
Attempts to locate the hosts file and alter it so the example.com entry is not there.
drush hr example.com --host_file="/etc/hosts" --reset="dscachutil -flushcache"
Removes example.com from the given hosts file, and flushes the DNS cache with the given OSX 10.6 command.
drush hr example.com --hf="/etc/hosts" --res="dscachutil -flushcache"
Same as above, but using abbreviated options.

Arguments:

url
The access url of the site to remove.

Options:

--host_file
The location of the hosts file. Should be editable without using sudo.
--reset
The command to flush the DNS cache. If you need sudo for this, then leave this be, and you'll need to do that yourself.

Also, be sure to read the extra notes issue prior to using either of the provided commands. Coming shortly.

Project information

  • caution Unsupported
    Not supported (i.e. abandoned), and no longer being developed. Learn more about dealing with unsupported (abandoned) projects
  • caution No further development
    No longer developed by its maintainers.
  • Created by tnanek on , updated