Index: net-scripts/net/dhcpcd.sh =================================================================== --- net-scripts/net/dhcpcd.sh (revision 3174) +++ net-scripts/net/dhcpcd.sh (working copy) @@ -60,42 +60,64 @@ dhcpcd_stop() { # # Returns 0 (true) when a DHCP address is obtained, otherwise 1 dhcpcd_start() { - local iface="$1" opts= pidfile="/var/run/dhcpcd-$1.pid" + local iface="$1" opt= opts= new= args= pidfile="/var/run/dhcpcd-$1.pid" local ifvar=$(bash_variable "${iface}") metric= d= interface_exists "${iface}" true || return 1 - # Get our options - opts="dhcpcd_${ifvar}" - opts="${dhcpcd} ${!opts}" + # Get dhcpcd options + eval args=\$dhcpcd_${ifvar} + [[ -n ${dhcpcd} ]] && args="${dhcpcd} ${args}" + + # Get generic dhcp options + eval opts=\$dhcp_${ifvar} + [[ -z ${opts} ]] && opts=${dhcp} + + # Figure out which version of dhcpcd we have so we know + # which style of option to use + case $(dhcpcd --version) in + "dhcpcd "[123]*) new=false ;; + *) new=true ;; + esac # Map some generic options to dhcpcd - d="dhcp_${ifvar}" - d=" ${!d} " - [[ ${d} == " " ]] && d=" ${dhcp} " - [[ ${d} == *" nodns "* ]] && opts="${opts} -R" - [[ ${d} == *" nontp "* ]] && opts="${opts} -N" - [[ ${d} == *" nonis "* ]] && opts="${opts} -Y" - [[ ${d} == *" nogateway "* ]] && opts="${opts} -G" - if [[ ${d} == *" nosendhost "* ]] ; then - opts="${opts} -h ''" - else - # We transmit the hostname by default - if [[ " ${opts} " != *" -h "* ]]; then - local hname=$(hostname) - [[ -n ${hname} && ${hname} != "(none)" && ${hname} != "localhost" ]] \ - && opts="-h \"${hname}\" ${opts}" - fi + for opt in ${opts} ; do + case "${opt}" in + nodns) + ${new} \ + && args="${args} -C resolv.conf" \ + || args="${args} -R" + ;; + nontp) + ${new} \ + && args="${args} -C ntp.conf" \ + || args="${args} -N" + ;; + nonis) + ${new} \ + && args="${args} -C yp.conf" \ + || args="${args} -Y" + ;; + nogateway) args="${args} -G" ;; + nosendhost) args="${args} -h ''" ;; + esac + done + + # We transmit the hostname by default + if [[ " ${args} " != *" -h "* ]]; then + local hname=$(hostname) + [[ -n ${hname} && ${hname} != "(none)" && ${hname} != "localhost" ]] \ + && args="-h \"${hname}\" ${args}" fi # Add our route metric metric="metric_${ifvar}" - [[ -n ${!metric} && ${!metric} != "0" ]] && opts="${opts} -m ${!metric}" + [[ -n ${!metric} && ${!metric} != "0" ]] && args="${args} -m ${!metric}" # Bring up DHCP for this interface (or alias) ebegin "Running dhcpcd" - eval /sbin/dhcpcd "${opts}" "${iface}" + eval /sbin/dhcpcd "${args}" "${iface}" eend $? || return 1 # DHCP succeeded, show address retrieved