Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/etc/rc.d Add a hack to fix the dhcpcd rc.d script to work wi...



details:   https://anonhg.NetBSD.org/src/rev/168d1985bd79
branches:  trunk
changeset: 787590:168d1985bd79
user:      roy <roy%NetBSD.org@localhost>
date:      Tue Jun 25 13:02:53 2013 +0000

description:
Add a hack to fix the dhcpcd rc.d script to work with a single
interface specified in dhcpcd_flags in rc.conf(5).
Fixes PR bin/43490

diffstat:

 etc/rc.d/dhcpcd |  22 +++++++++++++++++++++-
 1 files changed, 21 insertions(+), 1 deletions(-)

diffs (32 lines):

diff -r e36d9f88a562 -r 168d1985bd79 etc/rc.d/dhcpcd
--- a/etc/rc.d/dhcpcd   Tue Jun 25 12:27:41 2013 +0000
+++ b/etc/rc.d/dhcpcd   Tue Jun 25 13:02:53 2013 +0000
@@ -9,7 +9,27 @@
 name=dhcpcd
 rcvar=$name
 command=/sbin/$name
-pidfile=/var/run/$name.pid
 
 load_rc_config $name
+
+# If the last argument to dhcpcd is a valid interface and the prior argument
+# is not then dhcpcd will start on one interface only and create a pidfile
+# based on the interface name. See PR bin/43490.
+if [ -n "$flags" ]; then
+       myflags=$flags
+else
+       eval myflags=\$${name}_flags
+fi
+ifname="${myflags##* }"
+myflags="${myflags%% $ifname}"
+last_flag="${myflags##* }"
+if /sbin/ifconfig "$ifname" >/dev/null 2>&1 && 
+    ! /sbin/ifconfig "$last_flag" >/dev/null 2>&1
+then
+       pidfile=/var/run/$name-"$ifname".pid
+else
+       pidfile=/var/run/$name.pid
+fi
+unset myflags ifname last_flag
+
 run_rc_command "$1"



Home | Main Index | Thread Index | Old Index