--- dhcpcd.sh.ORIG 2010-08-30 14:24:59.000000000 -0500 +++ dhcpcd.sh 2010-08-30 15:16:17.000000000 -0500 @@ -62,6 +62,8 @@ dhcpcd_start() { local iface="$1" opts= pidfile="/var/run/dhcpcd-$1.pid" local ifvar=$(bash_variable "${iface}") metric= d= + local new= + local dhcpopts= interface_exists "${iface}" true || return 1 @@ -69,23 +71,47 @@ opts="dhcpcd_${ifvar}" opts="${dhcpcd} ${!opts}" - # 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 + case "$(/sbin/dhcpcd --version)" in + "dhcpcd "[123]*) new=false ;; + *) new=true ;; + esac + + # Map some dhcp generic options to dhcpcd + eval dhcpopts=\$dhcp_${ifvar} + [ -z "${dhcpopts}" ] && dhcpopts=${dhcp} + for opt in ${dhcpopts}; do + case "${opt}" in + nodns) + if ${new}; then + opts="${opts} -C resolv.conf" + else + opts="${opts} -R" + fi + ;; + nontp) + if ${new}; then + opts="${opts} -C ntp.conf" + else + opts="${opts} -N" + fi + ;; + nonis) + if ${new}; then + opts="${opts} -C yp.conf" + else + opts="${opts} -Y" + fi + ;; + nogateway) opts="${opts} -G";; + nosendhost) opts="${opts} -h ''"; + esac + done + + # We transmit the hostname by default + if [[ " ${opts} " != *" -h "* ]]; then + local hname=$(hostname) + [[ -n ${hname} && ${hname} != "(none)" && ${hname} != "localhost" ]] \ + && opts="-h \"${hname}\" ${opts}" fi # Add our route metric