--- /lib/rcscripts/net/dhcpcd.sh 2010-08-19 23:06:29.557694197 +1000 +++ /lib/rcscripts/net/dhcpcd-new.sh 2010-08-19 23:05:40.389694015 +1000 @@ -2,6 +2,7 @@ # Distributed under the terms of the GNU General Public License v2 # Contributed by Roy Marples (uberlord@gentoo.org) +# Modified by Jeremy W. Murphy for compatibility with dhcpcd-5 # void dhcpcd_depend(void) # @@ -28,6 +29,18 @@ return 1 } +# Returns: 0 (not installed) or major version number. +dhcpcd_version() { + local -i VERSION=0 + # Use /var/db/pkg? + if [ -d /var/db/pkg/net-misc ]; then + local FN=$(ls -d /var/db/pkg/net-misc/dhcpcd-[0-9]*) + if [ $FN ]; then + VERSION=${FN:28:1} + fi + fi + return $VERSION +} # bool dhcpcd_stop(char *iface) # # Stop DHCP on an interface by calling dhcpcd -z $iface @@ -69,11 +82,15 @@ opts="dhcpcd_${ifvar}" opts="${dhcpcd} ${!opts}" + # Get the version + dhcpcd_version + declare -i VERSION=$? + # Map some generic options to dhcpcd d="dhcp_${ifvar}" d=" ${!d} " [[ ${d} == " " ]] && d=" ${dhcp} " - [[ ${d} == *" nodns "* ]] && opts="${opts} -R" + [[ $VERSION == 4 && ${d} == *" nodns "* && ${d} == *" compat "* ]] && opts="${opts} -R" [[ ${d} == *" nontp "* ]] && opts="${opts} -N" [[ ${d} == *" nonis "* ]] && opts="${opts} -Y" [[ ${d} == *" nogateway "* ]] && opts="${opts} -G"