Use the new -P option to work out which pidfile dhcpcd will use.
This commit is contained in:
parent
8ddff245e8
commit
2357a4fb46
|
@ -1,5 +1,7 @@
|
|||
#!/bin/sh
|
||||
|
||||
# $NetBSD: dhcpcd,v 1.5 2016/01/07 22:03:00 roy Exp $
|
||||
|
||||
# PROVIDE: dhcpcd
|
||||
# REQUIRE: network mountcritlocal
|
||||
# BEFORE: NETWORKING
|
||||
|
@ -13,28 +15,14 @@ extra_commands="reload"
|
|||
|
||||
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.
|
||||
# Work out what pidfile dhcpcd will use based on flags
|
||||
if [ -n "$flags" ]; then
|
||||
myflags=$flags
|
||||
else
|
||||
eval myflags=\$${name}_flags
|
||||
fi
|
||||
ifname="${myflags##* }"
|
||||
myflags="${myflags%% $ifname}"
|
||||
last_flag="${myflags##* }"
|
||||
# Address the problem of having just dhcpcd_flags=wm0
|
||||
if [ "$myflags" = "$last_flag" ]; then
|
||||
last_flag="invalidinterfacename"
|
||||
fi
|
||||
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
|
||||
pidfile=$(eval $command -P $myflags 2>/dev/null)
|
||||
: ${pidfile:=/var/run/$name.pid}
|
||||
unset myflags
|
||||
|
||||
run_rc_command "$1"
|
||||
|
|
Loading…
Reference in New Issue