Make dhclient use resolvconf

When you use dhclient as a dhcp client, it will write the search domain and dns servers that it receives from the dhcp server directly to /etc/resolv.conf.
Here is how to make it use resolvconf instead.
This was causing trouble for me, because I've got openvpn update my dns configuration when connected, but after disconnecting it would leave my /etc/resolv.conf empty.
Create /etc/dhclient-enter-hooks and put in the following:

function make_resolv_conf {
  if [ x"$new_domain_name_servers" != x ]; then
    cat /dev/null > /etc/resolv.conf.dhclient
    chmod 644 /etc/resolv.conf.dhclient
    if [ x"$new_domain_search" != x ]; then
      echo search $new_domain_search >> /etc/resolv.conf.dhclient
    elif [ x"$new_domain_name" != x ]; then
      # Note that the DHCP 'Domain Name Option' is really just a domain
      # name, and that this practice of using the domain name option as
      # a search path is both nonstandard and deprecated.
      echo search $new_domain_name >> /etc/resolv.conf.dhclient
    fi
    for nameserver in $new_domain_name_servers; do
      echo nameserver $nameserver >>/etc/resolv.conf.dhclient
    done

    # mv /etc/resolv.conf.dhclient /etc/resolv.conf
    resolvconf -a $interface  /etc/resolv.conf.dhclient6
    chmod 644 /etc/resolv.conf.dhclient6

    if [ "x${new_dhcp6_domain_search}" != x ] ; then
      echo search ${new_dhcp6_domain_search} >> /etc/resolv.conf.dhclient6
    fi
    shopt -s nocasematch 
    for nameserver in ${new_dhcp6_name_servers} ; do
      # If the nameserver has a link-local address
      # add a  (interface name) to it.
      if  [[ "$nameserver" =~ ^fe80:: ]]
      then
        zone_id="%$interface"
      else
        zone_id=
      fi
      echo nameserver ${nameserver}$zone_id >> /etc/resolv.conf.dhclient6
    done
    shopt -u nocasematch 

    # mv /etc/resolv.conf.dhclient6 /etc/resolv.conf
    resolvconf -a $interface 

This is in fact the function from /sbin/dhclient-script copied, but changed to use resolvconf instead of writing directly to /etc/resolv.conf
Be sure to make the file executable:

chmod +x /etc/dhclient-enter-hooks

Et voila!